public void HandleCardMessage(Device.CardReader device, string cardId) { QC_IC_Info icCard = QC_IC_Info.FindByCardId(cardId); if (icCard == null) { MessageBox.Show("此卡未注册"); return; } if (!icCard.CardType.StartsWith("CUT_")) { MessageBox.Show("磁扣类型不对"); return; } if (icCard.SampleId <= 0) { MessageBox.Show("此卡没有业务信息"); return; } QC_Sample_Lab_Jy tempLab = QC_Sample_Lab_Jy.GetById(icCard.SampleId); if (tempLab == null) { MessageBox.Show("没有找到单据"); return; } tempLab.JyCode = DbContext.GetSeq("JY" + DateTime.Now.Date.ToString("yyyyMMdd"), 2); tempLab.Billtype = "开始检验"; tempLab.LabState = "开始检验"; tempLab.JyUser = LocalInfo.Current.user.ID; tempLab.JyTime = DateTime.Now; icCard.SampleId = 0; IDbConnection conn = DbContext.GetDefaultConnection(); conn.Open(); IDbTransaction trans = conn.BeginTransaction(); icCard.Save(trans); tempLab.Save(trans); trans.Commit(); conn.Close(); this.curLab = QC_Sample_Lab_Jy.GetById(tempLab.Sample_Lab_ID); lableiji.Add(curLab); DbContext.ExeSql("insert into QC_LabLog(zycode,jycode,jytime) values('" + this.curLab.StoreCode + "','" + this.curLab.JyCode + "',getDate())"); labTable1.LoadDataByWhere("labstate='送检' and checkgroupname like '化验样%' and maketime>=@maketime", DateTime.Today.AddDays(-1)); // labTable2.LoadDataByWhere("labstate='送检' and checkgroupname like '角质层%' and maketime>=@maketime", DateTime.Today.AddDays(-1)); label2.Text = labTable1.Count.ToString(); // label4.Text = labTable2.Count.ToString(); SetGridViewFocuse(); this.printDocument1.Print(); //自动打印 //this.printPreviewDialog1.ShowDialog(); }
/// <summary> /// 注册磁扣信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnInsert_Click(object sender, EventArgs e) { string cardId = txtCardId.Text.Trim(); QC_CardUseType useType = cmbCardType.SelectedItem as QC_CardUseType; if (useType == null) { MessageBox.Show("使用类型不能为空"); return; } string cardType = useType.CUTCode; if (string.IsNullOrEmpty(cardId)) { MessageBox.Show("卡号不能为空"); return; } if (string.IsNullOrEmpty(cardType)) { MessageBox.Show("使用类型不能为空"); return; } QC_IC_Info card = QC_IC_Info.FindByCardId(txtCardId.Text.Trim()); if (card != null) { MessageBox.Show(string.Format("卡号{0}已经注册,不能重复注册。", cardId)); return; } QC_IC_Info icCard = new QC_IC_Info(); icCard.CardID = cardId; icCard.CardType = cardType; icCard.RegUser = FrmMain.localinfo.user.Name; icCard.RegTime = DateTime.Now; icCard.Save(); icInfoDatas.Insert(0, icCard); txtCardId.Text = ""; //if (this.cmbCardType.Properties.Items.Count > 0) //{ // cmbCardType.SelectedIndex = 0; //} // MessageBox.Show("注册完成"); }
/// <summary> /// 解除单据绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsmBtn_UnbindBill_Click(object sender, EventArgs e) { QC_IC_Info bill = getSelectedBill(); if (bill == null) { MessageBox.Show("没有选定数据"); return; } if (bill.SampleId < 1) { MessageBox.Show("没有单据需要解除绑定"); return; } if (MessageBox.Show("您确实要解除绑定吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { bill.SampleId = 0; bill.Save(); MessageBox.Show("解除绑定完成"); } }
/// <summary> /// 刷卡 /// </summary> public void HandleCardMessage(Device.CardReader device, string cardId) { QC_IC_Info icCard = QC_IC_Info.FindByCardId(cardId); if (icCard == null) { MessageBox.Show("此卡未注册"); return; } if (icCard.CardType.StartsWith("CUT_")) { if (icCard.SampleId > 0) { MessageBox.Show("此卡已绑定信息"); return; } if (curSelLab == null) { MessageBox.Show("请先查询样品单号"); return; } if (curSelLab.CheckGroupType != "后续检验") { MessageBox.Show("此样品单号不需要绑定磁卡"); return; } if (curSelLab.LabState != "制样") { MessageBox.Show("此样品已绑定磁扣"); return; } string ckgCode = icCard.CardType.Substring(4); if (curSelLab.CheckGroupName.Contains("角质层")) { if (ckgCode != "04" && ckgCode != "05") { MessageBox.Show("磁扣类型不对"); return; } } else { if (curSelLab.CheckGroupCode != ckgCode && !((curSelLab.CheckGroupCode == "14" || curSelLab.CheckGroupCode == "13") && (ckgCode == "04" || ckgCode == "05" || ckgCode == "14" || ckgCode == "13"))) { MessageBox.Show("磁扣类型不对"); return; } } QC_Sample_Lab tempLab = curSelLab; icCard.SampleId = tempLab.Sample_Lab_ID; tempLab.CardId = icCard.CardID; tempLab.MakeUser = LocalInfo.Current.user.ID; tempLab.MakeTime = DateTime.Now; tempLab.Billtype = "已扫样品扣"; tempLab.LabState = "送检"; tempLab.RefreshState(); IDbConnection conn = DbContext.GetDefaultConnection(); conn.Open(); IDbTransaction trans = conn.BeginTransaction(); tempLab.Save(trans); icCard.Save(trans); trans.Commit(); conn.Close(); //DbContext.ExeSql("update mix set mix.SampleState=4 from QC_SAMPLE_MIX mix where mix.SampleState=3 and not exists (select * from QC_SAMPLE_LAB t1 inner join QC_MIXCHECKGROUP t2 on t2.SAMPLE_LAB_ID= t1.SAMPLE_LAB_ID where t2.SAMPLE_MIX_ID=mix.SAMPLE_MIX_ID and t1.CheckGroupName!='水分样' and IsNull(t1.BILLTYPE,'')='未绑定样品扣')"); lblLabMakeTime.Text = DateTime.Now.ToString("HH:mm:ss") + "完成刷卡"; DlgZyInfo dlg = new DlgZyInfo(curSelLab.CheckGroupName, curSelLab.ShortStoreCode); dlg.ShowDialog(); } else { MessageBox.Show("磁卡类型不对"); return; } }