Beispiel #1
0
        private void btnSendMetrial_Click(object sender, EventArgs e)
        {
            //UI Check
            ultraGridMetrialDetial.Rows.Band.SortedColumns.Add("ReceiveDate", false);

            if (!ValidateInput())
            {
                return;
            }

            string stockInStorage = FormatString(ucLabelComboxStorageIn.SelectedItemValue);
            string uiToItem       = FormatString(ucLabelEditToItem.Value).Trim().ToUpper();

            string moCode = FormatString(this.ucLabelEditIssueNo.Value);

            if (moCode == "")
            {
                moCode = " ";
            }

            //获取业务类型
            string           businesscode     = FormatString(ucLabelComboxBusinessCode.SelectedItemValue);
            MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode);

            //判断入库库别是否被管理
            //tblsysparam.PARAMCODE维护的是需要管理的库别对应tblstorage.STORAGECODE
            //对应的tblsysparamgroup.PARAMGROUPCODE="DESTSTORAGEMANAGE"
            SystemSettingFacade systemFacade = new SystemSettingFacade(this.DataProvider);
            object para = systemFacade.GetParameter(stockInStorage, "DESTSTORAGEMANAGE");
            bool   isManageToStorage = false;

            if (para != null)
            {
                isManageToStorage = true;
            }

            List <string> lotNoList  = new List <string>();
            DBDateTime    dBDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
            bool          saveData   = true;

            try
            {
                this.DataProvider.BeginTransaction();
                for (int i = 0; i < ultraGridMetrialDetial.Rows.Count; i++)
                {
                    int lotSendNumber = ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim() == string.Empty ? 0 : Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value.ToString().Trim());
                    if (ultraGridMetrialDetial.Rows[i].Cells["Check"].Value.ToString().ToLower() == "true" && lotSendNumber > 0)
                    {
                        MaterialLot materialLot = (MaterialLot)this.InvFacade.GetMaterialLot(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString().Trim().ToUpper());
                        //只有当目标库房没有被管理时,才需要做FIFO检查,就如同工单发料的库房没有被管理,在发料的时候是需要FIFO检查的
                        if (materialLot != null && materialLot.FIFOFlag == "Y" && isManageToStorage == false)
                        {
                            if (!CheckFiFo(lotNoList, ultraGridMetrialDetial.Rows[i].Cells["ItemCode"].Value.ToString(),
                                           ultraGridMetrialDetial.Rows[i].Cells["VendorCode"].Value.ToString(),
                                           Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["ReceiveDate"].Value), materialLot.StorageID.Trim().ToUpper()))
                            {
                                this.DataProvider.RollbackTransaction();
                                saveData = false;
                                break;
                            }
                        }

                        if (materialLot != null)
                        {
                            int    orgIdStockOut        = 0;
                            int    orgIdStockIn         = 0;
                            string fromSAPStorageID     = " ";
                            string toSAPStorageID       = " ";
                            string materialLotNoStockIn = " ";
                            object storageStockIn       = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue));
                            if (storageStockIn != null)
                            {
                                orgIdStockIn   = ((Storage)storageStockIn).OrgID;
                                toSAPStorageID = ((Storage)storageStockIn).SAPStorage;
                            }

                            object storageStockOut = this.InvFacade.GetStorageByStorageCode(materialLot.StorageID);
                            if (storageStockOut != null)
                            {
                                orgIdStockOut    = ((Storage)storageStockOut).OrgID;
                                fromSAPStorageID = ((Storage)storageStockOut).SAPStorage;
                            }

                            string toItemCode = uiToItem.Trim().Length == 0 ? materialLot.ItemCode : uiToItem.Trim().ToUpper();
                            //判断是否超发
                            int sendQty = Convert.ToInt32(ultraGridMetrialDetial.Rows[i].Cells["SendQty"].Value);
                            if ((materialLot.LotQty - sendQty) < 0)
                            {
                                ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Error, "$CS_SendMaterialLot_Not_Enough"));
                                this.DataProvider.RollbackTransaction();
                                saveData = false;
                                break;
                            }

                            if (isManageToStorage == true)
                            {
                                //当目标库管理时
                                if (materialLot.LotQty == sendQty && materialLot.ItemCode == toItemCode)
                                {
                                    materialLotNoStockIn = materialLot.MaterialLotNo;
                                    //当发料数量等于库存数量,直接修改TBLMaterialLot中的库别和ToItemCode
                                    MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot();
                                    materialLotStockIn.MaterialLotNo  = materialLot.MaterialLotNo;
                                    materialLotStockIn.IQCNo          = materialLot.IQCNo;
                                    materialLotStockIn.STLine         = materialLot.STLine;
                                    materialLotStockIn.ItemCode       = materialLot.ItemCode;
                                    materialLotStockIn.VendorCode     = materialLot.VendorCode;
                                    materialLotStockIn.OrganizationID = orgIdStockIn;
                                    materialLotStockIn.StorageID      = stockInStorage;
                                    materialLotStockIn.Unit           = materialLot.Unit;
                                    //Modified By Nettie Chen 2009/09/24
                                    //materialLotStockIn.CreateDate = dBDateTime.DBDate;
                                    materialLotStockIn.CreateDate = materialLot.CreateDate;
                                    //End Modified
                                    materialLotStockIn.LotInQty     = materialLot.LotInQty;
                                    materialLotStockIn.LotQty       = materialLot.LotQty;
                                    materialLotStockIn.FIFOFlag     = materialLot.FIFOFlag;
                                    materialLotStockIn.MaintainUser = ApplicationService.Current().UserCode;
                                    materialLotStockIn.MaintainDate = dBDateTime.DBDate;
                                    materialLotStockIn.MaintainTime = dBDateTime.DBTime;

                                    this.InvFacade.UpdateMaterialLot(materialLotStockIn);
                                }
                                else
                                {
                                    //当发料数量不等于库存数量,或Item有变化时,产生新的Lot
                                    string dateCode      = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate);
                                    string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, toItemCode, materialLot.CreateDate);
                                    materialLotNoStockIn = materialLot.VendorCode + "-" + toItemCode + "-" + dateCode + "-" + runningNumber;

                                    //修改出库的TBLMaterialLot
                                    materialLot.LotQty       = materialLot.LotQty - sendQty;
                                    materialLot.MaintainDate = dBDateTime.DBDate;
                                    materialLot.MaintainTime = dBDateTime.DBTime;
                                    this.InvFacade.UpdateMaterialLot(materialLot);

                                    //新增入库的TBLMaterialLot
                                    MaterialLot materialLotStockIn = this.InvFacade.CreateNewMaterialLot();
                                    materialLotStockIn.MaterialLotNo  = materialLotNoStockIn;
                                    materialLotStockIn.IQCNo          = materialLot.IQCNo;
                                    materialLotStockIn.STLine         = materialLot.STLine;
                                    materialLotStockIn.ItemCode       = toItemCode;
                                    materialLotStockIn.VendorCode     = materialLot.VendorCode;
                                    materialLotStockIn.OrganizationID = orgIdStockIn;
                                    materialLotStockIn.StorageID      = stockInStorage;
                                    materialLotStockIn.Unit           = materialLot.Unit;
                                    materialLotStockIn.CreateDate     = materialLot.CreateDate;
                                    materialLotStockIn.LotInQty       = sendQty;
                                    materialLotStockIn.LotQty         = sendQty;
                                    materialLotStockIn.FIFOFlag       = materialLot.FIFOFlag;
                                    materialLotStockIn.MaintainUser   = ApplicationService.Current().UserCode;
                                    materialLotStockIn.MaintainDate   = dBDateTime.DBDate;
                                    materialLotStockIn.MaintainTime   = dBDateTime.DBTime;
                                    this.InvFacade.AddMaterialLot(materialLotStockIn);
                                }

                                //入库的TBLMaterialTrans
                                MaterialTrans materialTransStockIn = this.InvFacade.CreateNewMaterialTrans();
                                materialTransStockIn.Serial          = 0;
                                materialTransStockIn.FRMaterialLot   = materialLot.MaterialLotNo;
                                materialTransStockIn.FRMITEMCODE     = materialLot.ItemCode;
                                materialTransStockIn.FRMStorageID    = materialLot.StorageID;
                                materialTransStockIn.TOMaterialLot   = materialLotNoStockIn;
                                materialTransStockIn.TOITEMCODE      = toItemCode;
                                materialTransStockIn.TOStorageID     = stockInStorage;
                                materialTransStockIn.TransQTY        = sendQty;
                                materialTransStockIn.Memo            = FormatString(this.ucLabelEditMemo.Value);
                                materialTransStockIn.UNIT            = materialLot.Unit;
                                materialTransStockIn.VendorCode      = materialLot.VendorCode;
                                materialTransStockIn.IssueType       = IssueType.IssueType_Receive;
                                materialTransStockIn.TRANSACTIONCODE = moCode;
                                materialTransStockIn.BusinessCode    = materialBusiness.BusinessCode;
                                materialTransStockIn.OrganizationID  = orgIdStockIn;
                                materialTransStockIn.MaintainUser    = ApplicationService.Current().UserCode;
                                materialTransStockIn.MaintainDate    = dBDateTime.DBDate;
                                materialTransStockIn.MaintainTime    = dBDateTime.DBTime;
                                this.InvFacade.AddMaterialTrans(materialTransStockIn);
                            }
                            else
                            {
                                //当目标库没有管理时,只更新出库的TBLMaterialLot.lotqty
                                materialLotNoStockIn = materialLot.MaterialLotNo;

                                materialLot.LotQty       = materialLot.LotQty - sendQty;
                                materialLot.MaintainUser = ApplicationService.Current().UserCode;
                                materialLot.MaintainDate = dBDateTime.DBDate;
                                materialLot.MaintainTime = dBDateTime.DBTime;

                                this.InvFacade.UpdateMaterialLot(materialLot);
                            }

                            //出库的TBLMaterialTrans
                            MaterialTrans materialTransStockOut = this.InvFacade.CreateNewMaterialTrans();
                            materialTransStockOut.Serial          = 0;
                            materialTransStockOut.FRMaterialLot   = materialLot.MaterialLotNo;
                            materialTransStockOut.FRMITEMCODE     = materialLot.ItemCode;
                            materialTransStockOut.FRMStorageID    = materialLot.StorageID;
                            materialTransStockOut.TOMaterialLot   = materialLotNoStockIn;
                            materialTransStockOut.TOITEMCODE      = toItemCode;
                            materialTransStockOut.TOStorageID     = stockInStorage;
                            materialTransStockOut.TransQTY        = sendQty;
                            materialTransStockOut.Memo            = FormatString(this.ucLabelEditMemo.Value);
                            materialTransStockOut.UNIT            = materialLot.Unit;
                            materialTransStockOut.VendorCode      = materialLot.VendorCode;
                            materialTransStockOut.IssueType       = IssueType.IssueType_Issue;
                            materialTransStockOut.TRANSACTIONCODE = moCode;
                            materialTransStockOut.BusinessCode    = materialBusiness.BusinessCode;
                            materialTransStockOut.OrganizationID  = orgIdStockOut;
                            materialTransStockOut.MaintainUser    = ApplicationService.Current().UserCode;
                            materialTransStockOut.MaintainDate    = dBDateTime.DBDate;
                            materialTransStockOut.MaintainTime    = dBDateTime.DBTime;

                            this.InvFacade.AddMaterialTrans(materialTransStockOut);

                            if (materialBusiness.SAPCODE.Trim().Length > 0)
                            {
                                SAPMaterialTrans sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans();
                                sAPMaterialTrans.MaterialLotNo  = materialLot.MaterialLotNo;
                                sAPMaterialTrans.PostSeq        = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo);
                                sAPMaterialTrans.OrganizationID = orgIdStockOut;
                                sAPMaterialTrans.ItemCode       = materialLot.ItemCode;
                                sAPMaterialTrans.AccountDate    = FormatHelper.TODateInt(ucDateAccount.Value);
                                sAPMaterialTrans.VoucherDate    = FormatHelper.TODateInt(ucDateVoucher.Value);
                                sAPMaterialTrans.FRMStorageID   = fromSAPStorageID;
                                sAPMaterialTrans.TOStorageID    = toSAPStorageID;
                                sAPMaterialTrans.TransQTY       = sendQty;
                                sAPMaterialTrans.ReceiveMemo    = FormatString(this.ucLabelEditMemo.Value);
                                sAPMaterialTrans.Unit           = materialLot.Unit;

                                //当非即售时Vendor为空
                                if (radioButtonSaleDelay.Checked == true)
                                {
                                    sAPMaterialTrans.VendorCode = " ";
                                }
                                else
                                {
                                    sAPMaterialTrans.VendorCode = materialLot.VendorCode;
                                }
                                sAPMaterialTrans.MoCode          = moCode;
                                sAPMaterialTrans.Flag            = FlagStatus.FlagStatus_MES;
                                sAPMaterialTrans.TransactionCode = " ";
                                sAPMaterialTrans.ToItemCode      = toItemCode;
                                sAPMaterialTrans.SAPCode         = materialBusiness.SAPCODE;
                                sAPMaterialTrans.MaintainUser    = ApplicationService.Current().UserCode;
                                sAPMaterialTrans.MaintainDate    = dBDateTime.DBDate;
                                sAPMaterialTrans.MaintainTime    = dBDateTime.DBTime;

                                this.InvFacade.AddSAPMaterialTrans(sAPMaterialTrans);
                            }
                        }

                        lotNoList.Add(ultraGridMetrialDetial.Rows[i].Cells["MetrialLot"].Value.ToString());
                    }
                }

                if (saveData)
                {
                    this.DataProvider.CommitTransaction();

                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_SendMaterialLot_Success"));
                }
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();

                Messages msg = new Messages();
                msg.Add(new UserControl.Message(ex));
                ApplicationRun.GetInfoForm().Add(msg);
            }

            if (saveData)
            {
                //_DataTableLoadedPart.Clear();
                //ucBtnQuery_Click
                ucBtnQuery_Click(this, null);
            }
        }
        private ServiceResult RunOne(SAPWebServiceEntity webServiceEntity, SAPMaterialTrans sapMaterialTrans, DT_MES_TRANSFERPOST_REQ req)
        {
            string xmlFilePath = SerializeUtil.SerializeFile(this.m_Argument.TransactionCode + "_Request.xml",
                                                             typeof(DT_MES_TRANSFERPOST_REQ), req);

            #region TransferLog

            DBDateTime         dateTime         = FormatHelper.GetNowDBDateTime(this.DataProvider);
            SAPDataTransferLog materialIssueLog = new SAPDataTransferLog();
            TransferFacade     transferFacade   = new TransferFacade(this.DataProvider);

            materialIssueLog.JobID               = TransferFacade.MaterialIssueJobID;
            materialIssueLog.TransactionCode     = this.m_Argument.TransactionCode;
            materialIssueLog.TransactionSequence = 1;
            materialIssueLog.RequestDate         = dateTime.DBDate;
            materialIssueLog.RequestTime         = dateTime.DBTime;
            materialIssueLog.RequestContent      = xmlFilePath;
            materialIssueLog.OrganizationID      = 2000;
            materialIssueLog.SendRecordCount     = 1;

            transferFacade.AddSAPDataTransferLog(materialIssueLog);

            #endregion

            #region Begin for Calling WebService

            try
            {
                MaterialIssueServiceClientProxy clientProxy = new MaterialIssueServiceClientProxy();
                clientProxy.RequestEncoding = Encoding.UTF8;
                clientProxy.Timeout         = InternalVariables.MS_TimeOut * 1000;
                clientProxy.Url             = webServiceEntity.Url;
                clientProxy.PreAuthenticate = true;
                System.Uri uri = new Uri(clientProxy.Url);
                clientProxy.Credentials = new NetworkCredential(webServiceEntity.UserName, webServiceEntity.Password).GetCredential(uri, "");
                clientProxy.MI_MES_TRANSFERPOST_REQ(req);
                clientProxy.Dispose();
                clientProxy = null;
            }
            catch (Exception e)
            {
                materialIssueLog.Result       = "Fail";
                materialIssueLog.ErrorMessage = e.Message;
                transferFacade.UpdateSAPDataTransferLog(materialIssueLog);
                return(new ServiceResult(false, e.Message, materialIssueLog.TransactionCode));
            }

            #endregion

            #region Update tblsapmaterialtrans

            if (sapMaterialTrans != null)
            {
                InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);
                try
                {
                    sapMaterialTrans.Flag            = FlagStatus.FlagStatus_POST;
                    sapMaterialTrans.TransactionCode = this.m_Argument.TransactionCode;
                    inventoryFacade.UpdateSAPMaterialTrans(sapMaterialTrans);
                }
                catch (Exception ex)
                {
                    return(new ServiceResult(false, ex.Message, this.m_Argument.TransactionCode));
                }
            }

            #endregion

            return(new ServiceResult(true, "", this.m_Argument.TransactionCode));
        }
