示例#1
0
        public bool ArgumentValid(ref string returnMessage)
        {
            returnMessage = string.Empty;

            if (this.m_Argument.DNList == null || this.m_Argument.DNList.Count == 0)
            {
                returnMessage = "交货单列表不能为空";
                return(false);
            }

            DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);

            foreach (DT_MES_DNPOST dn in this.m_Argument.DNList)
            {
                DeliveryNote deliveryNote = (DeliveryNote)deliveryFacade.GetDeliveryNote(dn.VBELN.Trim().ToUpper(), dn.POSNR.Trim().ToUpper());
                if (deliveryNote == null)
                {
                    returnMessage += "交货单不存在(交货单号:" + dn.VBELN.Trim().ToUpper() + ",交货单行项目:" + dn.POSNR.Trim().ToUpper() + ")" + "\n";
                }
                else
                {
                    if (deliveryNote.Flag != FlagStatus.FlagStatus_MES)
                    {
                        returnMessage += "交货单尚未出货,或者已经同步(交货单号:" + dn.VBELN.Trim().ToUpper() + ",交货单行项目:" + dn.POSNR.Trim().ToUpper() + ")" + "\n";
                    }
                }
            }
            if (returnMessage.Trim().Length > 0)
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        protected override object GetEditObject()
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            DBDateTime dateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

            DeliveryNote deliveryNote = this.facade.CreateNewDN();

            deliveryNote.DNCode              = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOEdit.Text, 40));
            deliveryNote.ShipTo              = FormatHelper.CleanString(this.txtShipToPartyEdit.Text);
            deliveryNote.DNLine              = "0";
            deliveryNote.ItemCode            = " ";
            deliveryNote.OrganizationID      = GlobalVariables.CurrentOrganizations.First().OrganizationID;
            deliveryNote.DNQuantity          = 0;
            deliveryNote.RealQuantity        = 0;
            deliveryNote.Unit                = " ";
            deliveryNote.MOCode              = " ";
            deliveryNote.OrderNo             = FormatHelper.CleanString(this.txtOrderNoEdit.Text);
            deliveryNote.CustomerOrderNo     = " ";
            deliveryNote.CustomerOrderNoType = " ";
            deliveryNote.MaintainUser        = this.GetUserCode();
            deliveryNote.MaintainDate        = dateTime.DBDate;
            deliveryNote.MaintainTime        = dateTime.DBTime;
            deliveryNote.DNFrom              = DNFrom.MES; //"MES";

            object obj = facade.GetDeliveryNote(deliveryNote.DNCode, "0");

            if (obj != null)
            {
                DeliveryNote deliveryNoteNew = obj as DeliveryNote;
                deliveryNote.DNStatus = deliveryNoteNew.DNStatus;
            }
            else
            {
                deliveryNote.DNStatus = DNStatus.StatusInit;
            }

            deliveryNote.RelatedDocument = FormatHelper.CleanString(this.txtRelateDocumentEdit.Text);
            deliveryNote.BusinessCode    = FormatHelper.CleanString(this.drpBusinessCodeEdit.Text);
            deliveryNote.Dept            = FormatHelper.CleanString(this.txtDeptEdit.Text);
            deliveryNote.Memo            = FormatHelper.CleanString(this.txtMemoEdit.Text);

            return(deliveryNote);
        }
