| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387 | 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 PTMedicalInsurance.Common;using PTMedicalInsurance.Helper;using Newtonsoft.Json.Linq;using PTMedicalInsurance.FormSetter;using System.IO;using System.IO.Compression;using PTMedicalInsurance.Business;using Sunny.UI;using Newtonsoft.Json;using System.Collections;using PTMedicalInsurance.Variables;namespace PTMedicalInsurance.Forms{    public partial class ClearingQuery : Form    {        private string txtPath;        private string txtName;        private string finalAchPath;        private UIDataGridViewFooter dgvHisSettlRecFooter = new Sunny.UI.UIDataGridViewFooter();        JObject jo9102Rtn = new JObject();        public ClearingQuery()        {            InitializeComponent();            this.StartPosition = FormStartPosition.CenterParent;        }        private void Clearing_Load(object sender, EventArgs e)        {            ComboxSetter cbxSetter = new ComboxSetter();            cbxSetter.setCbxInterfaceDataSource(cbxInterface);            cbxSetter.setCbxDictionaryDataSource(Global.inf.interfaceDr.ToString(), "insutype", cbxInsuType);            cbxSetter.setCbxDictionaryDataSource(Global.inf.interfaceDr.ToString(), "clr_type", cbxClrType);            GridViewSetter grdSetter = new GridViewSetter();            grdSetter.SetHeaderTextOfCheck(dgvSettlSummary);                        grdSetter.SetHeaderTextOfOthPlcCheck(dgvOthCheck);            cbgGroupSet.SelectAll();            cbgGroupSet.SetItemCheckState(4, false);            dpST.Text = DateTime.Now.ToString("yyyy-MM-01 00:00:00");            dpED.Value = DateTime.Now.AddDays(1 - DateTime.Now.Day).AddMonths(1).AddDays(-1);            cbxInterface.SelectedValueChanged += new EventHandler(cbxInterface_SelectedValueChanged);            WindowState = FormWindowState.Maximized;            tbTmp.Text= Global.currentDirectory + "\\Download";        }        private void cbxInterface_SelectedValueChanged(object sender, EventArgs e)        {            DataTable dtInteface = (DataTable)cbxInterface.DataSource;            int i = cbxInterface.SelectedIndex;            if (i != 2)            {                Global.pat.insuplc_admdvs = "";            }            else            {                Global.pat.insuplc_admdvs = "370100";            }            Global.inf.hospitalNO = dtInteface.Rows[i]["HospitalNO"].ToString();            Global.inf.hospitalName = dtInteface.Rows[i]["HospitalName"].ToString();            Global.inf.centerURL = dtInteface.Rows[i]["CenterURL"].ToString();            Global.inf.areaCode = dtInteface.Rows[i]["AreaCode"].ToString();            Global.user.name = "0";            Global.user.ID = "0";            Global.inf.operatoType = "3";            Global.inf.version = "v1.0";            Global.inf.recivedSystem = "SY";            Global.inf.interfaceDr = int.Parse(dtInteface.Rows[i]["ID"].ToString());            ComboxSetter cbxSetter = new ComboxSetter();            cbxSetter.setCbxDictionaryDataSource(dtInteface.Rows[i]["ID"].ToString(), "insutype", cbxInsuType);            cbxSetter.setCbxDictionaryDataSource(dtInteface.Rows[i]["ID"].ToString(), "clr_type", cbxClrType);        }        private void cmsCheck_Opening(object sender, CancelEventArgs e)        {        }        /// <summary>        /// 单条对总账事件        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void tsmCheck_Single_Click(object sender, EventArgs e)        {            string error = "";            if (Check_Single(out error) != 0)            {                MessageBox.Show("对总账失败:" + error);            }            else            {                MessageBox.Show("对总账成功");            }        }        /// <summary>        /// 单条对总账【本地】        /// </summary>        /// <param name="error"></param>        /// <returns></returns>        private int Check_Single(out string error)        {            error = "";string setlOptins = "";            DataTable dt = (DataTable)dgvSettlSummary.DataSource;            int i = dgvSettlSummary.CurrentRow.Index;            dynamic joCheck = new JObject();            joCheck.insutype = dt.Rows[i]["insutype"].ToString();                       //险种类型            joCheck.clr_type = dt.Rows[i]["clr_type"].ToString();                       //清算类别                        joCheck.setl_optins = dt.Rows[i]["setl_optins"].ToString();             //结算经办机构            setlOptins = dt.Rows[i]["setl_optins"].ToString();            joCheck.medfee_sumamt = dt.Rows[i]["medfee_sumamt"].ToString();             //医疗费总额            joCheck.fund_pay_sumamt = dt.Rows[i]["fund_pay_sumamt"].ToString();         //基金支付总额            joCheck.acct_pay = dt.Rows[i]["acct_pay"].ToString();                       //个人账户支付金额            joCheck.fixmedins_setl_cnt = dt.Rows[i]["fixmedins_setl_cnt"].ToString();   //定点医药机构结算笔数            joCheck.stmt_begndate = dpST.Value.ToString("yyyy-MM-dd HH:mm:ss");         //对账开始日期            joCheck.stmt_enddate = dpED.Value.ToString("yyyy-MM-dd HH:mm:ss");          //对账结束日期            JObject joData = new JObject();            joData.Add("data", joCheck);            //f            CenterBusiness cBus = new CenterBusiness();            JObject jo9001Rtn = new JObject();            cBus.signIn(out jo9001Rtn);            Global.pat.insuplc_admdvs = setlOptins;            InvokeHelper invoker = new InvokeHelper();            JObject joRtn = invoker.invokeCenterService(TradeEnum.FeeSummaryCheck, joData);             if (JsonHelper.parseCenterReturnJson(joRtn, out error) != 0)            {                return -1;            }            else            {                if (JsonHelper.getDestValue(joRtn, "output.stmtinfo.stmt_rslt") != "0")                {                    error = JsonHelper.getDestValue(joRtn, "output.stmtinfo.stmt_rslt_dscr");                    return -1;                }                else                {                    return 0;                }            }        }        private int OthPlcCheck_Single(out string error)        {            error = "";            DataTable dt = (DataTable)dgvOthCheck.DataSource;            int i = dgvOthCheck.CurrentRow.Index;            Global.inf.areaCode = dt.Rows[i]["insuplc_admdvs"].ToString();            int billType = int.Parse(dt.Rows[i]["BillType"].ToString());            dynamic joCheck = new JObject();            joCheck.psn_no = dt.Rows[i]["PersonnelNO"].ToString();            joCheck.medfee_sumamt = billType * Convert.ToDecimal(dt.Rows[i]["Sumamt"].ToString());            joCheck.optins_pay_sumamt = billType * (Convert.ToDecimal(dt.Rows[i]["FundPaySumamt"].ToString()) + Convert.ToDecimal(dt.Rows[i]["AccountPaySumamt"].ToString()));            joCheck.mdtrt_setl_time = Convert.ToDateTime(dt.Rows[i]["SettlementTime"].ToString()).ToString("yyyyMMddHHmmss");            joCheck.trns_type = dt.Rows[i]["BillType"].ToString();            joCheck.mdtrt_id = dt.Rows[i]["MdtrtID"].ToString();            joCheck.setl_id = dt.Rows[i]["SettlementID"].ToString();            JArray jaCheck = new JArray();            jaCheck.Add(joCheck);            JObject joData = new JObject();            joData.Add("data", jaCheck);            //上传给中心            //先签到            CenterBusiness cBus = new CenterBusiness();            JObject jo9001Rtn = new JObject();            cBus.signIn(out jo9001Rtn);            InvokeHelper invoker = new InvokeHelper();            JObject joRtn = invoker.invokeCenterService(TradeEnum.FeeSummaryCheck, joData);            if (JsonHelper.parseCenterReturnJson(joRtn, out error) != 0)            {                return -1;            }            else            {                if (JsonHelper.getDestValue(joRtn, "output.result[0].succ_flag") != "0")                {                    error = JsonHelper.getDestValue(joRtn, "output.result[0].prmmsg");                    return -1;                }                else                    return 0;            }        }        //private int CancleOthPlcClearing_Single(out string error)        //{        //    error = "";        //    DataTable dt = (DataTable)dgvClearingData.DataSource;        //    int i = dgvClearingData.CurrentRow.Index;        //    dynamic joCancleClearing = new JObject();        //    joCancleClearing.clr_appy_evt_id = dt.Rows[i]["ApplyID"].ToString();        //    joCancleClearing.data_ym = dt.Rows[i]["ClearYearMonth"].ToString();        //    JObject joData = new JObject();        //    joData.Add("data", joCancleClearing);        //    //上传给中心        //    //先签到        //    CenterBusiness cBus = new CenterBusiness();        //    JObject jo9001Rtn = new JObject();        //    cBus.signIn(out jo9001Rtn);        //    InvokeHelper invoker = new InvokeHelper();        //    JObject joRtn = invoker.invokeCenterService(TradeEnum.ClearingCancel, joData);        //    if (JsonHelper.parseCenterReturnJson(joRtn, out error) != 0)        //    {        //        return -1;        //    }        //    else        //    {        //        //保存到医保平台        //        JObject joTmp = new JObject();        //        joTmp.Add("HospitalDr", Global.inf.hospitalDr);        //        joTmp.Add("InterfaceDr", Global.inf.interfaceDr);        //        joTmp.Add("ApplyID", dt.Rows[i]["ApplyID"].ToString());        //        //joTmp.Add("CancleOccurTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));        //        //joTmp.Add("ClrWay", dt.Rows[i]["clr_way"].ToString());        //        joTmp.Add("ClrType", dt.Rows[i]["ClrType"].ToString());        //        //joTmp.Add("ClearYearMonth", dpST_2.Value.ToString("yyyyMM"));        //        //joTmp.Add("PersonTime", dt.Rows[i]["psntime"].ToString());        //        //joTmp.Add("Sumamt", dt.Rows[i]["med_sumfee"].ToString());        //        //joTmp.Add("MedAcceptSumamt", dt.Rows[i]["med_sumfee"].ToString());        //        //joTmp.Add("FundPay", dt.Rows[i]["fund_appy_sum"].ToString());        //        //joTmp.Add("CashPay", dt.Rows[i]["cash_payamt"].ToString());        //        //joTmp.Add("AccountPay", dt.Rows[i]["acct_pay"].ToString());        //        //joTmp.Add("Begndate", dpST_2.Value.ToString("yyyy-MM-dd 00:00:00"));        //        //joTmp.Add("Enddate", dpED_2.Value.ToString("yyyy-MM-dd 23:59:59"));        //        joTmp.Add("ValidFlag", -1);        //        joTmp.Add("updateUserID", "0");        //        //joTmp.Add("Operator", "0");        //        JArray jaParam = new JArray();        //        jaParam.Add(joTmp);        //        JObject joUpdate = new JObject();        //        joUpdate.Add("params", jaParam);        //        joUpdate.Add("updateUserID", "0");        //        joUpdate.Add("HospitalDr", Global.inf.hospitalDr);        //        joUpdate.Add("InterfaceDr", Global.inf.interfaceDr);        //        joUpdate.Add("code", "09010067");        //        invoker = new InvokeHelper();        //        joRtn = invoker.invokeInsuService(joUpdate.ToString(), "更新清算记录");        //        if (JsonHelper.parseIrisRtnValue(joRtn, out error) != 0)        //        {        //            return -1;        //        }        //        else        //            return 0;        //    }        //}        private int queryHisSettlementInfo(out string error)        {            GridViewSetter grdSetter = new GridViewSetter();            grdSetter.SetHeaderTextOfHisSettlRec(dgvHisSettlRec);            error = "";            try            {                DataTable dtInteface = (DataTable)cbxInterface.DataSource;                int i = cbxInterface.SelectedIndex;                string sqlStr = "SELECT SUM(BillType*Sumamt) AS medfee_sumamt,count(*) AS fixmedins_setl_cnt, ";                sqlStr = sqlStr + " SUM(BillType*AccountPaySumamt) AS acct_pay,SUM(BillType*HealthInsurancePay) AS fund_pay_sumamt ";                //sqlStr = sqlStr + " Interface_dr,clearingWay AS clr_way,clearingType AS clr_type ";                string conditionStr = " ";                DataTable dtSettlSummary = (DataTable)dgvSettlSummary.DataSource;                int iCurRow = dgvSettlSummary.CurrentRow.Index;                //DataTable dtInteface = (DataTable)cbxInterface.DataSource;                if (cbgGroupSet.GetItemCheckState(0))                {                    conditionStr = conditionStr + " and Interface_Dr ='" + dtSettlSummary.Rows[iCurRow]["Interface_dr"].ToString() + "'";                }                if (cbgGroupSet.GetItemCheckState(1))                {                    conditionStr = conditionStr + " and InsuranceType ='" + dtSettlSummary.Rows[iCurRow]["insutype"].ToString() + "'";                }                if (cbgGroupSet.GetItemCheckState(2))                {                    conditionStr = conditionStr + " and ClearingType ='" + dtSettlSummary.Rows[iCurRow]["clr_type"].ToString() + "'";                }                if (cbgGroupSet.GetItemCheckState(3))                {                    conditionStr = conditionStr + " and ClearingOrgan ='" + dtSettlSummary.Rows[iCurRow]["setl_optins"].ToString() + "'";                }                if (cbgGroupSet.GetItemCheckState(4))                {                    sqlStr = sqlStr + ",BillType";                    conditionStr = conditionStr + " and BillType ='" + dtSettlSummary.Rows[iCurRow]["BillType"].ToString() + "'";                }                sqlStr = "select *  FROM  BS_MedInsuSettlement WHERE Hospital_Dr=" + dtInteface.Rows[i]["HospitalDr"].ToString();                sqlStr = sqlStr + " and OccurTime>'" + dpST.Text + "'";                sqlStr = sqlStr + " and OccurTime<'" + dpED.Text + "'";                //省医保和市医保对账一样,异地对账需要用到另外的对账交易                //if (Global.inf.interfaceDr == 1)                //{                //    sqlStr = sqlStr + " and (InsuranceAreaCode='539900' or InsuranceAreaCode='530100')";                //}                //conditionStr = conditionStr.Substring(0,conditionStr.Length -1 );                //conditionStr = conditionStr.Remove(conditionStr.Length - 1, 1);                sqlStr = sqlStr + conditionStr;                JObject joSqlstr = new JObject();                joSqlstr.Add("sqlStr", sqlStr);                JArray jaParam = new JArray();                jaParam.Add(joSqlstr);                JObject joSettlQuery = new JObject();                joSettlQuery.Add("params", jaParam);                joSettlQuery.Add("code", "09010059");                InvokeHelper invoker = new InvokeHelper();                JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");                //DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));                JArray ja = JArray.Parse(JsonHelper.getDestValue(joRtn, "result.data"));                DataTable dt = (DataTable)JsonConvert.DeserializeObject(JsonHelper.getDestValue(joRtn, "result.data"), (typeof(DataTable)));                dgvHisSettlRec.DataSource = dt;                //dt.Columns[7].DataType = typeof(float);//不允许                //dgvHisSettlRecFooter.DataGridView = dgvHisSettlRec;                //dgvHisSettlRecFooter.Dock = System.Windows.Forms.DockStyle.Bottom;                //dgvHisSettlRecFooter.Clear();                //dgvHisSettlRecFooter["AdmID"] = "合计";                //dgvHisSettlRecFooter["OverLimitAmount"] = "测试";                return 0;            }            catch (Exception ex)            {                error = "queryHisSettlementInfo:" + ex.Message;                return -1;            }        }        private void tsmCheckDetail_Single_Click(object sender, EventArgs e)        {            //HIS明细            string error;            if (queryHisSettlementInfo(out error) != 0)            {                MessageBox.Show(error);            }            //中心明细            if (CheckDetail_Single(out error) != 0)            {                MessageBox.Show(error);            }        }        /// <summary>        /// 查询HIS结算明细记录        /// </summary>        /// <param name="sender"></param>        /// <param name="e"></param>        private void tsmHisRecord_Click(object sender, EventArgs e)        {            string error;            if (queryHisSettlementInfo(out error) != 0)            {                MessageBox.Show(error);            }        }        public static void writeToTxt(string content, string filePath, string fileName)        {            //创建文件夹,文件夹名称与TXT同名            string finalPath = filePath + "\\" + fileName;            if (!Directory.Exists(finalPath))            {                DirectoryInfo dirInfo = Directory.CreateDirectory(finalPath);            }            //判断文件夹中是否存在txt            string finalFileName = finalPath + "\\" + fileName + ".txt";            if (!File.Exists(finalFileName))            {                FileStream fs1 = File.Create(finalFileName);                fs1.Close();            }            FileStream fs = new FileStream(finalFileName, FileMode.Append, FileAccess.Write);            StreamWriter sw = new StreamWriter(fs);            sw.WriteLine(content);            sw.Close();            fs.Close();        }        /// <summary>        /// 读文件到byte[]        /// </summary>        /// <param name="fileName">硬盘文件路径</param>        /// <returns></returns>        public static byte[] ReadFileToByte(string fileName)        {            FileStream pFileStream = null;            byte[] pReadByte = new byte[0];            try            {                pFileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);                BinaryReader r = new BinaryReader(pFileStream);                r.BaseStream.Seek(0, SeekOrigin.Begin);    //将文件指针设置到文件开                pReadByte = r.ReadBytes((int)r.BaseStream.Length);                return pReadByte;            }            catch            {                return pReadByte;            }            finally            {                if (pFileStream != null)                    pFileStream.Close();            }        }        /// <summary>        ///单字节转有符号整数        /// </summary>        /// <param name="data"></param>        /// <returns></returns>        public string byteArrayToDecString(byte[] data)        {            StringBuilder builder = new StringBuilder();            for (int i = 0; i < data.Length; i++)            {                builder.Append((sbyte)data[i] + ",");            }            return builder.ToString().Trim();        }        private int HISDetailDataExport(string filePath, string fileName)        {            try            {                DataTable dt = (DataTable)dgvHisSettlRec.DataSource;                string content = "";                for (int i = 0; i < dt.Rows.Count; i++)                {                    string flag = "";                    if (dt.Rows[i]["ValidFlag"].ToString() == "-1")                    {                        flag = "1";                    }                    else                    {                        flag = "0";                    }                    content = "\r\n"                            + dt.Rows[i]["SettlementID"].ToString() + "\t"                            + dt.Rows[i]["MdtrtID"].ToString() + "\t"                            + dt.Rows[i]["PersonnelNO"].ToString() + "\t"                            + dt.Rows[i]["Sumamt"].ToString() + "\t"                            + dt.Rows[i]["FundPaySumamt"].ToString() + "\t"                            + dt.Rows[i]["AccountPaySumamt"].ToString() + "\t"                            + flag                            + content;                }                string finalContent = content.Remove(0, 2);                writeToTxt(finalContent, filePath, fileName);                return 0;            }            catch (Exception ex)            {                MessageBox.Show(ex.Message);                return -1;            }        }        private void tsmExport_Click(object sender, EventArgs e)        {            txtName = DateTime.Now.ToString("yyyyMMddHHmmssffff");            txtPath = Global.currentDirectory + "\\Download";            if (HISDetailDataExport(txtPath, txtName) != 0)            {                MessageBox.Show("导出TXT失败!");            }            else            {                MessageBox.Show("导出TXT成功!");            }                        //System.IO.Compression.ZipFile.CreateFromDirectory(txtPath + "\\" + "2022ceshi", txtPath + "\\" + "111.zip");        }        private void tsmCompress_Click(object sender, EventArgs e)        {            string path = @"C:\ProgramData\prykNT\prBrowser\bin\service\plugins\INSUNew\DownLoad\111";            string name = @"1121.zip";            string finalDirPath = txtPath + "\\" + txtName;            finalAchPath = finalDirPath + ".zip";            System.IO.Compression.ZipFile.CreateFromDirectory(finalDirPath, finalAchPath);            //System.IO.Compression.ZipFile.CreateFromDirectory(path, name);            //System.IO.Compression.ZipFile.CreateFromDirectory(path, name, 0, true);            MessageBox.Show("将TXT压缩为ZIP成功!");        }        private void tsmZIPToSDec_Click(object sender, EventArgs e)        {            byte[] bArray = ReadFileToByte(finalAchPath);            string str = byteArrayToDecString(bArray);            Global.writeLog(str);            MessageBox.Show("ZIP转为有符号整数成功!");        }        private void tsmUploadZIP_Click(object sender, EventArgs e)        {            string outParam = "";            byte[] bArray = ReadFileToByte(finalAchPath);            string str = "[" + byteArrayToDecString(bArray) + "]";            JObject joTmp = new JObject();            joTmp.Add("in", JArray.Parse(str));            joTmp.Add("filename", txtName + ".zip");            Global.inf.fileName = txtName + ".zip";            //joTmp.Add("filename", finalAchPath.Replace("\\",@"\"));            joTmp.Add("fixmedins_code", Global.inf.hospitalNO);            JObject joFsUploadIn = new JObject();            joFsUploadIn.Add("fsUploadIn", joTmp);            InvokeHelper invoker = new InvokeHelper();            JObject jo9101Rtn= invoker.invokeCenterService(TradeEnum.FileUpload, joFsUploadIn);            if (JsonHelper.parseCenterRtnValue(jo9101Rtn, out outParam) != 0)            {                                outParam = JsonHelper.setExceptionJson(-1, "【9101】文件上传失败", outParam).ToString();                                return;            }            else            {                MessageBox.Show("【9101】文件上传成功");            }        }        private void tsm3202_Click(object sender, EventArgs e)        {            if (string.IsNullOrEmpty(Global.inf.areaCode))            {                MessageBox.Show("请先签到!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);                return;            }            string outParam = "";            DataTable dt = (DataTable)dgvSettlSummary.DataSource;            int i = dgvSettlSummary.CurrentRow.Index;            dynamic joCheck = new JObject();            joCheck.file_qury_no = JObject.Parse(tbTmp.Text);            joCheck.clr_type = dt.Rows[i]["clr_type"].ToString();            joCheck.setl_optins = dt.Rows[i]["setl_optins"].ToString();            joCheck.stmt_begndate = dpST.Value.ToString("yyyy-MM-dd HH:mm:ss");            joCheck.stmt_enddate = dpED.Value.ToString("yyyy-MM-dd HH:mm:ss");            joCheck.medfee_sumamt = dt.Rows[i]["medfee_sumamt"].ToString();            joCheck.fund_pay_sumamt = dt.Rows[i]["fund_pay_sumamt"].ToString();            joCheck.cash_payamt = dt.Rows[i]["cash_payamt"].ToString();            joCheck.fixmedins_setl_cnt = dt.Rows[i]["fixmedins_setl_cnt"].ToString();            JObject joData = new JObject();            joData.Add("data", joCheck);            InvokeHelper invoker = new InvokeHelper();                       JObject jo3202Rtn= invoker.invokeCenterService(TradeEnum.FeeDetailCheck, joData);            if (JsonHelper.parseCenterRtnValue(jo3202Rtn, out outParam) != 0)            {                outParam = JsonHelper.setExceptionJson(-1, "【3202】医保明细对账失败", outParam).ToString();                MessageBox.Show(outParam);                return;            }            else            {                MessageBox.Show("【3202】医保明细对账成功");            }        }        private void tsmDownload_Click(object sender, EventArgs e)        {            string outParam = "";            JObject joTmp = new JObject();            joTmp.Add("file_qury_no", JObject.Parse(tbTmp.Text.Replace(@"\\", @"\")));            joTmp.Add("filename", txtName + ".zip");            joTmp.Add("fixmedins_code", Global.inf.hospitalNO);            JObject joFsDownloadIn = new JObject();            joFsDownloadIn.Add("fsDownloadIn", joTmp);            InvokeHelper invoker = new InvokeHelper();            jo9102Rtn = invoker.invokeCenterService(TradeEnum.FileDownload, joFsDownloadIn);            if (JsonHelper.parseCenterRtnValue(jo9102Rtn, out outParam) != 0)            {                outParam = JsonHelper.setExceptionJson(-1, "【9102】文件下载失败", outParam).ToString();                MessageBox.Show(outParam);                return;            }            else            {                MessageBox.Show("【9102】文件下载成功");            }        }        private void tsmUnCompress_Click(object sender, EventArgs e)        {            //解压缩            string zipFilePath = jo9102Rtn["filePath"].ToString();            string txtFileDir = System.Environment.CurrentDirectory + "\\Download";            //string txtFilePath = txtFileDir + "\\" + filename.Substring(0, filename.Length - 4);            string txtFilePath = txtFileDir;            if (File.Exists(txtFilePath))            {                File.Delete(txtFilePath);            }            ZipFile.ExtractToDirectory(zipFilePath, txtFileDir);        }        private void tsmImport_Click(object sender, EventArgs e)        {            GridViewSetter grd = new GridViewSetter();            grd.SetHeaderTextOfDgvCenterSetlRec(dgvCenterSettlRec);            string txtFileDir = tbTmp.Text;//E:\GHSF\SCYBDownLoad\result.txt            string[] lines = System.IO.File.ReadAllLines(txtFileDir);            Global.writeLog(lines.ToString());            DataTable dt = new DataTable();            dt.Columns.Add("sn", typeof(int));            dt.Columns.Add("psn_no", typeof(string));            dt.Columns.Add("mdtrt_id", typeof(string));            dt.Columns.Add("setl_id", typeof(string));            dt.Columns.Add("msgid", typeof(string));            dt.Columns.Add("stmt_rslt", typeof(string));            dt.Columns.Add("refd_setl_flag", typeof(string));            dt.Columns.Add("memo", typeof(string));            dt.Columns.Add("medfee_sumamt", typeof(string));            dt.Columns.Add("fund_pay_sumamt", typeof(string));            dt.Columns.Add("acct_pay", typeof(string));            //foreach (string line in lines)            for (int i = 0; i < lines.Length; i++)            {                string[] strs = (lines[i] + "\t").Split('\t');                DataRow dr = dt.NewRow();                //Global.inf.writeLog(lines[i].ToString());                //Global.inf.writeLog(strs.Length.ToString());                dr["sn"] = i;                dr["psn_no"] = strs[0];                dr["mdtrt_id"] = strs[1];                dr["setl_id"] = strs[2];                dr["msgid"] = strs[3];                dr["stmt_rslt"] = strs[4];                dr["refd_setl_flag"] = strs[5];                dr["memo"] = strs[6];                dr["medfee_sumamt"] = strs[7];                dr["fund_pay_sumamt"] = strs[8];                dr["acct_pay"] = strs[9];                //dr["Field2"] = strs[2];                dt.Rows.Add(dr);            }            dgvCenterSettlRec.DataSource = dt;        }        private int exportAndCompress(out string zipPath)        {            zipPath = "";            try            {                //导出TXT                string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffff");                string filePath = Global.currentDirectory + "\\Download";                HISDetailDataExport(filePath, fileName);                //压缩                string finalDirPath = filePath + "\\" + fileName;//同名文件夹                zipPath = finalDirPath + ".zip";                System.IO.Compression.ZipFile.CreateFromDirectory(finalDirPath, zipPath);                return 0;            }            catch (Exception ex)            {                zipPath = "exportAndCompress:" + ex.Message;                return -1;            }        }        /// <summary>        /// 上传ZIP文件转字节流再转换为有符号10进制数组后上传        /// </summary>        /// <param name="zipPath"></param>        /// <param name="file_qury_no"></param>        /// <returns></returns>        private int uploadFileToCenter(string zipPath, out string file_qury_no)        {            string outParam = "";            try            {                byte[] bArray = ReadFileToByte(zipPath);                string str = "[" + byteArrayToDecString(bArray) + "]";                JObject joTmp = new JObject();                joTmp.Add("in", JArray.Parse(str));                joTmp.Add("filename", txtName + ".zip");                joTmp.Add("fixmedins_code", Global.inf.hospitalNO);                JObject joFsUploadIn = new JObject();                joFsUploadIn.Add("fsUploadIn", joTmp);                InvokeHelper invoker = new InvokeHelper();                 JObject jo9101Rtn = invoker.invokeCenterService(TradeEnum.FileUpload, joFsUploadIn);                if (JsonHelper.parseCenterReturnJson(jo9101Rtn, out outParam) != 0)                {                    file_qury_no = outParam;                    return -1;                }                else                {                    file_qury_no = JsonHelper.getDestValue(jo9101Rtn, "output.file_qury_no");                    return 0;                }            }            catch (Exception ex)            {                file_qury_no = "uploadFileToCenter:" + ex.Message;                return -1;            }        }        /// <summary>        /// 查询明细        /// </summary>        /// <param name="outParam"></param>        /// <returns></returns>        private int checkDetail(out string outParam)        {            try            {                DataTable dt = (DataTable)dgvSettlSummary.DataSource;                int i = dgvSettlSummary.CurrentRow.Index;                dynamic joCheck = new JObject();                joCheck.clr_type = dt.Rows[i]["clr_type"].ToString();                joCheck.setl_optins = dt.Rows[i]["setl_optins"].ToString();                joCheck.stmt_begndate = dpST.Value.ToString("yyyy-MM-dd HH:mm:ss");                joCheck.stmt_enddate = dpED.Value.ToString("yyyy-MM-dd HH:mm:ss");                joCheck.medfee_sumamt = dt.Rows[i]["medfee_sumamt"].ToString();                joCheck.fund_pay_sumamt = dt.Rows[i]["fund_pay_sumamt"].ToString();                joCheck.cash_payamt = dt.Rows[i]["cash_payamt"].ToString();                joCheck.fixmedins_setl_cnt = dt.Rows[i]["fixmedins_setl_cnt"].ToString();                JObject joData = new JObject();                joData.Add("data", joCheck);                InvokeHelper invoker = new InvokeHelper();                JObject jo3202Rtn = invoker.invokeCenterService(TradeEnum.FeeDetailCheck, joData);                if (JsonHelper.parseCenterReturnJson(jo3202Rtn, out outParam) != 0)                {                    return -1;                }                else                {                    outParam = JsonHelper.getDestValue(jo3202Rtn, "jsxx_ds");                    return 0;                }            }            catch (Exception ex)            {                outParam = "checkDetail:" + ex.Message;                return -1;            }        }        private int checkDetail(string file_qury_no, out string outParam, out string fileName)        {            fileName = "";            try            {                DataTable dt = (DataTable)dgvSettlSummary.DataSource;                int i = dgvSettlSummary.CurrentRow.Index;                dynamic joCheck = new JObject();                joCheck.file_qury_no = file_qury_no.Replace(@"\\", @"\");                joCheck.clr_type = dt.Rows[i]["clr_type"].ToString();                joCheck.setl_optins = dt.Rows[i]["setl_optins"].ToString();                joCheck.stmt_begndate = dpST.Value.ToString("yyyy-MM-dd HH:mm:ss");                joCheck.stmt_enddate = dpED.Value.ToString("yyyy-MM-dd HH:mm:ss");                joCheck.medfee_sumamt = dt.Rows[i]["medfee_sumamt"].ToString();                joCheck.fund_pay_sumamt = dt.Rows[i]["fund_pay_sumamt"].ToString();                joCheck.cash_payamt = dt.Rows[i]["cash_payamt"].ToString();                joCheck.fixmedins_setl_cnt = dt.Rows[i]["fixmedins_setl_cnt"].ToString();                JObject joData = new JObject();                joData.Add("data", joCheck);                InvokeHelper invoker = new InvokeHelper();                 JObject jo3202Rtn = invoker.invokeCenterService(TradeEnum.FeeDetailCheck, joData);                if (JsonHelper.parseCenterReturnJson(jo3202Rtn, out outParam) != 0)                {                    return -1;                }                else                {                    outParam = JsonHelper.getDestValue(jo3202Rtn, "output.fileinfo.file_qury_no");                    fileName = JsonHelper.getDestValue(jo3202Rtn, "output.fileinfo.filename");                    return 0;                }            }            catch (Exception ex)            {                outParam = "checkDetail:" + ex.Message;                return -1;            }        }        private int downloadZIP(string file_qury_no, string fileName, out string outParam)        {            outParam = "";            try            {                JObject joTmp = new JObject();                joTmp = new JObject();                joTmp.Add("file_qury_no", file_qury_no.Replace(@"\\", @"\"));                joTmp.Add("filename", fileName);                joTmp.Add("fixmedins_code", Global.inf.hospitalNO);                JObject joFsDownloadIn = new JObject();                joFsDownloadIn.Add("fsDownloadIn", joTmp);                InvokeHelper invoker = new InvokeHelper();                JObject jo9102Rtn = invoker.DownloadCenterFile(JsonHelper.setCenterInpar("9102", joFsDownloadIn).ToString());                string error = "";                if (JsonHelper.parseIrisRtnValue(jo9102Rtn, out error) != 0)                {                    outParam = error;                    return -1;                }                else                {                    outParam = JsonHelper.getDestValue(jo9102Rtn, "filePath");                    return 0;                }            }            catch (Exception ex)            {                outParam = "downloadZIP:" + ex.Message;                return -1;            }        }        private int importToDgvCenterSetlRec(string outParam)        {            DataTable dt = JsonConvert.DeserializeObject<DataTable>(outParam, new ReadDataTableConverter());            dgvCenterSettlRec.DataSource = dt;            return 0;        }        private int importToDgvCenterSetlRec(string fileName, string zipFilePath, out string outParam)        {            outParam = "";            try            {                string dir = fileName.Substring(1, fileName.Length - 4);                //解压缩                string txtFileDir = System.Environment.CurrentDirectory + "\\Download\\" + dir;                string txtFilePath = zipFilePath.Substring(0, zipFilePath.Length - 4);                if (File.Exists(txtFilePath))                {                    File.Delete(txtFilePath);                }                if (!Directory.Exists(txtFileDir))                {                    Directory.CreateDirectory(txtFileDir);                }                ZipFile.ExtractToDirectory(zipFilePath, txtFileDir);                //导入文件                GridViewSetter grd = new GridViewSetter();                grd.SetHeaderTextOfDgvCenterSetlRec(dgvCenterSettlRec);                //txtFileDir = txtFileDir;//E:\GHSF\SCYBDownLoad\result.txt                string[] lines = System.IO.File.ReadAllLines(txtFileDir + "\\result.txt");                DataTable dt = new DataTable();                dt.Columns.Add("sn", typeof(int));                dt.Columns.Add("psn_no", typeof(string));                dt.Columns.Add("mdtrt_id", typeof(string));                dt.Columns.Add("setl_id", typeof(string));                dt.Columns.Add("msgid", typeof(string));                dt.Columns.Add("stmt_rslt", typeof(string));                dt.Columns.Add("refd_setl_flag", typeof(string));                dt.Columns.Add("memo", typeof(string));                dt.Columns.Add("medfee_sumamt", typeof(string));                dt.Columns.Add("fund_pay_sumamt", typeof(string));                dt.Columns.Add("acct_pay", typeof(string));                //foreach (string line in lines)                for (int i = 0; i < lines.Length; i++)                {                    string[] strs = (lines[i] + "\t").Split('\t');                    DataRow dr = dt.NewRow();                    //Global.inf.writeLog(lines[i].ToString());                    //Global.inf.writeLog(strs.Length.ToString());                    dr["sn"] = i + 1;                    dr["psn_no"] = strs[0];                    dr["mdtrt_id"] = strs[1];                    dr["setl_id"] = strs[2];                    dr["msgid"] = strs[3];                    dr["stmt_rslt"] = strs[4];                    dr["refd_setl_flag"] = strs[5];                    dr["memo"] = strs[6];                    dr["medfee_sumamt"] = strs[7];                    dr["fund_pay_sumamt"] = strs[8];                    dr["acct_pay"] = strs[9];                    //dr["Field2"] = strs[2];                    dt.Rows.Add(dr);                }                dgvCenterSettlRec.DataSource = dt;                return 0;            }            catch (Exception ex)            {                outParam = "importToDgvCenterSetlRec:" + ex.Message;                return -1;            }        }        private int CheckDetail_Single(out string outParam)        {            outParam = "";            //先签到            CenterBusiness cBus = new CenterBusiness();            //JObject jo9001Rtn = new JObject();            //cBus.signIn(out jo9001Rtn);            try            {                //导出并压缩                //if (exportAndCompress(out outParam) != 0)                //{                //    return -1;                //}                //string zipPath = outParam;                //Global.writeLog("exportAndCompress:" + zipPath);                ////上传给中心,                //if (uploadFileToCenter(zipPath, out outParam) != 0)                //{                //    return -1;                //}                //Global.writeLog("uploadFileToCenter:" + outParam);                //string file_query_no = outParam;                //string fileName = "";                //3202明细对账  输出查询号和文件名                if (checkDetail(out outParam) != 0)                {                    return -1;                }                //file_query_no = outParam;                //Global.writeLog("checkDetail:" + outParam + "///" + fileName);                ////下载  获取 查询号和文件名后 下载                //if (downloadZIP(file_query_no, fileName, out outParam) != 0)                //{                //    return -1;                //}                //zipPath = outParam;                importToDgvCenterSetlRec(outParam);                //Global.writeLog("downloadZIP:" + outParam);                ////导入DGV                //if (importToDgvCenterSetlRec(fileName, zipPath, out outParam) != 0)                //{                //    return -1;                //}                //Global.writeLog("importToDgvCenterSetlRec:" + outParam);                return 0;            }            catch (Exception ex)            {                outParam = "CheckDetail_Single:" + ex.Message;                return -1;            }        }        private void dgvRowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)        {            DataGridView dgv = (DataGridView)sender;            dgv.RowHeadersWidth = 60;            if (dgv.Rows.Count > 1)                e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);        }        private void dgvSettlSummary_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)        {            if (dgvSettlSummary.Rows.Count > 1)                e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);        }        private void dgvHisSettlRec_RowStateChanged(object sender, DataGridViewRowStateChangedEventArgs e)        {            if (dgvHisSettlRec.Rows.Count > 1)                e.Row.HeaderCell.Value = string.Format("{0}", e.Row.Index + 1);        }        private int compareDataGridView(string value, string colName, Sunny.UI.UIDataGridView dgv)        {            try            {                for (int i = 0; i < dgv.RowCount; i++)                {                    if (dgv.Rows[i].Cells[colName].Value.ToString() == value)                    {                        return 0;                    }                }                return -1;            }            catch (Exception ex)            {                MessageBox.Show("compareDataGridView" + ex.Message);                return -1;            }        }        private void tsmAICheck_Click(object sender, EventArgs e)        {            for (int i = 0; i < dgvHisSettlRec.RowCount; i++)            {                string value = dgvHisSettlRec.Rows[i].Cells["SettlementID"].Value.ToString();                string colName = "setl_id";                if (compareDataGridView(value, colName, dgvCenterSettlRec) != 0)                {                    dgvHisSettlRec.Rows[i].DefaultCellStyle.BackColor = Color.Red;                    rtbCheckDetailLog.AppendText("HIS结算ID:" + value + "在中心明细中未找到数据!" + "\r\n");                }            }            for (int i = 0; i < dgvCenterSettlRec.RowCount; i++)            {                string value = dgvCenterSettlRec.Rows[i].Cells["setl_id"].Value.ToString();                string colName = "SettlementID";                if (compareDataGridView(value, colName, dgvHisSettlRec) != 0)                {                    dgvCenterSettlRec.Rows[i].DefaultCellStyle.BackColor = Color.Red;                    rtbCheckDetailLog.AppendText("中心结算ID:" + value + "在HIS明细中未找到数据!" + "\r\n");                }            }        }        private void btnAddOneDay_Click(object sender, EventArgs e)        {            dpST.Value = dpST.Value.AddDays(1);            dpED.Value = dpED.Value.AddDays(1);        }        private void btnReduceOndDay_Click(object sender, EventArgs e)        {            dpST.Value = dpST.Value.AddDays(-1);            dpED.Value = dpED.Value.AddDays(-1);        }        private void Clearing1()        {            //组织入参,进行中心清算            int i = dgvSettlSummary.CurrentRow.Index;            DataTable dt = (DataTable)dgvSettlSummary.DataSource;            JObject joData = new JObject();            joData.Add("", dgvSettlSummary.CurrentRow.Cells[""].Value.ToString());            //存到医保平台        }        private void uiButton3_Click(object sender, EventArgs e)        {            string sqlStr = "SELECT * ";            sqlStr = sqlStr + " FROM  BS_MedInsuSettlement WHERE Hospital_Dr=" + Global.inf.hospitalDr;            sqlStr = sqlStr + " and OccurTime>'" + dpST_O.Text + "'";            sqlStr = sqlStr + " and OccurTime<'" + dpED_O.Text + "'";            sqlStr = sqlStr + " and Interface_dr =" + +Global.inf.interfaceDr;            sqlStr = sqlStr + " and (left(InsuranceAreaCode,2)<>'50')";            //if (cbxInsuType.Text != "")            //{            //    sqlStr = sqlStr + " and insutype ='" + cbxInsuType.SelectedValue + "'";            //}            if (cbxClrType_O.Text != "")            {                sqlStr = sqlStr + " and ClearingType ='" + cbxClrType_O.SelectedValue + "'";            }            //if (tbSettlOption.Text != "")            //{            //    sqlStr = sqlStr + " and ClearingOrgan ='" + tbSettlOption.Text + "'";            //}            if (cbxValid_O.SelectedIndex != 0)            {                if (cbxValid_O.SelectedIndex == 1)                { sqlStr = sqlStr + " and ValidFlag =1"; }                else                    sqlStr = sqlStr + " and ValidFlag =-1";            }            JObject joSqlstr = new JObject();            joSqlstr.Add("sqlStr", sqlStr);            JArray jaParam = new JArray();            jaParam.Add(joSqlstr);            JObject joSettlQuery = new JObject();            joSettlQuery.Add("params", jaParam);            joSettlQuery.Add("code", "09010059");            InvokeHelper invoker = new InvokeHelper();            JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询结算信息");            //DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));            DataTable dt = (DataTable)JsonConvert.DeserializeObject(joRtn["result"]["data"].ToString(), (typeof(DataTable)));            //DataTable dtResult = new DataTable();            ////克隆表结构            //dtResult = dt.Clone();            //foreach (DataColumn col in dtResult.Columns)            //{            //    if (col.ColumnName == "BillID")            //    {            //        //修改列类型            //        col.DataType = typeof(string);            //    }            //    if (col.ColumnName == "RecordID")            //    {            //        //修改列类型            //        col.DataType = typeof(string);            //    }            //}            //foreach (DataRow row in dt.Rows)            //{            //    DataRow newDtRow = dtResult.NewRow();            //    foreach (DataColumn column in dt.Columns)            //    {            //        if (column.ColumnName == "BillID")            //        {            //            MessageBox.Show("cs1:" + column.ColumnName + row[column.ColumnName].ToString());            //            newDtRow[column.ColumnName] = Convert.ToString(row[column.ColumnName]);            //        }            //        else            //        {            //            newDtRow[column.ColumnName] = row[column.ColumnName];            //        }            //    }            //    dtResult.Rows.Add(newDtRow);            //}            dgvOthCheck.DataSource = dt;        }        private void uiSymbolButton2_Click(object sender, EventArgs e)        {            dpST_O.Value = dpST_O.Value.AddDays(1);            dpED_O.Value = dpED_O.Value.AddDays(1);        }        private ArrayList getIndexArray(String inputStr, String findStr)        {            ArrayList list = new ArrayList();            int start = 0;            while (start < inputStr.Length)            {                int index = inputStr.IndexOf(findStr, start);                if (index >= 0)                {                    list.Add(index);                    start = index + findStr.Length;                }                else                {                    break;                }            }            return list;        }        private void uiButton2_Click(object sender, EventArgs e)        {            DataTable dt = (DataTable)dgvOthCheck.DataSource;            string error = "";            int failRows = 0;            for (int i = 0; i < dt.Rows.Count; i++)            {                //dgvOthCheck.Rows[i].Selected = true;                dgvOthCheck.CurrentCell = dgvOthCheck.Rows[i].Cells[0];                if (OthPlcCheck_Single(out error) != 0)                {                    string str = "【当前人员】:";                    //Graphics g = this.CreateGraphics();                    //Font font = new Font("宋体", 14, FontStyle.Bold);                    //SolidBrush brush = new SolidBrush(Color.Red);                    //g.DrawString(str, font, brush, 20, 50);                    string patInfo = str + dt.Rows[i]["PatientName"].ToString()                                   + ",结算编号:" + dt.Rows[i]["SettlementID"].ToString()                                   + ",清算类别:" + dt.Rows[i]["ClearingType"].ToString()                                   + ",就诊类别(1门诊2住院):" + dt.Rows[i]["admType"].ToString();                    rtbOthCheckResultRecord.AppendText(patInfo + ";对账失败:" + error + "\r\n");                    failRows++;                }                else                {                    //rtbOthCheckResultRecord.AppendText("当前人员:" + dt.Rows[i]["PatientName"].ToString() + ";对账成功!"  + "\r\n");                }            }            if (failRows == 0)            {                rtbOthCheckResultRecord.AppendText("当前所有人员对账成功!" + "\r\n");            }            else            {                string str = "【当前人员】";                ArrayList list = getIndexArray(rtbOthCheckResultRecord.Text, str);                for (int i = 0; i < list.Count; i++)                {                    int index = (int)list[i];                    rtbOthCheckResultRecord.Select(index, str.Length);                    rtbOthCheckResultRecord.SelectionColor = Color.Red;                    Font oldFont = rtbOthCheckResultRecord.SelectionFont;                    Font font = new Font(oldFont, oldFont.Style | FontStyle.Bold);                    rtbOthCheckResultRecord.SelectionFont = font;                }            }        }        private void tsmHandCheck_Click(object sender, EventArgs e)        {            JObject joData = JObject.Parse(rtbCheckDetailLog.Text);            InvokeHelper invoker = new InvokeHelper();             JObject joRtn = invoker.invokeCenterService(TradeEnum.FeeSummaryCheck, joData);        }        private void btnClose_Click(object sender, EventArgs e)        {            Close();        }        private void Btn_Query_Click(object sender, EventArgs e)        {            DataTable dtInteface = (DataTable)cbxInterface.DataSource;            int i = cbxInterface.SelectedIndex;            //乘以单据类型后,IRIS会返回整数,关键不知道SQL里咋转换为浮点数            //string sqlStr = "SELECT SUM(BillType*Sumamt) AS medfee_sumamt,count(*) AS fixmedins_setl_cnt,SUM(BillType*PersonCashPay) AS cash_payamt, ";            //sqlStr = sqlStr + " SUM(BillType*AccountPaySumamt) AS acct_pay,SUM(BillType*FundPaySumamt) AS fund_pay_sumamt ";            string sqlStr = "SELECT SUM(BillType*Sumamt) AS medfee_sumamt,count(*) AS fixmedins_setl_cnt,SUM(BillType*PersonCashPay) AS cash_payamt,  ";            sqlStr = sqlStr + " SUM(billType*AccountPaySumamt) AS acct_pay,SUM(BillType*FundPaySumamt) AS fund_pay_sumamt ";            //sqlStr = sqlStr + " Interface_dr,clearingWay AS clr_way,clearingType AS clr_type ";            // 增加先行自付金额、医疗救助基金、公务员医疗补助、个人账户共济支付、企业补充、职工大额            sqlStr += ",Sum(BillType*PreSelfPayAmount) as PreSelfPayAmount,sum(BillType*MedicalAssistPay) as MedicalAssistPay,sum(BillType*CivilserviceAllowancePay) as CivilserviceAllowancePay,sum(BillType*AccountMutualAidAmount) as AccountMutualAidAmount ,sum(BillType*LargeExpensesSupplementPay) as LargeExpensesSupplementPay,sum(BillType*EnterpriseSupplementPay) as EnterpriseSupplementPay ";            string conditionStr = " Group By";            if (cbgGroupSet.GetItemCheckState(0))            {                sqlStr = sqlStr + ",Interface_Dr";                conditionStr = conditionStr + " Interface_Dr,";            }            if (cbgGroupSet.GetItemCheckState(1))            {                sqlStr = sqlStr + ",InsuranceType as insutype";                conditionStr = conditionStr + " InsuranceType,";             }            if (cbgGroupSet.GetItemCheckState(2))            {                                       sqlStr = sqlStr + ",ClearingType as clr_type";                conditionStr = conditionStr + " ClearingType,";            }            if (cbgGroupSet.GetItemCheckState(3))            {                sqlStr = sqlStr + ",ClearingOrgan as setl_optins";                conditionStr = conditionStr + " ClearingOrgan,";            }            if (cbgGroupSet.GetItemCheckState(4))            {                sqlStr = sqlStr + ",BillType";                conditionStr = conditionStr + " BillType,";            }            sqlStr = sqlStr + " FROM BS_MedInsuSettlement WHERE Hospital_Dr=" + dtInteface.Rows[i]["HospitalDr"].ToString();            sqlStr = sqlStr + " and OccurTime>'" + dpST.Text + "'";            sqlStr = sqlStr + " and OccurTime<'" + dpED.Text + "'";            if (cbxInterface.Text != "")            {                sqlStr = sqlStr + " and Interface_Dr =" + dtInteface.Rows[i]["ID"].ToString();            }            if (cbxInsuType.Text != "")            {                sqlStr = sqlStr + " and InsuranceType ='" + cbxInsuType.SelectedValue + "'";            }            if (cbxClrType.Text != "")            {                sqlStr = sqlStr + " and ClearingType ='" + cbxClrType.SelectedValue + "'";            }            //if (Global.inf.interfaceDr == 1)            //{            //    sqlStr = sqlStr + " and (left(InsuranceAreaCode,4)='6201' or left(InsuranceAreaCode,4)='6299')";            //}            //conditionStr = conditionStr.Substring(0,conditionStr.Length -1 );            conditionStr = conditionStr.Remove(conditionStr.Length - 1, 1);            sqlStr = sqlStr + conditionStr;            JObject joSqlstr = new JObject();            //MessageBox.Show(sqlStr);            joSqlstr.Add("sqlStr", sqlStr);            JArray jaParam = new JArray();            jaParam.Add(joSqlstr);            JObject joSettlQuery = new JObject();            joSettlQuery.Add("params", jaParam);            joSettlQuery.Add("code", "09010061");            InvokeHelper invoker = new InvokeHelper();            JObject joRtn = invoker.invokeInsuService(joSettlQuery.ToString(), "查询汇总结算信息");            DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable));            dgvSettlSummary.DataSource = dt;            //初始化HIS结算明细View数据            dgvHisSettlRec.DataSource = null;        }        private void btnBatchCheck_Click(object sender, EventArgs e)        {        }        private void tsmCheck_Batch_Click(object sender, EventArgs e)        {        }    }}
 |