S_GaugeStandingBook GetMessage() { if (txtCode.Tag == null) { throw new Exception("请选择【物品】"); } if (GeneralFunction.IsNullOrEmpty(txtGaugeCoding.Text)) { throw new Exception("请填写【量检具编号】"); } if (GeneralFunction.IsNullOrEmpty(txtManufacturer.Text)) { throw new Exception("请填写【制造商】"); } if (dtpInputDate.Value.Date > ServerTime.Time.Date) { throw new Exception("【入库日期】不能大于当前时间"); } if (dtpMaterialDate.Value.Date > ServerTime.Time.Date) { throw new Exception("【领料日期】不能大于当前时间"); } if (GeneralFunction.IsNullOrEmpty(cmbGaugeType.Text)) { throw new Exception("请选择【量检具类别】"); } if (cmbGaugeType.Text != "C类" && GeneralFunction.IsNullOrEmpty(cmbCheckType.Text)) { throw new Exception("请选择【校准类别】"); } S_GaugeStandingBook book = new S_GaugeStandingBook(); book.F_Id = txtName.Tag == null?Guid.NewGuid().ToString() : txtName.Tag.ToString(); book.DutyUser = txtDutyUser.Tag.ToString(); book.GaugeCoding = txtGaugeCoding.Text; book.GoodsID = Convert.ToInt32(txtCode.Tag); book.InputDate = dtpInputDate.Value; book.Manufacturer = txtManufacturer.Text; book.MaterialDate = chbZK.Checked ? null : (DateTime?)dtpMaterialDate.Value; book.Remark = txtRemark.Text; book.Validity = (int)numValidity.Value; book.ScrapFlag = chbBF.Checked; book.FactoryNo = txtFactoryNo.Text; book.GaugeType = cmbGaugeType.Text; book.CheckType = cmbCheckType.Text; return(book); }
/// <summary> /// 更新量检具信息 /// </summary> /// <param name="gaugeStandingBook">量检具信息</param> /// <param name="mode">操作类型</param> public void SaveInfo(S_GaugeStandingBook gaugeStandingBook, CE_OperatorMode mode) { using (DepotManagementDataContext ctx = CommentParameter.DepotDataContext) { try { var varGauge = from a in ctx.S_GaugeStandingBook where a.GaugeCoding == gaugeStandingBook.GaugeCoding select a; if (varGauge.Count() == 1) { if (mode == CE_OperatorMode.添加) { throw new Exception("已存在【量检具编号】:" + gaugeStandingBook.GaugeCoding + ", 无法添加"); } S_GaugeStandingBook lnqGauge = varGauge.Single(); lnqGauge.Manufacturer = gaugeStandingBook.Manufacturer; lnqGauge.Remark = gaugeStandingBook.Remark; lnqGauge.Validity = gaugeStandingBook.Validity; lnqGauge.EffectiveDate = gaugeStandingBook.EffectiveDate; lnqGauge.DutyUser = gaugeStandingBook.DutyUser; lnqGauge.InputDate = gaugeStandingBook.InputDate; lnqGauge.MaterialDate = gaugeStandingBook.MaterialDate; lnqGauge.CheckType = gaugeStandingBook.CheckType; lnqGauge.GaugeType = gaugeStandingBook.GaugeType; lnqGauge.FactoryNo = gaugeStandingBook.FactoryNo; } else if (varGauge.Count() == 0) { if (mode == CE_OperatorMode.修改) { throw new Exception("不存在【量检具编号】:" + gaugeStandingBook.GaugeCoding + ", 无法修改"); } gaugeStandingBook.F_Id = Guid.NewGuid().ToString(); ctx.S_GaugeStandingBook.InsertOnSubmit(gaugeStandingBook); } else { throw new Exception("【量检具编号】重复"); } ctx.SubmitChanges(); } catch (Exception) { throw; } } }
void StatusChange(DepotManagementDataContext ctx, string code) { var varBook = from a in ctx.S_GaugeStandingBook where a.GaugeCoding == code select a; S_GaugeStandingBook bookInfo = varBook.FirstOrDefault(); var varFile = from a in ctx.Bus_Gauge_Files where a.GaugeCode == code && a.FileType == "校准证书" select a; if (varFile.Count() > 0) { DateTime tempDate = (DateTime)varFile.Select(k => k.FileDate).Max(); bookInfo.EffectiveDate = tempDate.AddMonths((int)bookInfo.Validity); IBillMessagePromulgatorServer billMessageServer = BasicServerFactory.GetServerModule <IBillMessagePromulgatorServer>(); billMessageServer.BillType = "量检具台账"; billMessageServer.EndFlowMessage(code, "已提交了校准证书", null, null); } else { bookInfo.EffectiveDate = null; } var varScrapt = from a in ctx.Bus_Gauge_Files where a.GaugeCode == code && a.FileType == "报废记录" select a; if (varScrapt.Count() > 0) { bookInfo.ScrapFlag = true; } else { bookInfo.ScrapFlag = false; } }
public void OperationGaugeStandingBook(DepotManagementDataContext ctx, string billNo, CE_MarketingType type, int operationType) { try { CE_SubsidiaryOperationType subType = (CE_SubsidiaryOperationType)Enum.ToObject(typeof(CE_SubsidiaryOperationType), operationType); var varData = from a in ctx.S_GaugeOperation where a.BillID == billNo select a; foreach (S_GaugeOperation operationInfo in varData) { S_GaugeStandingBook lnqBook = new S_GaugeStandingBook(); var varbook = from a in ctx.S_GaugeStandingBook where a.GaugeCoding == operationInfo.GaugeCoding select a; if (varbook.Count() > 1) { throw new Exception("【物品ID】:" + operationInfo.GoodsID.ToString() + " 【量检具编号】:" + operationInfo.GaugeCoding + ",在【量检具台账】中存在多个,无法进行业务操作"); } if (type == CE_MarketingType.入库) { if (varbook.Count() == 0) { lnqBook = new S_GaugeStandingBook(); lnqBook.GaugeCoding = operationInfo.GaugeCoding; lnqBook.GoodsID = operationInfo.GoodsID; lnqBook.InputDate = ServerTime.Time; lnqBook.ScrapFlag = false; lnqBook.Validity = 0; } else { lnqBook = varbook.Single(); lnqBook.MaterialDate = null; lnqBook.DutyUser = null; lnqBook.ScrapFlag = false; } } else if (type == CE_MarketingType.出库) { if (varbook.Count() == 0) { throw new Exception("【物品ID】:" + operationInfo.GoodsID.ToString() + " 【量检具编号】:" + operationInfo.GaugeCoding + ",不存在【量检具台账】中,无法进行【出库】业务操作"); } lnqBook = varbook.Single(); lnqBook.DutyUser = null; lnqBook.ScrapFlag = false; lnqBook.MaterialDate = ServerTime.Time; if (subType == CE_SubsidiaryOperationType.领料) { lnqBook.MaterialDate = ServerTime.Time; } } } } catch (Exception ex) { throw new Exception(ex.Message); } }