ChooseCard.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Data.SqlTypes;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using PTMedicalInsurance.Common;
  12. using PTMedicalInsurance.Helper;
  13. using Newtonsoft.Json.Linq;
  14. using PTMedicalInsurance.Forms;
  15. using PTMedicalInsurance.Variables;
  16. using PTMedicalInsurance.CardReaders;
  17. namespace PTMedicalInsurance.Forms
  18. {
  19. public partial class ChooseCard : Form
  20. {
  21. public string cardType;
  22. public string businessType;
  23. public string ID,PatName;
  24. public int sL_CardType;
  25. public string psnCertType;
  26. public bool bYDSBK;
  27. //设置业务实例
  28. InvokeHelper invoker = new InvokeHelper();
  29. public ChooseCard()
  30. {
  31. InitializeComponent();
  32. this.StartPosition = FormStartPosition.CenterParent;
  33. initCombox();
  34. }
  35. private DataTable GetDBLKComboxTable(string sqlStr)
  36. {
  37. InvokeHelper invoker = new InvokeHelper();
  38. dynamic joInparm = new JObject();
  39. dynamic joTmp = new JObject();
  40. joTmp.sqlStr = sqlStr;
  41. JArray jaParams = new JArray();
  42. jaParams.Add(joTmp);
  43. joInparm.Add("params", JArray.FromObject(jaParams));
  44. joInparm.code = "09010014";
  45. string inParam = joInparm.ToString();
  46. JObject joRtn = invoker.invokeInsuService(inParam, "获取下拉框消息");
  47. //dynamic jsonRtn = JsonConvert.DeserializeObject(strRtn);
  48. DataTable dt = (DataTable)joRtn["result"].ToObject(typeof(DataTable));
  49. //dt.Columns[0].ColumnName = "编码";
  50. //dt.Columns[1].ColumnName = "名称";
  51. //dt.Columns[2].ColumnName = "拼音查找码";
  52. return dt;
  53. }
  54. private void SetDBLKCombox(ref PTControl.DBLookupCombox dblcbx, string sqlStr)
  55. {
  56. dblcbx.sDisplayField = "Code,Name,SearchCode";
  57. dblcbx.sDisplayMember = "名称";
  58. dblcbx.sKeyWords = "Code,SearchCode";
  59. DataTable dt = GetDBLKComboxTable(sqlStr);
  60. dblcbx.DataSource = dt;
  61. if (dt?.Rows.Count > 0)
  62. {
  63. // default to select first one;
  64. }
  65. dblcbx.RowFilterVisible = true;
  66. dblcbx.TextBox.Width = 400;
  67. dblcbx.DataGridView.Width = 400;
  68. dblcbx.DataGridView.Columns[0].Name = "编码";
  69. dblcbx.DataGridView.Columns[1].Name = "名称";
  70. dblcbx.DataGridView.Columns[2].Name = "查找码";
  71. dblcbx.DataGridView.Columns[0].Width = 100;
  72. dblcbx.DataGridView.Columns[1].Width = 200;
  73. }
  74. private void initCombox()
  75. {
  76. string sqlCondition = " and A.Interface_Dr = '" + Global.inf.InsuCurrencyCataLogue.ToString() + "'";
  77. string sqlStr = "";
  78. sqlStr = " SELECT B.Code,B.Descripts AS Name FROM HB_Dictionary A JOIN HB_DictionaryDataDetail B ON A.ID = B.HBDictionary_Dr "
  79. + " WHERE A.InsuCode = 'psn_cert_type'" + sqlCondition;
  80. SetDBLKCombox(ref dblkcbxPsnCertType, sqlStr);
  81. }
  82. private void btOk_Click(object sender, EventArgs e)
  83. {
  84. cardType = "0" + (rbgCardType.SelectedIndex +1).ToString();
  85. businessType = "01"+cbBusinessType.Text.Substring(0,3);
  86. bYDSBK = chk_WSSBK.Checked;
  87. // 身份证
  88. if (rbgCardType.SelectedIndex == 1)
  89. {
  90. ID = tbID.Text;
  91. PatName = tbName.Text;
  92. }
  93. //社保卡
  94. if (rbgCardType.SelectedIndex == 2)
  95. {
  96. if (cbCardType.Text == "")
  97. {
  98. MessageBox.Show("读社保卡时需要选择卡类型!");
  99. return;
  100. }
  101. sL_CardType = int.Parse(cbCardType.Text.Trim().Substring(0, 1)); //卡类型
  102. }
  103. //非中国大陆公民身份证人员
  104. if (rbgCardType.SelectedIndex == 3)
  105. {
  106. if (tbID.Text == "")
  107. {
  108. MessageBox.Show("非大陆居民,外籍号码必填!例:香港的外籍号码:HKG000000888");
  109. return;
  110. }
  111. }
  112. DialogResult = DialogResult.OK;
  113. }
  114. private void ChooseCard_Load(object sender, EventArgs e)
  115. {
  116. rbgCardType.SelectedIndex = 2; //身份证
  117. cbBusinessType.SelectedIndex = 0; //社保卡
  118. }
  119. private void rbgCardType_ValueChanged(object sender, int index, string text)
  120. {
  121. if (rbgCardType.SelectedIndex == 0)
  122. {
  123. // 电子凭证
  124. cbBusinessType.Enabled = true;
  125. lblNo.Text = "电子凭证号";
  126. tbID.Text = "";
  127. tbID.Focus();
  128. }
  129. else
  130. {
  131. lblNo.Text = "身份证号";
  132. cbBusinessType.Enabled = false;
  133. tbID.Text = Global.pat.presetIDNO;
  134. }
  135. if (rbgCardType.SelectedIndex == 2)
  136. {
  137. cbCardType.SelectedIndex = 0;
  138. cbCardLevel.SelectedIndex = 2;
  139. cbCardType.Enabled = true;
  140. tbPassword.Enabled = true;
  141. //tbPassword.Text = "";
  142. }
  143. else
  144. {
  145. cbCardType.Enabled = false;
  146. tbPassword.Enabled = false;
  147. }
  148. if (rbgCardType.SelectedIndex == 1)
  149. {
  150. cbCBD.Text = "深圳市";
  151. Global.pat.card.SearchAdmCode = "440300";
  152. }
  153. else
  154. {
  155. cbCBD.Text = "";
  156. Global.pat.card.SearchAdmCode = "";
  157. }
  158. if (rbgCardType.SelectedIndex == 3)
  159. {
  160. lblNo.Text = "外籍号码";
  161. }
  162. }
  163. private void btCancle_Click(object sender, EventArgs e)
  164. {
  165. DialogResult = DialogResult.Cancel;
  166. }
  167. /// <summary>
  168. /// 修改密码
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void uiButton1_Click(object sender, EventArgs e)
  173. {
  174. string errorMsg="";
  175. JObject joData = new JObject();
  176. joData.Add("", "");
  177. JObject joInput = new JObject();
  178. joInput.Add("data", joData);
  179. InvokeHelper invoker = new InvokeHelper();
  180. JObject joRtn =invoker.invokeCenterService(TradeEnum.ModifyPassword, joInput);
  181. if (JsonHelper.parseCenterRtnValue(joRtn, out errorMsg) != 0)
  182. {
  183. MessageBox.Show("修改卡密码失败:" + errorMsg);
  184. }
  185. else
  186. {
  187. MessageBox.Show("修改卡密码成功!");
  188. }
  189. }
  190. private void SearchAdmdvs()
  191. {
  192. JObject joAdmdvsInfo = new JObject();
  193. SearchAdmdvs Adm = new SearchAdmdvs();
  194. try
  195. {
  196. Global.pat.card.SearchAdmKey = cbCBD.Text;
  197. Adm.StartPosition = FormStartPosition.CenterParent;
  198. if (Adm.ShowDialog() == DialogResult.OK)
  199. {
  200. cbCBD.Text = Global.pat.card.SearchAdmName;
  201. if (!string.IsNullOrEmpty(Global.pat.card.SearchAdmCode))
  202. {
  203. //自动选择异地
  204. if (Utils.isOtherCity(Global.pat.card.SearchAdmCode))
  205. {
  206. //rbgOtherProv.SelectedIndex = 1;
  207. }
  208. }
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. MessageBox.Show("异常:" + ex.Message);
  214. return;
  215. }
  216. }
  217. private void dblkcbxPsnCertType_AfterSelector(object sender, PTControl.AfterSelectorEventArgs e)
  218. {
  219. DataGridViewRow row = e.Value as DataGridViewRow;
  220. DataRowView dataRow = row.DataBoundItem as DataRowView;
  221. psnCertType = dataRow["Code"].ToString().Trim();
  222. //insuTypeName = dataRow["Name"].ToString().Trim();
  223. }
  224. private void btInit_Click(object sender, EventArgs e)
  225. {
  226. CardReader reader = CardReader.Instance;
  227. reader.Initialize(Global.inf.cardURL, Global.inf.areaCode);
  228. if (reader.Init() != 0)
  229. {
  230. string outParam = "读社保卡,初始化失败!";
  231. MessageBox.Show(outParam);
  232. }
  233. else
  234. {
  235. MessageBox.Show("初始化成功!");
  236. };
  237. }
  238. private void cbCBD_DoEnter(object sender, EventArgs e)
  239. {
  240. //初始化
  241. Global.pat.card.SearchAdmCode = "";
  242. SearchAdmdvs();
  243. }
  244. }
  245. }