示例#3
0
        private void DealDN(List <MES_DN> dnlist, DBDateTime currentDateTime)
        {
            DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);

            foreach (MES_DN dn in dnlist)
            {
                deliveryFacade.DeleteDN4Receive(dn.DNCode);
            }

            DeliveryNote deliveryNote;
            object       oldDeliveryNote;

            foreach (MES_DN dn in dnlist)
            {
                deliveryNote        = deliveryFacade.CreateNewDN();
                deliveryNote.DNCode = FormatHelper.PKCapitalFormat(dn.DNCode);
                deliveryNote.DNLine = FormatHelper.PKCapitalFormat(dn.DNLine);

                deliveryNote.CustomerOrderNo     = dn.CustomerOrderNo;
                deliveryNote.CustomerOrderNoType = dn.CustomerOrderNoType;
                deliveryNote.DNQuantity          = dn.DNQuantity;
                deliveryNote.SAPStorage          = dn.FromStorage;
                deliveryNote.FromStorage         = dn.OrgID.ToString() + "-" + dn.FromStorage;
                deliveryNote.ItemCode            = dn.ItemCode;
                //deliveryNote.ItemDescription = dn.ItemDescription;
                deliveryNote.ItemDescription = ""; // Temp save null

                //deliveryNote.ItemGrade = dn.ItemGrade;
                deliveryNote.MaintainDate   = currentDateTime.DBDate;
                deliveryNote.MaintainTime   = currentDateTime.DBTime;
                deliveryNote.MaintainUser   = "******";
                deliveryNote.MOCode         = dn.MOCode;
                deliveryNote.MovementType   = dn.MovementType;
                deliveryNote.OrderNo        = dn.OrderNo;
                deliveryNote.OrganizationID = dn.OrgID;
                deliveryNote.ShipTo         = dn.ShipTo;
                deliveryNote.ToStorage      = dn.ToStorage;
                deliveryNote.Unit           = dn.Unit;
                //deliveryNote.Status = dn.Status;
                deliveryNote.DNStatus = DNStatus.StatusInit;
                deliveryNote.DNFrom   = DNFrom.ERP;

                oldDeliveryNote = deliveryFacade.GetDeliveryNote(deliveryNote.DNCode, deliveryNote.DNLine);
                if (oldDeliveryNote == null)
                {
                    deliveryNote.RealQuantity = 0;
                    deliveryFacade.AddDeliveryNote(deliveryNote);
                }
                //else
                //{
                //    deliveryNote.RealQuantity = (oldDeliveryNote as DeliveryNote).RealQuantity;

                //    deliveryFacade.UpdateDeliveryNote(deliveryNote);
                //}
            }
        }
示例#4
0
        protected override void AddDomainObject(object domainObject)
        {
            if (_facade == null)
            {
                _facade = new InventoryFacade(this.DataProvider);
            }

            DNTempOut      dnTempOut      = domainObject as DNTempOut;
            DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);

            DeliveryNote deliveryNote = (DeliveryNote)deliveryFacade.GetDeliveryNote(dnTempOut.DNNO, dnTempOut.DNLine);

            if (deliveryNote == null)
            {
                WebInfoPublish.PublishInfo(this, "$ERROR_DNNO_And_DNLine_NOT_Exist", this.languageComponent1);
                return;
            }

            if (deliveryNote.DNStatus == DNStatus.StatusClose)
            {
                WebInfoPublish.PublishInfo(this, "$ERROR_DNNO_And_DNLine_Close", this.languageComponent1);
                return;
            }

            if (deliveryNote.ItemCode.Trim().ToUpper() != this.txtItemCodeQuery.Text.Trim().ToUpper())
            {
                WebInfoPublish.PublishInfo(this, "$ERROR_DNNO_And_DNLine_ItemCode", this.languageComponent1);
                return;
            }

            object getDNTempOut = _facade.GetDNTempOut(dnTempOut.StackCode, dnTempOut.ItemCode, dnTempOut.DNNO, dnTempOut.DNLine);

            if (getDNTempOut != null)
            {
                WebInfoPublish.PublishInfo(this, "$ERROR_DNNO_And_DNLine_Temped", this.languageComponent1);
                return;
            }

            _facade.AddDNTempOut(dnTempOut);

            //this.txtSAP_REPORTQTY.Text = Convert.ToString(int.Parse(this.txtCanUseredQtyQuery.Text.Trim()) - int.Parse(this.txtTempOutQtyEdit.Text.Trim()));

            this.RequestData();
        }
