using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SqlTypes; 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.Forms; using PTMedicalInsurance.Variables; namespace PTMedicalInsurance.Forms { public partial class ChooseCard : Form { public string cardType; public string businessType; public string ID,PatName; public int sL_CardType; public string psnCertType; //设置业务实例 InvokeHelper invoker = new InvokeHelper(); public ChooseCard() { InitializeComponent(); this.StartPosition = FormStartPosition.CenterParent; initCombox(); } private DataTable GetDBLKComboxTable(string sqlStr) { InvokeHelper invoker = new InvokeHelper(); dynamic joInparm = new JObject(); dynamic joTmp = new JObject(); joTmp.sqlStr = sqlStr; JArray jaParams = new JArray(); jaParams.Add(joTmp); joInparm.Add("params", JArray.FromObject(jaParams)); joInparm.code = "09010014"; string inParam = joInparm.ToString(); JObject joRtn = invoker.invokeInsuService(inParam, "获取下拉框消息"); //dynamic jsonRtn = JsonConvert.DeserializeObject(strRtn); DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable)); //dt.Columns[0].ColumnName = "编码"; //dt.Columns[1].ColumnName = "名称"; //dt.Columns[2].ColumnName = "拼音查找码"; return dt; } private void SetDBLKCombox(ref PTControl.DBLookupCombox dblcbx, string sqlStr) { dblcbx.sDisplayField = "Code,Name,SearchCode"; dblcbx.sDisplayMember = "名称"; dblcbx.sKeyWords = "Code,SearchCode"; DataTable dt = GetDBLKComboxTable(sqlStr); dblcbx.DataSource = dt; if (dt?.Rows.Count > 0) { // default to select first one; } dblcbx.RowFilterVisible = true; dblcbx.TextBox.Width = 400; dblcbx.DataGridView.Width = 400; dblcbx.DataGridView.Columns[0].Name = "编码"; dblcbx.DataGridView.Columns[1].Name = "名称"; dblcbx.DataGridView.Columns[2].Name = "查找码"; dblcbx.DataGridView.Columns[0].Width = 100; dblcbx.DataGridView.Columns[1].Width = 200; } private void initCombox() { string sqlCondition = " and A.Interface_Dr = '" + Global.inf.InsuCurrencyCataLogue.ToString() + "'"; string sqlStr = ""; sqlStr = "SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr WHERE A.InsuCode = 'psn_cert_type'" + sqlCondition; SetDBLKCombox(ref dblkcbxPsnCertType, sqlStr); } private void btOk_Click(object sender, EventArgs e) { cardType = "0" + (rbgCardType.SelectedIndex +1).ToString(); businessType = "01"+cbBusinessType.Text.Substring(0,3); // 身份证 if (rbgCardType.SelectedIndex == 1) { ID = tbID.Text; PatName = tbName.Text; } //社保卡 if (rbgCardType.SelectedIndex == 2) { if (cbCardType.Text == "") { MessageBox.Show("读社保卡时需要选择卡类型!"); return; } sL_CardType = int.Parse(cbCardType.Text.Trim().Substring(0, 1)); //卡类型 } DialogResult = DialogResult.OK; } private void ChooseCard_Load(object sender, EventArgs e) { rbgCardType.SelectedIndex = 1; //身份证 cbBusinessType.SelectedIndex = 0; //社保卡 } private void rbgCardType_ValueChanged(object sender, int index, string text) { if (rbgCardType.SelectedIndex == 0) { // 电子凭证 cbBusinessType.Enabled = true; lblNo.Text = "电子凭证号"; tbID.Text = ""; tbID.Focus(); } else { lblNo.Text = "身份证号"; cbBusinessType.Enabled = false; tbID.Text = Global.pat.presetIDNO; } if (rbgCardType.SelectedIndex == 2) { cbCardType.SelectedIndex = 0; cbCardLevel.SelectedIndex = 2; cbCardType.Enabled = true; tbPassword.Enabled = true; //tbPassword.Text = ""; } else { cbCardType.Enabled = false; tbPassword.Enabled = false; } if (rbgCardType.SelectedIndex == 1) { cbCBD.Text = "东莞市"; Global.pat.card.SearchAdmCode = "441900"; } else { cbCBD.Text = ""; Global.pat.card.SearchAdmCode = ""; } if (rbgCardType.SelectedIndex == 3) { lblNo.Text = "社保卡号"; } } private void btCancle_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; } private void SearchAdmdvs() { JObject joAdmdvsInfo = new JObject(); SearchAdmdvs Adm = new SearchAdmdvs(); try { Global.pat.card.SearchAdmKey = cbCBD.Text; Adm.StartPosition = FormStartPosition.CenterParent; if (Adm.ShowDialog() == DialogResult.OK) { cbCBD.Text = Global.pat.card.SearchAdmName; if (!string.IsNullOrEmpty(Global.pat.card.SearchAdmCode)) { //自动选择异地 if (Utils.isOtherCity(Global.pat.card.SearchAdmCode)) { //rbgOtherProv.SelectedIndex = 1; } } } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message); return; } } private void dblkcbxPsnCertType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e) { DataGridViewRow row = e.Value as DataGridViewRow; DataRowView dataRow = row.DataBoundItem as DataRowView; psnCertType = dataRow["Code"].ToString().Trim(); //insuTypeName = dataRow["Name"].ToString().Trim(); } private void cbCBD_DoEnter(object sender, EventArgs e) { //初始化 Global.pat.card.SearchAdmCode = ""; SearchAdmdvs(); } } }