private void timer1_Tick(object sender, EventArgs e) { timer1.Stop(); string cardid = string.Empty; string cardType = SkyComm.getvalue("卡类型"); //if (cardType == "磁条卡") //{ cardid = m100ReadCard.ReadCard(); //} //else if (cardType == "IC卡") //{ // cardid = m100ICReadCard.ReadCard(); //} if (cardid == string.Empty) { this.Close(); } //MessageBox.Show("卡号: " + cardid); FrmMain.cardInfoStruct.CardNo = cardid; //FrmMain.cardInfoStruct.CardNo = "002000000024153734"; if (FrmMain.cardInfoStruct.CardNo != string.Empty && FrmMain.cardInfoStruct.CardNo.Length >= 6) { //MyMsg.MsgInfo(FrmMain.cardInfoStruct.CardNo); //FrmMain.cardInfoStruct.CardNo = "002000000024153734";// "001000776394154179"; backgroundWorker1.RunWorkerAsync(); //FrmMain.cardInfoStruct.CardNo = aa; timer1.Stop(); this.top1.timer1.Stop(); } else { if (incardcount > 0) { MyMsg.MsgInfo("卡片无效,请确认插入方向后重新插卡!"); incardcount--; timer1.Start(); } else { this.DialogResult = DialogResult.Cancel; } } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { if (Settings.Default.运行模式 == "RUN") { try { string cardid = string.Empty; string cardType = Settings.Default.卡类型; if (cardType == "磁条卡") { cardid = m100ReadCard.ReadCard(); } else if (cardType == "IC卡") { cardid = m100ICReadCard.ReadCard(); } if (cardid == string.Empty) { throw new Exception("异常卡片!"); } FrmMain.cardInfoStruct.CardNo = cardid; LogService.GlobalInfoMessage("查询卡信息"); SkyComm skyComm = new SkyComm(); DataSet dsinfo = skyComm.QueryCardInfo(FrmMain.cardInfoStruct.CardNo); FrmMain.parInfo = dsinfo; if (FrmMain.parInfo.Tables.Count > 0 && FrmMain.parInfo.Tables[0].Rows.Count > 0) { FrmMain.cardBlance = Convert.ToDecimal(FrmMain.parInfo.Tables[0].Rows[0]["卡余额"]); } else { throw new Exception("没有此卡信息!"); } } catch (Exception err) { throw new Exception(err.Message); } } else { if (Settings.Default.运行模式 == "TEST") { string cardid = string.Empty; string cardType = Settings.Default.卡类型; if (cardType == "磁条卡") { cardid = m100ReadCard.ReadCard(); } else if (cardType == "IC卡") { cardid = m100ICReadCard.ReadCard(); } } FrmMain.cardInfoStruct.CardNo = "123456789"; DataTable dtParInfo = new DataTable(); DataColumn dc = new DataColumn(); dc.ColumnName = "卡号"; dc.DataType = typeof(System.String); dtParInfo.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "姓名"; dc.DataType = typeof(System.String); dtParInfo.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "性别"; dc.DataType = typeof(System.String); dtParInfo.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "出生日期"; dc.DataType = typeof(System.DateTime); dtParInfo.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "身份证号"; dc.DataType = typeof(System.String); dtParInfo.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "卡余额"; dc.DataType = typeof(System.Decimal); dtParInfo.Columns.Add(dc); DataRow drNew = dtParInfo.NewRow(); drNew["卡号"] = FrmMain.cardInfoStruct.CardNo; drNew["姓名"] = "李某某"; drNew["性别"] = "男"; drNew["出生日期"] = Convert.ToDateTime("1983-12-03"); drNew["身份证号"] = "610123456789654120"; drNew["卡余额"] = "1000"; dtParInfo.Rows.Add(drNew); FrmMain.parInfo.Tables.Add(dtParInfo); FrmMain.cardBlance = 1000; Thread.Sleep(1000); } }