示例#5
0
        public ServiceResult Run(RunMethod runMethod)
        {
            /*====Get WebService URL and UserName and Password====*/
            SAPWebServiceEntity webServiceEntity = System.Configuration.ConfigurationManager.GetSection("DNConfirmConfig") as SAPWebServiceEntity;

            if (webServiceEntity == null)
            {
                return(new ServiceResult(false, "没有维护DNConfirm对应的Service地址", this.m_Argument.TransactionCode));
            }

            DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);

            #region Begin for Prepare input Paremeter

            DT_MES_DNPOST_REQ inputParameter = new DT_MES_DNPOST_REQ();

            if (runMethod == RunMethod.Auto)
            {
                this.NewTransactionCode();
                this.m_Argument.DNList.Clear();

                object[] deliveryNoteList = deliveryFacade.QueryDNNotConfirmed();
                if (deliveryNoteList != null)
                {
                    foreach (DeliveryNote deliveryNote in deliveryNoteList)
                    {
                        DT_MES_DNPOST post = new DT_MES_DNPOST();
                        post.VBELN   = deliveryNote.DNCode;
                        post.POSNR   = deliveryNote.DNLine;
                        post.MATNR   = deliveryNote.ItemCode;
                        post.G_LFIMG = deliveryNote.RealQuantity.ToString();
                        post.LGORT   = deliveryNote.SAPStorage;

                        this.m_Argument.DNList.Add(post);
                    }
                }
            }

            if (this.m_Argument.DNList == null || this.m_Argument.DNList.Count <= 0)
            {
                return(new ServiceResult(true, "", this.m_Argument.TransactionCode));
            }

            inputParameter.TRANS   = this.m_Argument.TransactionCode;
            inputParameter.DNPARAM = this.m_Argument.DNList.ToArray();

            #endregion

            string xmlFilePath = SerializeUtil.SerializeFile(this.m_Argument.TransactionCode + "_Request.xml",
                                                             typeof(DT_MES_DNPOST_REQ), inputParameter);

            #region TransferLog

            DBDateTime         requestDataTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
            SAPDataTransferLog transferLog     = new SAPDataTransferLog();
            TransferFacade     transferFacade  = new TransferFacade(this.DataProvider);

            transferLog.JobID               = TransferFacade.DNConfirmJobID;
            transferLog.TransactionCode     = this.m_Argument.TransactionCode;
            transferLog.TransactionSequence = 1;
            transferLog.RequestDate         = requestDataTime.DBDate;
            transferLog.RequestTime         = requestDataTime.DBTime;
            transferLog.RequestContent      = xmlFilePath;
            transferLog.OrganizationID      = 2000;
            transferLog.SendRecordCount     = 1;

            transferFacade.AddSAPDataTransferLog(transferLog);

            #endregion

            #region Begin for Calling WebService

            try
            {
                DNConfirmServiceClientProxy clientProxy = new DNConfirmServiceClientProxy();
                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_DNPOST_REQ(inputParameter);
                clientProxy.Dispose();
                clientProxy = null;
            }
            catch (Exception e)
            {
                transferLog.Result       = "Fail";
                transferLog.ErrorMessage = e.Message;
                transferFacade.UpdateSAPDataTransferLog(transferLog);
                return(new ServiceResult(false, e.Message, transferLog.TransactionCode));
            }

            #endregion

            #region Update tbldn

            try
            {
                this.DataProvider.BeginTransaction();
                foreach (DT_MES_DNPOST post in this.m_Argument.DNList)
                {
                    DeliveryNote deliveryNote = (DeliveryNote)deliveryFacade.GetDeliveryNote(post.VBELN, post.POSNR);
                    if (deliveryNote != null)
                    {
                        deliveryNote.Flag            = FlagStatus.FlagStatus_POST;
                        deliveryNote.TransactionCode = this.m_Argument.TransactionCode;
                        deliveryFacade.UpdateDeliveryNote(deliveryNote);
                    }
                }
                this.DataProvider.CommitTransaction();
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                return(new ServiceResult(false, ex.Message, this.m_Argument.TransactionCode));
            }

            #endregion

            return(new ServiceResult(true, "", this.m_Argument.TransactionCode));
        }