using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Newtonsoft.Json.Linq;
using PTMedicalInsurance.Variables;
using PTMedicalInsurance.Business;
using PTMedicalInsurance.Common;

namespace PTMedicalInsurance.Forms
{
    public partial class SettlementForm : Form
    {

        //1.声明自适应类实例
        AutoResizeForm asc = new AutoResizeForm();

        public SettlementForm()
        {
            InitializeComponent();

            //this.StartPosition = FormStartPosition.CenterParent;

            asc.controllInitializeSize(this);
            asc.controlAutoSize(this);

        }

        public SettlementForm(JObject jo)
        {
            InitializeComponent();
            JObject joSettlmentInfo = JObject.FromObject(jo["setlinfo"]);
            dtSettlmentDetail = (DataTable)jo["setldetail"].ToObject(typeof(DataTable));
            this.tbAdmCertType.Text = joSettlmentInfo["mdtrt_cert_type"].Text();
            this.tbPsnCertType.Text = joSettlmentInfo["psn_cert_type"].Text();
            this.tbPsnCertNO.Text = joSettlmentInfo["certno"].Text();
            this.tbInsuType.Text = joSettlmentInfo["insutype"].Text();
            this.tbPersonType.Text = joSettlmentInfo["psn_type"].Text();
            this.tbMedType.Text = joSettlmentInfo["med_type"].Text();
            this.tbSumamt.Text = joSettlmentInfo["medfee_sumamt"].Text();
            this.tbFullOwnPay.Text = joSettlmentInfo["fulamt_ownpay_amt"].Text();
            this.tbOverLimitOwnPay.Text = joSettlmentInfo["overlmt_selfpay"].Text();
            this.tbPreSelfPay.Text = joSettlmentInfo["preselfpay_amt"].Text();
            this.tbInScopyAmount.Text = joSettlmentInfo["inscp_scp_amt"].Text();
            this.tbActualPayDeduLine.Text = joSettlmentInfo["act_pay_dedc"].Text();
            this.tbInsuFundPay.Text = joSettlmentInfo["hifp_pay"].Text();
            this.tbInsuFundPayRito.Text = joSettlmentInfo["pool_prop_selfpay"].Text();
            this.tbCvlserv_pay.Text = joSettlmentInfo["cvlserv_pay"].Text();
            this.tbHifes_pay.Text = joSettlmentInfo["hifes_pay"].Text();
            this.tbHifmi_pay.Text = joSettlmentInfo["hifmi_pay"].Text();
            this.tbWorkerLargeMedical.Text = joSettlmentInfo["hifob_pay"].Text();
            this.tbAssian.Text = joSettlmentInfo["maf_pay"].Text();
            this.tbOtherPay.Text = joSettlmentInfo["oth_pay"].Text();
            this.tbFundPaySummat.Text = joSettlmentInfo["fund_pay_sumamt"].Text();
            this.tbPsnSummat.Text = joSettlmentInfo["psn_part_amt"].Text();
            this.tbPsnAccountPaySummat.Text = joSettlmentInfo["acct_pay"].Text();
            this.tbPsnCashPay.Text = joSettlmentInfo["psn_cash_pay"].Text();
            this.tbHospitalPartAmount.Text = joSettlmentInfo["hosp_part_amt"].Text();
            this.tbBalc.Text = joSettlmentInfo["balc"].Text();
            this.tbAccountMutualAidAmount.Text = joSettlmentInfo["acct_mulaid_pay"].Text();
            this.tbClearingWay.Text = joSettlmentInfo["clr_way"].Text();
            this.tbClearingType.Text = joSettlmentInfo["clr_type"].Text();
            Global.Set.acctPay = joSettlmentInfo["acct_pay"].Text();
            setDgvSettlDetailHeader();
            dgvSetlDetail.DataSource = dtSettlmentDetail;           

        }
        private void AddDGVColumn(DataGridView dgv, string headerText, string dataPropertyName, int width = 120)
        {
            DataGridViewColumn newColumn = new DataGridViewTextBoxColumn();
            newColumn.HeaderText = headerText;
            newColumn.Width = width;
            newColumn.DataPropertyName = dataPropertyName;
            newColumn.Name = dataPropertyName;
            dgv.Columns.Add(newColumn);
        }

        private void  setDgvSettlDetailHeader()
        {
            AddDGVColumn(dgvSetlDetail, "基金支付类型", "fund_pay_type", 80);
            AddDGVColumn(dgvSetlDetail, "符合政策范围金额", "inscp_scp_amt");
            AddDGVColumn(dgvSetlDetail, "本次可支付限额金额", "crt_payb_lmt_amt");
            AddDGVColumn(dgvSetlDetail, "基金支付金额", "fund_payamt");
            AddDGVColumn(dgvSetlDetail, "基金支付类型名称", "fund_pay_type_name", 300);
            AddDGVColumn(dgvSetlDetail, "结算过程信息", "setl_proc_info", 200);
            dgvSetlDetail.ColumnHeadersDefaultCellStyle.Font = new Font("宋体", 9, FontStyle.Bold);
            dgvSetlDetail.ColumnHeadersHeight = 40;
        }
        public DataTable dtSettlmentDetail;
        //险种
        public string insuType { get; set; }


        private void pnlPayInfo_Click(object sender, EventArgs e)
        {

        }

        private void uiLabel29_Click(object sender, EventArgs e)
        {

        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            Global.pat.mutualAidFlag = cbMutualAid.Checked;
            DialogResult = DialogResult.OK;
        }

        private void uiButton2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }
}