/******************************************************************************
 * 文件名称: GridViewSetter.cs
 * 文件说明: GridView界面的设置
 * 当前版本: V1.0
 * 创建日期: 2022-04-14
 * 2020-04-14: 增加 AddDGVColumn 方法
 * 2020-04-14: 增加 AddDGVCheckBoxColumn 方法
 * 2020-04-14: 增加 SetHeaderTextOfDrug 方法
 * 2020-04-14: 增加 SetHeaderTextOfDiagnose 方法


******************************************************************************/
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PTMedicalInsurance.FormSetter
{
    class GridViewSetter
    {
        /// <summary>
        /// 动态增加datagridview列
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="headerText"></param>
        /// <param name="dataPropertyName"></param>
        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 AddDGVCheckBoxColumn(DataGridView dgv, string headerText, string dataPropertyName, int width = 120)
        {
            DataGridViewColumn newColumn = new DataGridViewCheckBoxColumn();
            newColumn.HeaderText = headerText;
            newColumn.Width = width;
            newColumn.DataPropertyName = dataPropertyName;
            newColumn.Name = dataPropertyName;
            dgv.Columns.Add(newColumn);
        }

        private void AddDGVComboxColumn(DataTable dt,DataGridView dgv, string headerText, string dataPropertyName, int width = 120)
        {
            DataGridViewComboBoxColumn newColumn = new DataGridViewComboBoxColumn();
            newColumn.DataSource = dt;
            newColumn.HeaderText = headerText;
            newColumn.Width = width;
            newColumn.DataPropertyName = dataPropertyName;
            newColumn.Name = dataPropertyName;
            newColumn.DisplayMember = "descripts";
            newColumn.ValueMember = "id";
            dgv.Columns.Add(newColumn);
        }

        #region 设置表格标题

        public void SetHeaderTextOfInterfaceMaintain(DataTable dt, DataGridView dgv)
        {
            dgv.Columns.Clear();
            AddDGVComboxColumn(dt,dgv, "医院ID", "HospitalDr", 200);
            AddDGVColumn(dgv, "编码", "InterfaceID", 200);
            AddDGVColumn(dgv, "名称", "InterfaceName", 200);
            AddDGVColumn(dgv, "中心编码", "HospitalNO");
            AddDGVColumn(dgv, "医院等级", "HospitalLevel");
            AddDGVColumn(dgv, "中心网址", "CenterURL");
            AddDGVColumn(dgv, "中心网址2", "CenterURL2");
            AddDGVColumn(dgv, "对应DLL名称", "DLLName");
            AddDGVColumn(dgv, "区划代码", "AreaCode");
            AddDGVCheckBoxColumn(dgv, "使用标志", "UseFlag");
        }
        /// <summary>
        /// 设置药品列标题
        /// </summary>
        public void SetHeaderTextOfDrug(DataGridView dgv)
        {
            dgv.Columns.Clear();
            AddDGVColumn(dgv, "编码", "Code", 200);
            AddDGVColumn(dgv, "名称", "Name", 200);
            AddDGVColumn(dgv, "批准文号", "ApprovalNO", 200);
            AddDGVColumn(dgv, "剂型", "DosageFormCode");
            AddDGVColumn(dgv, "剂型名称", "DosageFormName");
            AddDGVColumn(dgv, "规格", "Specification");
            AddDGVColumn(dgv, "包装单位", "UnitOfPackag");
            AddDGVColumn(dgv, "计价单位", "UnitOfValuation");
            AddDGVColumn(dgv, "有效标志", "ValidFlag");
            AddDGVCheckBoxColumn(dgv, "使用标志", "UseFlag");
            AddDGVColumn(dgv, "特殊药品标志", "SpecialFlag");
            AddDGVColumn(dgv, "限制标志", "LimitFlag");
            AddDGVColumn(dgv, "限制范围", "LimitRange");
            AddDGVColumn(dgv, "版本号", "VersionNO");
        }

        /// <summary>
        /// 设置诊断，手术，病种等列标题
        /// </summary>
        public void SetHeaderTextOfDiagnose(DataGridView dgv)
        {
            dgv.Columns.Clear();
            AddDGVColumn(dgv, "编码", "CategoryCode");
            AddDGVColumn(dgv, "类名", "CategoryName");

        }

        /// <summary>
        /// 设置药品列标题
        /// </summary>
        public void SetHeaderTextOfSettlList(DataGridView dgv)
        {
            dgv.AutoGenerateColumns = false;
            dgv.Columns.Clear();
            AddDGVColumn(dgv, "结算编号", "SettlementID", 200);
            AddDGVColumn(dgv, "就诊号", "MdtrtID", 200);
            AddDGVColumn(dgv, "姓名", "PatientName");
            AddDGVColumn(dgv, "险种", "InsuranceType");
            AddDGVColumn(dgv, "人员类别", "PersonType");
            AddDGVColumn(dgv, "结算时间", "SettlementTime");
            AddDGVColumn(dgv, "医疗类别", "MedicalType");
            AddDGVColumn(dgv, "总金额", "Sumamt");
            AddDGVColumn(dgv, "自付金额", "OwnPayAmount");
            AddDGVColumn(dgv, "超限金额", "OverLimitAmount");
            AddDGVColumn(dgv, "先行自付", "PreSelfPayAmount");
            AddDGVColumn(dgv, "政策范围内金额", "InPolicyRangeAmount");
            AddDGVColumn(dgv, "公务员补助金额", "CivilserviceAllowancePay");
            AddDGVColumn(dgv, "大病补助金额", "SeriousIllnessPay");
            AddDGVColumn(dgv, "大额补助金额", "LargeExpensesSupplementPay");
            AddDGVColumn(dgv, "医疗救助金额", "MedicalAssistPay");
            AddDGVColumn(dgv, "医院承担金额", "HospitalPartAmount");
            AddDGVColumn(dgv, "其他支出金额", "OtherPay");
            AddDGVColumn(dgv, "基金支付金额", "FundPaySumamt");
            AddDGVColumn(dgv, "个人支付金额", "PersonPaySumamt");
            AddDGVColumn(dgv, "现金支付金额", "PersonCashPay");
            AddDGVColumn(dgv, "账户余额", "Balance");
            AddDGVColumn(dgv, "共济账户支付金额", "AccountMutualAidAmount");
            AddDGVColumn(dgv, "清算机构", "ClearingOrgan");
            AddDGVColumn(dgv, "清算方式", "ClearingWay");
            AddDGVColumn(dgv, "清算类型", "ClearingType");
            AddDGVColumn(dgv, "有效标志", "ValidFlag");
        }

        /// <summary>
        /// 设置中心交易日志列标题
        /// </summary>
        public void SetHeaderTextOfCenterLog(DataGridView dgv)
        {
            dgv.AutoGenerateColumns = false;
            dgv.Columns.Clear();
            AddDGVColumn(dgv, "报文ID", "msgid", 200);
            AddDGVColumn(dgv, "交易编号", "infno", 80);
            AddDGVColumn(dgv, "医保编号", "psn_no", 200);
            AddDGVColumn(dgv, "交易时间", "inf_time", 200);
            AddDGVColumn(dgv, "参保地", "insuplc_admdvs", 100);
            AddDGVColumn(dgv, "就医地", "mdtrtarea_admvs", 100);
            AddDGVColumn(dgv, "入参", "inparam");
            AddDGVColumn(dgv, "出参", "outparam");
            AddDGVColumn(dgv, "操作员", "opter", 80);
            AddDGVColumn(dgv, "有效标志", "validflag", 60);
            AddDGVColumn(dgv, "接收系统编码", "recer_sys_code", 60);
            AddDGVColumn(dgv, "设备编号", "dev_no", 200);
            AddDGVColumn(dgv, "医疗机构编码", "fixmedins_code", 150);
            AddDGVColumn(dgv, "医疗机构名称", "fixmedins_name", 300);
        }

        /// <summary>
        /// 设置登记列标题
        /// </summary>
        public void SetHeaderTextOfRegister(DataGridView dgv)
        {
            dgv.AutoGenerateColumns = false;
            dgv.Columns.Clear();
            AddDGVColumn(dgv, "HIS就诊号", "AdmID", 80);
            AddDGVColumn(dgv, "姓名", "Pat_Name", 80);
            AddDGVColumn(dgv, "医保编号", "PersonalNO", 300);
            AddDGVColumn(dgv, "医保登记号", "InsuRegID", 250);
            AddDGVColumn(dgv, "中心登记时间", "RegDate", 200);
            AddDGVColumn(dgv, "发生时间", "OccurTime", 200);
            AddDGVColumn(dgv, "险种", "InsuType",80);
            AddDGVColumn(dgv, "凭证类型", "Cert_Type",60);
            AddDGVColumn(dgv, "凭证编号", "Cert_NO", 250);
            AddDGVColumn(dgv, "医疗类别", "med_type", 60);
            AddDGVColumn(dgv, "参保地", "insuplc_admdvs", 60);
            AddDGVColumn(dgv, "就医地", "mdtrtarea_admvs", 60);
            AddDGVColumn(dgv, "登记状态", "RegState", 60);
            AddDGVColumn(dgv, "有效标志", "ValidFlag", 60);
            AddDGVColumn(dgv, "类型", "Type", 60);
            AddDGVColumn(dgv, "取消登记时间", "CancleRegDate", 200);
            AddDGVColumn(dgv, "报文ID", "msgid", 250);
        }
        #endregion
    }
    
}
