/// <summary> /// 更新样桶已使用状态 /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool UpdateSampleBarrel(String code) { CmcsSampleBarrel entity = Dbers.GetInstance().SelfDber.Entity <CmcsSampleBarrel>(" where BarrelCode='" + code + "' "); if (entity != null) { entity.IsUse = 1; return(Dbers.GetInstance().SelfDber.Update <CmcsSampleBarrel>(entity) > 0); } else { return(false); } }
/// <summary> /// 键入Enter检测有效性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtInputSampleCode_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.CurrentFlowFlag != eFlowFlag.等待扫码) { return; } string barrelCode = txtInputSampleCode.Text.Trim().ToUpper(); if (String.IsNullOrWhiteSpace(barrelCode)) { return; } // 根据采样桶编码查找该采样单下所有采样桶记录 if (this.brotherRCSampleBarrels.Count == 0) { this.brotherRCSampleBarrels = czyHandlerDAO.GetRCSampleBarrels(barrelCode, out resMessage); if (this.brotherRCSampleBarrels.Count == 0) { ShowMessage(resMessage, eOutputType.Error); txtInputSampleCode.ResetText(); return; } ShowMessage(resMessage, eOutputType.Normal); CreateButtonX(this.brotherRCSampleBarrels.Count); ShowButton(this.brotherRCSampleBarrels.Count, "Sum"); } // 采样桶编码属于同一采样单下则验证通过,直到全部验证完毕 this.rCSampleBarrel = this.brotherRCSampleBarrels.Where(a => a.SampSecondCode == barrelCode).FirstOrDefault(); if (this.rCSampleBarrel != null) { if (!this.IsScanedRCSampleBarrelId.Contains(this.rCSampleBarrel.Id)) { this.IsScanedRCSampleBarrelId.Add(this.rCSampleBarrel.Id); //ShowButton(this.IsScanedRCSampleBarrelId.Count, "Already"); ShowButton(this.IsScanedRCSampleBarrelId.Count, "Already", Convert.ToInt32(this.rCSampleBarrel.SampSecondCode.Substring(14, 2))); if (this.IsScanedRCSampleBarrelId.Count < this.brotherRCSampleBarrels.Count) { ShowMessage("样桶编码:" + barrelCode + ",还剩" + (this.brotherRCSampleBarrels.Count - this.IsScanedRCSampleBarrelId.Count) + "桶未交样,请扫下个样桶", eOutputType.Normal); } else { foreach (CmcsRCSampleBarrel item in this.brotherRCSampleBarrels) { CmcsSampleBarrel entity = commonDAO.SelfDber.Entity <CmcsSampleBarrel>(" where BarrelCode='" + item.BarrelCode + "' "); if (entity != null) { entity.IsUse = 0; Dbers.GetInstance().SelfDber.Update(entity); } } czyHandlerDAO.SaveHandSamplingSend(this.brotherRCSampleBarrels[0].SamplingId, SelfVars.LoginUser.UserName, DateTime.Now); ShowMessage("样桶编码:" + barrelCode + ",该批次样桶已全部交样成功", eOutputType.Normal); } this.CurrentFlowFlag = eFlowFlag.等待校验; } else { txtInputSampleCode.ResetText(); ShowMessage("样桶编码:" + barrelCode + " 已校验,请扫下个样桶", eOutputType.Error); } } else { txtInputSampleCode.ResetText(); ShowMessage("样桶编码:" + barrelCode + " 交样失败,请扫下个样桶", eOutputType.Error); } } }
private void txtInputSampleCode_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == System.Windows.Forms.Keys.Return) { if (this.CurrentFlowFlag != eFlowFlag.等待扫码) { return; } string barrelCode = this.txtInputSampleCode.Text.Trim(); if (string.IsNullOrWhiteSpace(barrelCode)) { return; } if (this.brotherRCSampleBarrels.Count == 0) { this.brotherRCSampleBarrels = this.czyHandlerDAO.GetRCSampleBarrels(barrelCode, out this.resMessage); if (this.brotherRCSampleBarrels.Count == 0) { this.ShowMessage(this.resMessage, FrmMakeTake.eOutputType.Error); this.txtInputSampleCode.ResetText(); return; } this.ShowMessage(this.resMessage, FrmMakeTake.eOutputType.Normal); this.CreateButtonX(this.brotherRCSampleBarrels.Count); this.ShowButton(this.brotherRCSampleBarrels.Count, "Sum", 0); } this.rCSampleBarrel = (from a in this.brotherRCSampleBarrels where a.SampSecondCode == barrelCode select a).FirstOrDefault <CmcsRCSampleBarrel>(); if (this.rCSampleBarrel != null) { if (!this.IsScanedRCSampleBarrelId.Contains(this.rCSampleBarrel.Id)) { this.IsScanedRCSampleBarrelId.Add(this.rCSampleBarrel.Id); this.ShowButton(this.IsScanedRCSampleBarrelId.Count, "Already", System.Convert.ToInt32(this.rCSampleBarrel.SampSecondCode.Substring(14, 2))); if (this.IsScanedRCSampleBarrelId.Count < this.brotherRCSampleBarrels.Count) { this.ShowMessage(string.Concat(new object[] { "样桶编码:", barrelCode, ",还剩", this.brotherRCSampleBarrels.Count - this.IsScanedRCSampleBarrelId.Count, "桶未校验,请扫下个样桶" }), FrmMakeTake.eOutputType.Normal); } else { foreach (CmcsRCSampleBarrel current in this.brotherRCSampleBarrels) { CmcsSampleBarrel cmcsSampleBarrel = Dbers.GetInstance().SelfDber.Entity <CmcsSampleBarrel>(" where BarrelCode='" + current.BarrelCode + "' ", null); if (cmcsSampleBarrel != null) { cmcsSampleBarrel.IsUse = 0; Dbers.GetInstance().SelfDber.Update <CmcsSampleBarrel>(cmcsSampleBarrel); } } this.czyHandlerDAO.SaveHandSamplingReceive(this.brotherRCSampleBarrels[0].SamplingId, SelfVars.LoginUser.UserName, DateTime.Now); this.ShowMessage("样桶编码:" + barrelCode + ",该批次样桶已全部校验成功", FrmMakeTake.eOutputType.Normal); } this.CurrentFlowFlag = eFlowFlag.等待校验; return; } this.txtInputSampleCode.ResetText(); this.ShowMessage("样桶编码:" + barrelCode + " 已校验,请扫下个样桶", FrmMakeTake.eOutputType.Error); return; } else { this.txtInputSampleCode.ResetText(); this.ShowMessage("样桶编码:" + barrelCode + " 校验失败,请扫下个样桶", FrmMakeTake.eOutputType.Error); } } }