ChooseCard.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. namespace PTMedicalInsurance.Forms
  17. {
  18. public partial class ChooseCard : Form
  19. {
  20. public string sP_CertType, sP_CertNO, sP_CardSN, sP_IDType, sP_IDNO, sL_CertCodeType, sL_EcCertDecodeTradeNO;
  21. public string businessType, EcCertDecodeType;
  22. public string ID,PatName;
  23. public Boolean bOtherProvLocal = false;
  24. public int sL_CardType;
  25. //设置业务实例
  26. InvokeHelper invoker = new InvokeHelper();
  27. public ChooseCard()
  28. {
  29. InitializeComponent();
  30. this.StartPosition = FormStartPosition.CenterParent;
  31. }
  32. private void btOk_Click(object sender, EventArgs e)
  33. {
  34. if (rbgOtherProv.SelectedIndex == 0)
  35. bOtherProvLocal = false; //本地
  36. else
  37. bOtherProvLocal = true; //异地
  38. if ((tbPZLP.Text != "") && (tbZJHM.Text == ""))
  39. tbZJHM.Text = tbPZLP.Text;
  40. sP_CertType = "0" + (rbgMdtrtCertType.SelectedIndex +1).ToString(); //就诊凭证类型
  41. sP_CertNO = tbPZLP.Text; //凭证令牌
  42. sP_IDNO = tbZJHM.Text; //证件号码
  43. sP_CardSN = tbCardSN.Text; //卡识别码
  44. sP_IDType = cbDocumentType.Text.Trim().Substring(0, 6); //证件类型
  45. PatName = tbName.Text; //姓名
  46. //电子凭证
  47. if (rbgMdtrtCertType.SelectedIndex == 0)
  48. {
  49. sL_CertCodeType= "01" + cbYMYWLX.Text.Trim().Substring(0,3); //用码业务类型
  50. if (rbgEcCertDecodeType.SelectedIndex == 0)
  51. {
  52. sL_EcCertDecodeTradeNO = "ec.query";
  53. EcCertDecodeType = "0";
  54. }
  55. else if (rbgEcCertDecodeType.SelectedIndex == 1)
  56. {
  57. sL_EcCertDecodeTradeNO = "cn.nhsa.qrcode.get";
  58. EcCertDecodeType = "1";
  59. }
  60. else if (rbgEcCertDecodeType.SelectedIndex == 2)
  61. {
  62. sL_EcCertDecodeTradeNO = "cn.nhsa.auth.check";
  63. EcCertDecodeType = "2";
  64. }
  65. }
  66. //身份证
  67. if (rbgMdtrtCertType.SelectedIndex == 1)
  68. {
  69. if (tbZJHM.Text == "")
  70. {
  71. MessageBox.Show("使用身份证读卡时,证件号码不能为空!");
  72. return;
  73. }
  74. else
  75. {
  76. tbPZLP.Text = tbZJHM.Text;
  77. sP_CertNO = sP_IDNO;
  78. }
  79. }
  80. //社保卡
  81. if (rbgMdtrtCertType.SelectedIndex == 2)
  82. {
  83. if (cbCardType.Text == "")
  84. {
  85. MessageBox.Show("读社保卡时需要选择卡类型!");
  86. return;
  87. }
  88. sL_CardType = int.Parse(cbCardType.Text.Trim().Substring(0, 1)); //卡类型
  89. }
  90. DialogResult = DialogResult.OK;
  91. }
  92. private void ChooseCard_Load(object sender, EventArgs e)
  93. {
  94. rbgMdtrtCertType.SelectedIndex = 2; //身份证
  95. cbYMYWLX.SelectedIndex = 0; //用码业务类型
  96. rbgOtherProv.SelectedIndex = 0; //本地
  97. cbDocumentType.SelectedIndex = 0; //证件类型
  98. }
  99. private void rbgMdtrtCertType_ValueChanged(object sender, int index, string text)
  100. {
  101. if (rbgMdtrtCertType.SelectedIndex == 0)
  102. {
  103. rbgEcCertDecodeType.SelectedIndex = 0;
  104. uiLabel4.Text = "凭证令牌";
  105. rbgEcCertDecodeType.Enabled = true;
  106. cbYMYWLX.Enabled = true;
  107. uiLabel3.Visible = true;
  108. cbYMYWLX.Visible = true;
  109. }
  110. else if (rbgMdtrtCertType.SelectedIndex == 1)
  111. {
  112. uiLabel4.Text = "身份证号";
  113. rbgEcCertDecodeType.Enabled = false;
  114. cbYMYWLX.Enabled = false;
  115. uiLabel3.Visible = false;
  116. cbYMYWLX.Visible = false;
  117. }
  118. else if (rbgMdtrtCertType.SelectedIndex == 2)
  119. {
  120. uiLabel4.Text = "社保卡号";
  121. cbCardType.SelectedIndex = 0;
  122. rbgEcCertDecodeType.Enabled = false;
  123. cbYMYWLX.Enabled = false;
  124. uiLabel3.Visible = false;
  125. cbYMYWLX.Visible = false;
  126. }
  127. }
  128. private void btCancle_Click(object sender, EventArgs e)
  129. {
  130. DialogResult = DialogResult.Cancel;
  131. }
  132. private void uiButton1_Click(object sender, EventArgs e)
  133. {
  134. Global.pat.bChangePIN = true;
  135. CardReader_GS CardRead_GS = new CardReader_GS(Global.inf.cardURL, Global.inf.areaCode);
  136. #region【更改社保卡密码】
  137. //【1.调用初始化读卡函数】
  138. if (CardRead_GS.Init() != 0)
  139. {
  140. MessageBox.Show("修改密码初始化Init失败!");
  141. return;
  142. }
  143. //【2.调用社保卡获取卡信息】
  144. if (CardRead_GS.ReadCardBas(out string basInfo, out string regInfo) != 0)
  145. {
  146. return;
  147. }
  148. else
  149. {
  150. //【社保卡读卡成功返回】
  151. Global.pat.insuplc_admdvs = tools.getDestPosStrBySpliter(basInfo, 1); //参保地
  152. Global.pat.card.NO = tools.getDestPosStrBySpliter(basInfo, 2); //社会保障号码
  153. Global.pat.name = tools.getDestPosStrBySpliter(basInfo, 5); //姓名
  154. Global.pat.certNO = Global.pat.card.NO;
  155. if (Global.pat.insuplc_admdvs == "")
  156. {
  157. MessageBox.Show("ReadCardBas读卡获取:参保地为空!");
  158. return;
  159. }
  160. if (Global.pat.certNO == "")
  161. {
  162. MessageBox.Show("ReadCardBas读卡获取:身份证号为空!");
  163. return;
  164. }
  165. if (Global.pat.name == "")
  166. {
  167. MessageBox.Show("ReadCardBas读卡获取:姓名为空!");
  168. return;
  169. }
  170. //【2.调用更改社保卡密码函数】
  171. if (CardRead_GS.ChangePIN(out string OutMsg) != 0)
  172. {
  173. MessageBox.Show("社保卡密码更改异常ChangePIN:" + OutMsg);
  174. return;
  175. }
  176. else
  177. {
  178. MessageBox.Show("社保卡密码更改成功!");
  179. }
  180. }
  181. #endregion
  182. //DialogResult = DialogResult.OK;
  183. }
  184. private void SearchAdmdvs()
  185. {
  186. JObject joAdmdvsInfo = new JObject();
  187. SearchAdmdvs Adm = new SearchAdmdvs();
  188. try
  189. {
  190. Global.pat.card.SearchAdmKey = cbCBD.Text;
  191. Adm.StartPosition = FormStartPosition.CenterParent;
  192. if (Adm.ShowDialog() == DialogResult.OK)
  193. {
  194. cbCBD.Text = Global.pat.card.SearchAdmName;
  195. }
  196. }
  197. catch (Exception ex)
  198. {
  199. MessageBox.Show("异常:" + ex.Message);
  200. return;
  201. }
  202. }
  203. private void cbCBD_DoEnter(object sender, EventArgs e)
  204. {
  205. SearchAdmdvs();
  206. }
  207. }
  208. }