using Newtonsoft.Json.Linq; using PTMedicalInsurance.Business; using PTMedicalInsurance.Forms.BasicDatas.GridViewSetters; using PTMedicalInsurance.Helper; using PTMedicalInsurance.Variables; 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; namespace PTMedicalInsurance.Forms.BasicDatas { public partial class LimitPriceAndSelfpayPropInfo : Form { private string code; private string err; MIIrisServices mIS = new MIIrisServices(); private GridViewSetter grdSetter = new GridViewSetter(); public LimitPriceAndSelfpayPropInfo() { InitializeComponent(); } public LimitPriceAndSelfpayPropInfo(string _code) { InitializeComponent(); code = _code; InitForm(); } private void InitForm() { this.StartPosition = FormStartPosition.CenterScreen; grdSetter.setLimitPrice(dgvLimitPrice); grdSetter.setSelfPayProp(dgvSelfPayProp); } private int GetAuxInfo(string auxInfoType,out string errMsg) { string tableName="", eventName=""; if (auxInfoType == "LimitPrice") { tableName = "HB_MedInsuDirectoryLimitPrice"; eventName = "限价信息"; } if (auxInfoType == "SelfPayProp") { tableName = "HB_MedInsuDirectorySelfpayProportion"; eventName = "自付比例信息"; } JObject joSqlstr = new JObject(); joSqlstr.Add("sqlStr", CreateSql(auxInfoType)); JObject joRtn = mIS.DynamicQuery(joSqlstr, $"查询{eventName}"); if (JsonHelper.parseIrisRtnValue(joRtn, out errMsg) != 0) { return -1; } else { if (JsonHelper.getDestValue(joRtn, "result.total") == "0") { errMsg = $"未查询到{eventName}!"; return -1; } errMsg = joRtn.ToString(); return 0; } } private String CreateSql(string auxInfoType) { string sqlStr = ""; if (auxInfoType == "LimitPrice") { sqlStr += " SELECT A.ID, A.Hospital_Dr, A.Interface_Dr, A.Code, A.Name,B.Descripts LimitType, C.Descripts DisposeWay, A.BeginDate, "; sqlStr += " A.EndDate, A.UpLimitAmount, A.InsuranceAreaCode, A.PoolAreaNO,A.ValidFlag, A.RequiredID, A.UpdateTime"; sqlStr += " FROM SQLUser.HB_MedInsuDirectoryLimitPrice A LEFT JOIN HB_DictionaryDataDetail B ON A.LimitType = B.Code "; sqlStr += " AND (B.HBDictionary_Dr = (SELECT ID FROM SQLUser.HB_Dictionary WHERE InsuCode= 'hilistLmtpricType' AND Interface_Dr = 1))"; sqlStr += " LEFT JOIN HB_DictionaryDataDetail C ON A.DisposeWay = C.Code"; sqlStr += " AND (B.HBDictionary_Dr = (SELECT ID FROM SQLUser.HB_Dictionary WHERE InsuCode= 'overlmtDspoWay' AND Interface_Dr = 1))"; sqlStr += $" WHERE A.Interface_Dr = {Global.inf.interfaceDr} AND A.Code ='{code}'"; } if (auxInfoType == "SelfPayProp") { sqlStr += " SELECT A.ID, A.Hospital_Dr, A.Interface_Dr, A.Code, A.Name,B.Descripts PersonnelType, C.Descripts ProportionType, A.BeginDate, "; sqlStr += " A.EndDate, A.Proportion, A.InsuranceAreaCode, A.PoolAreaNO,A.ValidFlag, A.RequiredID, A.UpdateTime"; sqlStr += " FROM SQLUser.HB_MedInsuDirectorySelfpayProportion A LEFT JOIN HB_DictionaryDataDetail B ON A.PersonnelType = B.Code "; sqlStr += " AND (B.HBDictionary_Dr = (SELECT ID FROM SQLUser.HB_Dictionary WHERE InsuCode= 'selfpayPropPsnType' AND Interface_Dr = 1))"; sqlStr += " LEFT JOIN HB_DictionaryDataDetail C ON A.ProportionType = C.Code"; sqlStr += " AND (B.HBDictionary_Dr = (SELECT ID FROM SQLUser.HB_Dictionary WHERE InsuCode= 'selfpayPropType' AND Interface_Dr = 1))"; sqlStr += $" WHERE A.Interface_Dr = {Global.inf.interfaceDr} AND A.Code ='{code}'"; } return sqlStr; } private void QueryAuxInfo() { string finalError = ""; bool isFail = false; if (GetAuxInfo("LimitPrice", out err) != 0) { isFail = true; finalError = err; } else { JObject joRtn = JObject.Parse(err); DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable)); dgvLimitPrice.DataSource = dt; } if (GetAuxInfo("SelfPayProp", out err) != 0) { isFail = true; finalError += err; } else { JObject joRtn = JObject.Parse(err); DataTable dt = (DataTable)joRtn["result"]["data"].ToObject(typeof(DataTable)); dgvSelfPayProp.DataSource = dt; } if (isFail) { MessageBox.Show(finalError); } } private void btnOK_Click(object sender, EventArgs e) { Close(); } private void LimitPriceAndSelfpayPropInfo_Shown(object sender, EventArgs e) { QueryAuxInfo(); } } }