Esempio n. 1
0
        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
                });
            }
        }
Esempio n. 2
0
        private void edtMetrialLotNo_TxtboxKeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\r')
            {
                if (this.edtMoCode.Value.Trim() == string.Empty)
                {
                    ApplicationRun.GetInfoForm().AddEx("$CS_CMPleaseInputMO");
                    this.edtMoCode.TextFocus(false, true);
                    return;
                }

                if (!this.CheckSendMetrialNumber())
                {
                    this.edtMoPlanQty.TextFocus(false, true);
                    return;
                }

                if (this.edtMetrialLotNo.Value.Trim() == string.Empty)
                {
                    ApplicationRun.GetInfoForm().AddEx("$Please_Input_MaterialLot");
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }

                InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
                object          materialLot     = inventoryFacade.GetMaterialLot(this.edtMetrialLotNo.Value.Trim().ToUpper());
                if (materialLot == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Not_Find_Metrial"));
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }

                MaterialLotWithItemDesc materialLotWithItemDesc = (MaterialLotWithItemDesc)inventoryFacade.GetMaterialLotAndItemDesc(FormatHelper.CleanString(this.edtMoCode.Value.Trim().ToUpper()), this.edtMetrialLotNo.Value.Trim().ToUpper());

                if (materialLotWithItemDesc == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$MaterialLot_NOMAP_MO"));
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }

                if (materialLotWithItemDesc.LotQty == 0)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_MetrialLot_Is_Empty"));
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }

                //检查物料是否存在Sbom
                SBOMFacade sboMFacade = new SBOMFacade(this.DataProvider);
                object[]   sBOMList   = sboMFacade.QuerySBOMByMoCode(this.edtMoCode.Value.Trim().ToUpper());

                if (sBOMList == null)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SBOMInMO_IsNot_Exist"));
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }

                bool materailIsInSBOM = false;
                for (int i = 0; i < sBOMList.Length; i++)
                {
                    if (((SBOM)sBOMList[i]).SBOMItemCode.Trim().ToUpper() == materialLotWithItemDesc.ItemCode.Trim().ToUpper())
                    {
                        materailIsInSBOM = true;
                        break;
                    }
                }

                if (!materailIsInSBOM)
                {
                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_Material_Not_In_SBOM"));
                    this.edtMetrialLotNo.TextFocus(false, true);
                    return;
                }
                //end

                //检查是否需要再加载到Grid上
                bool dateHaveExist = false;

                for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++)
                {
                    if (ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().ToUpper() == materialLotWithItemDesc.MaterialLotNo.ToUpper())
                    {
                        dateHaveExist = true;
                        break;
                    }
                }

                if (!dateHaveExist)
                {
                    this.LoadGrid(new object[] { materialLotWithItemDesc });
                }
                //end

                this.edtMetrialLotNo.TextFocus(false, true);
            }
        }