private void LoadGrid(object[] dataObjects) { if (this.opsLoadMetrial.Value == "0") { _DataTableLoadedPart.Clear(); } int needBatchNumber = Convert.ToInt32(this.edtMoPlanQty.Value.Trim()); int needNumber = 0; int[] lotNeedNumberList = new int[dataObjects.Length]; //计算每行发料数量 for (int i = 0; i < dataObjects.Length; i++) { int lotSendNumber = 0; MaterialLotWithItemDesc materialLotWithItemDesc = (MaterialLotWithItemDesc)dataObjects[i]; string lastItemCode = string.Empty; if (i > 0) { MaterialLotWithItemDesc materialLotWithItemDescLast = (MaterialLotWithItemDesc)dataObjects[i - 1]; lastItemCode = materialLotWithItemDescLast.ItemCode; } if (lastItemCode != materialLotWithItemDesc.ItemCode) { SBOMFacade SBOMFacade = new SBOMFacade(this.DataProvider); decimal sBomItemQty = SBOMFacade.GetSbomItemQtyWithMo(materialLotWithItemDesc.ItemCode, FormatHelper.CleanString(this.edtMoCode.Value.Trim().ToUpper())); needNumber = Convert.ToInt32(Math.Ceiling(needBatchNumber * sBomItemQty)); } lotSendNumber = Math.Min(materialLotWithItemDesc.LotQty, needNumber); lotNeedNumberList[i] = lotSendNumber; needNumber -= lotSendNumber; } for (int i = 0; i < dataObjects.Length; i++) { Domain.Material.MaterialLotWithItemDesc materialLotWithItemDesc = (Domain.Material.MaterialLotWithItemDesc)dataObjects[i]; _DataTableLoadedPart.Rows.Add(new object[] { true, materialLotWithItemDesc.MaterialLotNo, materialLotWithItemDesc.IQCNo, materialLotWithItemDesc.STLine, materialLotWithItemDesc.VendorCode, materialLotWithItemDesc.VendorDesc, materialLotWithItemDesc.ItemCode, materialLotWithItemDesc.ItemDesc, materialLotWithItemDesc.CreateDate, materialLotWithItemDesc.LotQty, lotNeedNumberList[i], materialLotWithItemDesc.OrganizationID, materialLotWithItemDesc.StorageID, materialLotWithItemDesc.Unit }); } }
//检查Grid发货数量 private bool CheckGridSendNumber() { Dictionary <string, int> sendQtyByItem = new Dictionary <string, int>(); for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++) { if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true") { string itemCode = ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString(); int lotInQty = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["LotQty"].Value.ToString()); int lotQty = ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim() == string.Empty ? 0 : int.Parse(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim()); if (lotInQty < lotQty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_LotQty_Smaller_LotInQty $CS_MaterialLot:" + ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString())); return(false); } if (lotQty <= 0) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_LotQty_Over_Zero $CS_MaterialLot:" + ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString())); return(false); } if (!sendQtyByItem.ContainsKey(itemCode)) { sendQtyByItem.Add(itemCode, 0); } sendQtyByItem[itemCode] += lotQty; } } SBOMFacade SBOMFacade = new SBOMFacade(this.DataProvider); foreach (KeyValuePair <string, int> par in sendQtyByItem) { decimal SbomItemQty = SBOMFacade.GetSbomItemQtyWithMo(par.Key, FormatHelper.CleanString(this.edtMoCode.Value.Trim().ToUpper())); int planQty = Convert.ToInt32(Math.Ceiling(SbomItemQty * Convert.ToInt32(this.edtMoPlanQty.Value.Trim()))); if (par.Value > planQty) { ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_OneItem_SendNumber:" + par.Value + "$CS_Not_Over_PlanQty:" + planQty + " $CS_ItemCode:" + par.Key)); return(false); } } return(true); }