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;

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