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.Helper;

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

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

        public SettlementInfo()
        {
            InitializeComponent();

            //this.StartPosition = FormStartPosition.CenterParent;

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

        }

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

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