Beispiel #3
0
        private void bntStockIn_Click(object sender, EventArgs e)
        {
            try
            {
                DBDateTime dbDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string     itemDesc   = string.Empty;
                string     vendorDesc = string.Empty;
                bool       result     = ValidateInput(out itemDesc, out vendorDesc);
                if (result == false)
                {
                    return;
                }
                string businesscode = FormatString(ucLabelComboxBusinessCode.SelectedItemValue);
                int    qty          = int.Parse(ucLabelEditQty.Value);

                //入库库别
                string fromSAPStorageID = string.Empty;
                string toSAPStorageID   = string.Empty;
                int    orgId            = 0;
                object storageStockIn   = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageIn.SelectedItemValue));
                if (storageStockIn != null)
                {
                    orgId          = ((Storage)storageStockIn).OrgID;
                    toSAPStorageID = ((Storage)storageStockIn).SAPStorage;
                }

                object storageStockOut = this.InvFacade.GetStorageByStorageCode(FormatString(ucLabelComboxStorageOut.SelectedItemValue));
                if (storageStockOut != null)
                {
                    fromSAPStorageID = ((Storage)storageStockOut).SAPStorage;
                }

                //获取当前业务代码信息
                MaterialBusiness materialBusiness = (MaterialBusiness)this.WHFacade.GetMaterialBusiness(businesscode);
                string           iqcno            = FormatString(this.ucLabelEditDoc.Value).ToUpper();
                if (iqcno == "")
                {
                    iqcno = " ";
                }
                //Config MaterialLot
                MaterialLot materialLot = this.InvFacade.CreateNewMaterialLot();
                materialLot.IQCNo          = iqcno;
                materialLot.STLine         = FormatInt(this.ucLabelEditDocLine.Value);
                materialLot.ItemCode       = FormatString(this.ucLEItemCode.Value);
                materialLot.VendorCode     = FormatString(this.ucLabelEditVendor.Value);
                materialLot.OrganizationID = orgId;
                materialLot.StorageID      = FormatString(ucLabelComboxStorageIn.SelectedItemValue);
                materialLot.Unit           = FormatString(this.ucLabelEditUnit.Value);
                materialLot.CreateDate     = FormatHelper.TODateInt(ucDateStockIn.Value);
                materialLot.LotInQty       = qty;
                materialLot.LotQty         = qty;
                materialLot.FIFOFlag       = materialBusiness.ISFIFO;
                materialLot.MaintainUser   = ApplicationService.Current().UserCode;
                materialLot.MaintainDate   = dbDateTime.DBDate;
                materialLot.MaintainTime   = dbDateTime.DBTime;

                //Set MaterialLotNo
                string dateCode      = this.InvFacade.GetMaterialLotDateCode(materialLot.CreateDate);
                string runningNumber = this.InvFacade.GetNewMaterialLotRunningNumber(materialLot.VendorCode, materialLot.ItemCode, materialLot.CreateDate);
                materialLot.MaterialLotNo = materialLot.VendorCode + "-" + materialLot.ItemCode + "-" + dateCode + "-" + runningNumber;

                //Config MaterialTrans
                MaterialTrans materialTrans = this.InvFacade.CreateNewMaterialTrans();
                materialTrans.Serial          = 0;
                materialTrans.FRMaterialLot   = " ";
                materialTrans.FRMITEMCODE     = " ";
                materialTrans.FRMStorageID    = " ";
                materialTrans.TOMaterialLot   = materialLot.MaterialLotNo;
                materialTrans.TOITEMCODE      = materialLot.ItemCode;
                materialTrans.TOStorageID     = materialLot.StorageID;
                materialTrans.TransQTY        = materialLot.LotInQty;
                materialTrans.Memo            = FormatString(this.ucLabelEditMemo.Value);
                materialTrans.UNIT            = materialLot.Unit;
                materialTrans.VendorCode      = materialLot.VendorCode;
                materialTrans.IssueType       = IssueType.IssueType_Receive;
                materialTrans.TRANSACTIONCODE = materialLot.IQCNo;
                materialTrans.BusinessCode    = materialBusiness.BusinessCode;
                materialTrans.OrganizationID  = materialLot.OrganizationID;
                materialTrans.MaintainUser    = ApplicationService.Current().UserCode;
                materialTrans.MaintainDate    = dbDateTime.DBDate;
                materialTrans.MaintainTime    = dbDateTime.DBTime;

                //Config Sapmaterialtrans
                //分别获取入库库别和发货库别对应的SAP库别,在TBLsAPMaterialTrans中的StorageId存放的是SAP库别
                SAPMaterialTrans sAPMaterialTrans = null;
                if (materialBusiness.SAPCODE.Trim().Length > 0)
                {
                    sAPMaterialTrans = this.InvFacade.CreateNewSAPMaterialTrans();
                    sAPMaterialTrans.MaterialLotNo  = materialLot.MaterialLotNo;
                    sAPMaterialTrans.PostSeq        = this.InvFacade.GetSAPMaterialTransMaxSeq(materialLot.MaterialLotNo);
                    sAPMaterialTrans.OrganizationID = materialLot.OrganizationID;
                    sAPMaterialTrans.ItemCode       = materialLot.ItemCode;
                    sAPMaterialTrans.AccountDate    = FormatHelper.TODateInt(ucDateAccount.Value);
                    sAPMaterialTrans.VoucherDate    = FormatHelper.TODateInt(ucDateVoucher.Value);
                    if (fromSAPStorageID == "" || fromSAPStorageID == null)
                    {
                        sAPMaterialTrans.FRMStorageID = " ";
                    }
                    else
                    {
                        sAPMaterialTrans.FRMStorageID = fromSAPStorageID;
                    }
                    if (toSAPStorageID == "" || toSAPStorageID == null)
                    {
                        sAPMaterialTrans.TOStorageID = " ";
                    }
                    else
                    {
                        sAPMaterialTrans.TOStorageID = toSAPStorageID;
                    }
                    sAPMaterialTrans.TransQTY    = materialLot.LotInQty;
                    sAPMaterialTrans.ReceiveMemo = FormatString(this.ucLabelEditMemo.Value);
                    sAPMaterialTrans.Unit        = materialLot.Unit;
                    //当非即售时Vendor为空
                    if (radioButtonSaleDelay.Checked == true)
                    {
                        sAPMaterialTrans.VendorCode = " ";
                    }
                    else
                    {
                        sAPMaterialTrans.VendorCode = materialLot.VendorCode;
                    }
                    sAPMaterialTrans.MoCode          = materialLot.IQCNo;
                    sAPMaterialTrans.Flag            = FlagStatus.FlagStatus_MES;
                    sAPMaterialTrans.TransactionCode = " ";
                    sAPMaterialTrans.ToItemCode      = materialLot.ItemCode;
                    if (materialBusiness.SAPCODE == null || materialBusiness.SAPCODE == "")
                    {
                        sAPMaterialTrans.SAPCode = " ";
                    }
                    else
                    {
                        sAPMaterialTrans.SAPCode = materialBusiness.SAPCODE;
                    }
                    sAPMaterialTrans.MaintainUser = ApplicationService.Current().UserCode;
                    sAPMaterialTrans.MaintainDate = dbDateTime.DBDate;
                    sAPMaterialTrans.MaintainTime = dbDateTime.DBTime;
                }

                bool saveData = this.InvFacade.MaterialStockIn(materialLot, materialBusiness, materialTrans, sAPMaterialTrans);

                if (saveData)
                {
                    //向Grid上增加记录
                    DataRow dr = this._DataTable.NewRow();
                    dr["Check"]          = false;
                    dr["MaterialLot"]    = materialLot.MaterialLotNo;
                    dr["IQCNO"]          = materialLot.IQCNo;
                    dr["IQCLine"]        = materialLot.STLine;
                    dr["VendorCode"]     = materialLot.VendorCode;
                    dr["VendorDesc"]     = vendorDesc;
                    dr["ItemCode"]       = materialLot.ItemCode;
                    dr["ItemCodeDesc"]   = itemDesc;
                    dr["ReceiveDate"]    = materialLot.CreateDate;
                    dr["StockInQty"]     = materialLot.LotInQty;
                    dr["StockInStorage"] = materialLot.StorageID;
                    dr["FifoChcek"]      = materialBusiness.ISFIFO;
                    dr["FrmMemo"]        = FormatString(this.ucLabelEditMemo.Value).Replace("\n", " ");
                    this._DataTable.Rows.Add(dr);

                    ClearInputData();

                    ApplicationRun.GetInfoForm().Add(new UserControl.Message(MessageType.Success, "$CS_StockIn_Success"));
                }
            }
            catch (Exception ex)
            {
                Messages msg = new Messages();
                msg.Add(new UserControl.Message(ex));
                ApplicationRun.GetInfoForm().Add(msg);
            }
        }