public DefInOrderModifyForm(MMInOrder order) { InitializeComponent(); OrderItem = order; rtbPurOrderID.Text = OrderItem.PurchaseOrderPK; var def = MMDefinition.Instance.Datas.FirstOrDefault(p => p.Enable && p.DefID == OrderItem.DefID); stbMMDef.Value = MMDefinition.Instance.GetNamebyID(def.ParamID); var sup = Supplier.Instance.Datas.FirstOrDefault(p => p.Enable && p.SupplierID == OrderItem.SupID); stbSupplier.Value = Supplier.Instance.GetNamebyID(sup.ParamID); rtbCheckLot.Text = OrderItem.CheckLot; rtbBatch.Text = OrderItem.BatchID; rtbCarID.Text = OrderItem.CarID; rtbCount.Text = OrderItem.DefCount.ToString(); rtbNote.Text = OrderItem.Note; }
public void CreateSampleOrder(MMInOrder mminorder) { var order = new SampleOrder { SampleQuantity = 50, SampleDate = DateTime.Today.ToString(EncodeConst.DateFormat), //SamplerPK = 1, State = DataState.New, SourceOrderID = mminorder.CheckLot, DefPK = mminorder.DefPK, SupPK = mminorder.SupPK, LotID = mminorder.BatchID, SampleType = SampleTypeEnum.PackagesComming }; CreateSampleOrderForm form = new CreateSampleOrderForm(order); if (form.ShowDialog() == DialogResult.OK) { GV.ChildDatas.Add(form.OrderItem); GV.Refresh(GV.MasterDatas, GV.ChildDatas); } }
private void rt_Ok_Click(object sender, EventArgs e) { if (System.Windows.Forms.DialogResult.No == System.Windows.Forms.MessageBox.Show("确定保存?" , "注意", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question)) { return; } if (DefPK.Value.IsNullOrWhiteSpace()) { MessageBox.Show("请选择物料"); return; } if (stbSupplier.Value.IsNullOrWhiteSpace()) { MessageBox.Show("请选择供应商"); return; } if (rtbPurOrderID.Text.IsNullOrWhiteSpace()) { MessageBox.Show("请输入采购单号"); return; } if (rtbLot.Text.IsNullOrWhiteSpace()) { MessageBox.Show("请输入批次"); return; } if (rtbCount.Text.IsNullOrWhiteSpace()) { MessageBox.Show("请输入数量"); return; } if (rtbCheckLot.Text.IsNullOrWhiteSpace()) { MessageBox.Show("请输入检验批次号"); return; } else { var items = MMInOrder.Instance.Datas.FirstOrDefault(p => p.CheckLot == rtbCheckLot.Text); if (items != null) { MessageBox.Show("检验批次号已存在!"); return; } } if (rtbCarID.Text.IsNullOrWhiteSpace()) { MessageBox.Show("请输入车号"); return; } OrderItem.SynTime = DateTime.Now.ToString(EncodeConst.DateTimeFormat);//获取当前时间 OrderItem.OrderID = MMInOrder.GetNewOrderID(System.DateTime.Today); OrderItem.BatchID = rtbLot.Text; OrderItem.CarID = rtbCarID.Text; OrderItem.DefCount = rtbCount.Text.DBValueToString().ToInt(); OrderItem.PurchaseOrderPK = rtbPurOrderID.Text; OrderItem.CheckLot = rtbCheckLot.Text; var sup = Supplier.Instance.Datas.FirstOrDefault(p => p.Enable && p.ParamName.Equals(stbSupplier.Value)); OrderItem.SupPK = sup.ParamID; var mm = MMDefinition.Instance.Datas.FirstOrDefault(p => p.Enable && p.ParamName.Equals(DefPK.Value)); OrderItem.DefPK = mm.DefPK; OrderItem.Note = rtbNote.Text; OrderItem.OrderState = MMDefInOrderStateEnum.Creat; var rv = Encode.EncodeData.SaveDatas(OrderItem); if (rv.Success) { AutoCreateOrder aco = new AutoCreateOrder(); aco.CreateSampleOrderByMMInOrder(OrderItem, false); newSampleOrder = aco.newSampleOrder; DialogResult = DialogResult.OK; } else { ReturnValue.ShowMessage(rv); } this.Close(); }
public bool CreateSampleOrderByMMInOrder(MMInOrder OrderItem, bool modifyOrNot) { bool isSuccess = false; SampleOrder SampleOrderItem = new SampleOrder(); SampleOrderItem.DefPK = OrderItem.DefPK; //物料PK SampleOrderItem.LotID = OrderItem.BatchID; //批次号 SampleOrderItem.SampleDate = OrderItem.SynTime; //抽样时间 SampleOrderItem.SourceOrderID = OrderItem.CheckLot; //来源单号 SampleOrderItem.Creator = OrderItem.Creator; //创建人 SampleOrderItem.CreateTime = OrderItem.SynTime; //创建时间 SampleOrderItem.SampleQuantity = 50; //样品数量 SampleOrderItem.SampleType = SampleTypeEnum.PackagesComming; //样品类型 SampleOrderItem.CheckType = CheckTypeEnum.Normal; //检验类型 SampleOrderItem.SupPK = OrderItem.SupPK; //供应商 //新建 if (!modifyOrNot) { SampleOrderItem.SampleID = EncodeHelper.GetOrderID <SampleOrder>("SampleID", "S");//样品ID SampleOrderItem.State = DataState.New; } else { SampleOrderItem.State = DataState.Changed; } SampleOrderItem.SamplerPK = -1; ReturnValue rv = SSIT.EncodeBase.Encode.EncodeData.SaveDatas <SampleOrder>(new EncodeCollection <SampleOrder>(SampleOrderItem)); if (rv.Success) { newSampleOrder = SampleOrderItem; ReturnValue.ShowMessage("已自动生成样品单!"); CheckOrder CheckOrderItem = new CheckOrder { SampleID = SampleOrderItem.SampleID, LotID = SampleOrderItem.LotID, HutPK = SampleOrderItem.HutPK, DefPK = SampleOrderItem.DefPK, SourceOrderID = SampleOrderItem.SourceOrderID, SampleDate = SampleOrderItem.SampleDate, CheckQuantity = 1, CheckType = CheckTypeEnum.Normal, State = DataState.New }; string PlanCheckItemString = SSIT.QMBase.DefinitionCheckItemCombine.GetCheckItemstringby(CheckOrderItem.DefPK, SSIT.QMBase.MMTypEnum.QM); if (PlanCheckItemString.IsNullOrEmpty()) { var order = (CheckOrder)CheckOrderItem.Clone(); order.IDENTITY = null; order.CreateTime = DateTime.Now.ToString(EncodeConst.DateTimeFormat); order.Creator = null; order.CheckOrderID = EncodeHelper.GetOrderID <CheckOrder>("CheckOrderID", "C"); string frontWorker = AllocationWorker(true); order.PlanInspector = frontWorker; rv = SSIT.EncodeBase.Encode.EncodeData.SaveDatas <CheckOrder>(new EncodeCollection <CheckOrder>(order)); if (rv.Success) { isSuccess = true; ReturnValue.ShowMessage("已自动生成检测单!"); } return(isSuccess); } Dictionary <int, List <CheckItem> > dick = new Dictionary <int, List <CheckItem> >(); string[] checkItems = PlanCheckItemString.Split(','); foreach (string checkItem in checkItems) { CheckItem ci = CheckItem.Instance.Datas.FirstOrDefault(p => p.Enable && p.ParamID == int.Parse(checkItem)); if (!dick.ContainsKey(ci.CheckCategoryID)) { dick.Add(ci.CheckCategoryID, new List <CheckItem>()); } dick[ci.CheckCategoryID].Add(ci); } //根据dick的数量创建检测单 foreach (var items in dick.Values) { //用linq,根据value查字典的key,即检测大类ID int CheckType = dick.FirstOrDefault(p => p.Value == items).Key; //CheckCategoryID —— 8包材前道 9包材后道 var order = (CheckOrder)CheckOrderItem.Clone(); order.IDENTITY = null; var list = items.Select(p => p.ParamID).ToList(); order.PlanCheckItemString = list.ListIntToString(); if (order.State == DataState.New) { order.CreateTime = DateTime.Now.ToString(EncodeConst.DateTimeFormat); order.Creator = null; order.CheckOrderID = EncodeHelper.GetOrderID <CheckOrder>("CheckOrderID", "C"); //调用分配函数 //包材前道 if (CheckType == 8) { string frontWorker = AllocationWorker(true); order.PlanInspector = frontWorker; } //包材后道 if (CheckType == 9) { string backWorker = AllocationWorker(false); order.PlanInspector = backWorker; } } rv = SSIT.EncodeBase.Encode.EncodeData.SaveDatas <CheckOrder>(new EncodeCollection <CheckOrder>(order)); if (rv.Success) { isSuccess = true; ReturnValue.ShowMessage("已自动生成检测单!"); } } } return(isSuccess); }