Exemplo n.º 1
0
        protected override void UpdateDomainObject(object domainObject)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            DBDateTime   dateTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
            DeliveryNote deliveryNote = domainObject as DeliveryNote;

            try
            {
                string status = deliveryNote.DNStatus;
                if (status == DNStatus.StatusClose)
                {
                    throw new Exception(string.Format("$Disabled_Status_Colse_Update   $Current_DNCode:{0}    $Current_Status: {1}", deliveryNote.DNCode, this.languageComponent1.GetString(status)));
                }
                if (status == DNStatus.StatusUsing)
                {
                    throw new Exception(string.Format("$Disabled_Status_Using_Update   $Current_DNCode:{0}    $Current_Status: {1}", deliveryNote.DNCode, this.languageComponent1.GetString(status)));
                }

                deliveryNote.MaintainUser = this.GetUserCode();
                deliveryNote.MaintainDate = dateTime.DBDate;
                deliveryNote.MaintainTime = dateTime.DBTime;

                this.facade.UpdateDeliveryNote(deliveryNote);
            }
            catch (Exception ex)
            {
                ExceptionManager.Raise(this.GetType().BaseType, "$Error_Update_Domain_Object", ex);
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 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);
                //}
            }
        }
Exemplo n.º 4
0
 protected override int GetRowCount()
 {
     if (facade == null)
     {
         facade = new DeliveryFacade(this.DataProvider);
     }
     return(this.facade.QueryDNLineCount(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOQuery.Text)),
                GlobalVariables.CurrentOrganizations.First().OrganizationID));
 }
Exemplo n.º 5
0
 protected override object[] LoadDataSource(int inclusive, int exclusive)
 {
     if (facade == null)
     {
         facade = new DeliveryFacade(this.DataProvider);
     }
     return(facade.QueryDNLine(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOQuery.Text)),
                GlobalVariables.CurrentOrganizations.First().OrganizationID,
                inclusive, exclusive));
 }
Exemplo n.º 6
0
 protected override int GetRowCount()
 {
     if (facade == null)
     {
         facade = new DeliveryFacade(base.DataProvider);
     }
     return(this.facade.QueryDNCount(
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.drpBusinessCodeQuery.SelectedValue)),
                FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOQuery.Text)),
                FormatHelper.CleanString(this.drpDNStatus.SelectedValue),
                FormatHelper.CleanString(this.txtDeptQuery.Text),
                GlobalVariables.CurrentOrganizations.First().OrganizationID));
 }
Exemplo n.º 7
0
        private void UpdateStatus()
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(this.DataProvider);
            }

            ArrayList array = this.gridHelper.GetCheckedRows();

            if (array.Count > 0)
            {
                ArrayList  objs     = new ArrayList(array.Count);
                DBDateTime dateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);

                try
                {
                    foreach (GridRecord row in array)
                    {
                        object obj = this.GetEditObject(row);

                        if (((DeliveryNote)obj).DNStatus == DNStatus.StatusClose)
                        {
                            throw new Exception(string.Format("$Current_DNCode:{0}    $Current_Status: {1}", ((DeliveryNote)obj).DNCode, this.languageComponent1.GetString(((DeliveryNote)obj).DNStatus)));
                        }

                        object[] objDN = this.facade.GetDNForClose(((DeliveryNote)obj).DNCode);

                        if (objDN != null)
                        {
                            foreach (DeliveryNote deliveryNote in objDN)
                            {
                                deliveryNote.DNStatus     = DNStatus.StatusClose;
                                deliveryNote.MaintainUser = this.GetUserCode();
                                deliveryNote.MaintainDate = dateTime.DBDate;
                                deliveryNote.MaintainTime = dateTime.DBTime;

                                objs.Add(deliveryNote);
                            }
                        }
                    }
                    this.facade.DNClose((DeliveryNote[])objs.ToArray(typeof(DeliveryNote)));

                    this.gridHelper.RequestData();
                }
                catch (Exception ex)
                {
                    ExceptionManager.Raise(this.GetType().BaseType, "$Error_DeliveryNote_Close", ex);
                }
            }
        }
Exemplo n.º 8
0
        protected override object GetEditObject(GridRecord row)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }
            object obj = facade.GetDeliveryNote(row.Items.FindItemByKey("DNNO").Value.ToString(), "0");

            if (obj != null)
            {
                return((DeliveryNote)obj);
            }

            return(null);
        }
Exemplo n.º 9
0
        protected override object[] LoadDataSource(int inclusive, int exclusive)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            return(this.facade.QueryDN(
                       FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.drpBusinessCodeQuery.SelectedValue)),
                       FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOQuery.Text)),
                       FormatHelper.CleanString(this.drpDNStatus.SelectedValue),
                       FormatHelper.CleanString(this.txtDeptQuery.Text),
                       GlobalVariables.CurrentOrganizations.First().OrganizationID,
                       inclusive, exclusive));
        }
Exemplo n.º 10
0
        protected override object GetEditObject(GridRecord row)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(this.DataProvider);
            }
            object obj = this.facade.GetDeliveryNote(this.txtDNNOQuery.Text.Trim(), row.Items.FindItemByKey("DNLine").Text.Trim());

            if (obj != null)
            {
                return((DeliveryNote)obj);
            }

            return(null);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
        protected override void AddDomainObject(object domainObject)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            DeliveryNote deliveryNote = domainObject as DeliveryNote;

            object obj = this.facade.GetDeliveryNote(deliveryNote.DNCode, deliveryNote.DNLine);

            if (obj != null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Primary_Key_Overlap");
            }

            this.facade.AddDeliveryNote(deliveryNote);
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
0
        protected override void DeleteDomainObjects(ArrayList domainObjects)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            DeliveryNote[] deliveryNotes = (DeliveryNote[])domainObjects.ToArray(typeof(DeliveryNote));

            if (deliveryNotes != null)
            {
                this.DataProvider.BeginTransaction();

                try
                {
                    foreach (DeliveryNote deliveryNote in deliveryNotes)
                    {
                        if (deliveryNote.DNStatus == DNStatus.StatusInit)
                        {
                            this.facade.DeleteDeliveryNote(deliveryNote);
                        }
                        else
                        {
                            throw new Exception(string.Format("$Disabled_Status_Init_Delete   $Current_DNCode:{0}    $Current_Status: {1}", deliveryNote.DNCode, this.languageComponent1.GetString(deliveryNote.DNStatus)));
                        }
                    }

                    this.facade.UpdateDNHeadStatus(deliveryNotes[0].DNCode, this.GetUserCode());  //Add by sandy on 20130220

                    this.DataProvider.CommitTransaction();
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();

                    ExceptionManager.Raise(deliveryNotes[0].GetType(), "$Error_Delete_Domain_Object", ex);
                }
            }
        }
Exemplo n.º 15
0
        protected override void AddDomainObject(object domainObject)
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            DBDateTime   dateTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
            DeliveryNote deliveryNote = domainObject as DeliveryNote;

            object obj = this.facade.GetDeliveryNote(deliveryNote.DNCode, deliveryNote.DNLine);

            if (obj != null)
            {
                ExceptionManager.Raise(this.GetType(), "$Error_Primary_Key_Overlap");
            }

            deliveryNote.MaintainUser = this.GetUserCode();
            deliveryNote.MaintainDate = dateTime.DBDate;
            deliveryNote.MaintainTime = dateTime.DBTime;

            this.facade.AddDeliveryNote(deliveryNote);
        }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
0
        public void Receive(DNCONFIRM_REQ request)
        {
            ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = false;
            ((SQLDomainDataProvider)DataProvider).PersistBroker.OpenConnection();
            try
            {
                TransferFacade     transferFacade = new TransferFacade(this.DataProvider);
                SAPDataTransferLog log;
                DBDateTime         currentDateTime = FormatHelper.GetNowDBDateTime(this.DataProvider);
                string             xmlFilePath;
                if (request.TransactionCode == null || request.TransactionCode == string.Empty)
                {
                    // New Log
                    log = transferFacade.CreateNewSAPDataTransferLog();
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.JobID               = TransferFacade.InvertoryJobID;
                    log.OrganizationID      = 2000;
                    log.ReceivedRecordCount = (request.DNConfirmList == null || request.DNConfirmList.Count == 0) ? 0 : request.DNConfirmList.Count;
                    log.TransactionCode     = TransferFacade.DNConfirmJobID + "_"
                                              + currentDateTime.DBDate.ToString() + "_"
                                              + currentDateTime.DBTime.ToString()
                                              + DateTime.Now.Millisecond.ToString();
                    log.TransactionSequence = 1;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNCONFIRM_REQ), request);
                    log.RequestContent = xmlFilePath;
                    log.RequestDate    = currentDateTime.DBDate;
                    log.RequestTime    = currentDateTime.DBTime;
                    //log.Result
                    log.SendRecordCount = 0;
                    transferFacade.AddSAPDataTransferLog(log);

                    request.TransactionCode = log.TransactionCode;
                }
                else
                {
                    // Update log
                    log = transferFacade.GetSAPDataTransferLog(request.TransactionCode, 1) as SAPDataTransferLog;
                    //log.ErrorMessage
                    //log.FinishedDate
                    //log.FinishedTime
                    log.ReceivedRecordCount = (request.DNConfirmList == null || request.DNConfirmList.Count == 0) ? 0 : request.DNConfirmList.Count;
                    xmlFilePath             = SerializeUtil.SerializeFile(log.TransactionCode + "_Response.xml",
                                                                          typeof(DNCONFIRM_REQ), request);
                    log.ResponseContent = xmlFilePath;
                    log.ResponseDate    = currentDateTime.DBDate;
                    log.ResponseTime    = currentDateTime.DBTime;
                    //log.Result
                    transferFacade.UpdateSAPDataTransferLog(log);
                }

                this.DataProvider.BeginTransaction();
                try
                {
                    DeliveryFacade deliveryFacade = new DeliveryFacade(this.DataProvider);
                    DN2SAP         dn2sap;
                    foreach (MES_DNConfirm dnconfirm in request.DNConfirmList)
                    {
                        dn2sap              = deliveryFacade.CreateNewDN2SAP();
                        dn2sap.Active       = "Y";
                        dn2sap.DNCode       = dnconfirm.DNNo;
                        dn2sap.ErrorMessage = dnconfirm.Message;
                        dn2sap.Flag         = dnconfirm.Flag;
                        dn2sap.MaintainDate = currentDateTime.DBDate;
                        dn2sap.MaintainTime = currentDateTime.DBTime;
                        dn2sap.MaintainUser = "******";

                        deliveryFacade.UpdateDN2SAPStatusByDNNo(dn2sap.DNCode.ToUpper());

                        deliveryFacade.AddDN2SAP(dn2sap);

                        if (string.Compare(dnconfirm.Flag, "Y", true) == 0)  // Post OK
                        {
                            // Update tbldn.flag to SAP
                            deliveryFacade.UpdateDNFlag(dnconfirm.DNNo, FlagStatus.FlagStatus_SAP);
                        }
                    }

                    this.DataProvider.CommitTransaction();

                    log.Result       = "OK";
                    log.ErrorMessage = "";
                    currentDateTime  = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    log.FinishedDate = currentDateTime.DBDate;
                    log.FinishedTime = currentDateTime.DBTime;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
                catch (Exception ex)
                {
                    this.DataProvider.RollbackTransaction();

                    log.Result       = "Fail";
                    log.ErrorMessage = ex.Message;
                    log.FinishedDate = 0;
                    log.FinishedTime = 0;

                    transferFacade.UpdateSAPDataTransferLog(log);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ((SQLDomainDataProvider)DataProvider).PersistBroker.CloseConnection();
                ((SQLDomainDataProvider)DataProvider).PersistBroker.AutoCloseConnection = true;
            }
        }
Exemplo n.º 18
0
        //protected void drpItemGradeEdit_Load(object sender, System.EventArgs e)
        //{
        //    if (!IsPostBack)
        //    {
        //        DropDownListBuilder builder = new DropDownListBuilder(this.drpItemGradeEdit);

        //        SystemSettingFacade systemFacade = new SystemSettingFacade(this.DataProvider);

        //        object[] objList = systemFacade.GetParametersByParameterGroup("PRODUCTLEVEL");
        //        int i = 1;

        //        this.drpItemGradeEdit.Items.Insert(0, new ListItem(" ", " "));

        //        if (objList != null)
        //        {
        //            foreach (BenQGuru.eMES.Domain.BaseSetting.Parameter para in objList)
        //            {
        //                this.drpItemGradeEdit.Items.Insert(i, new ListItem(para.ParameterDescription, para.ParameterAlias));
        //                i++;
        //            }
        //        }

        //        this.drpItemGradeEdit.SelectedIndex = 0;

        //    }
        //}

        #endregion

        #region Object <--> Page

        protected override object GetEditObject()
        {
            if (facade == null)
            {
                facade = new DeliveryFacade(base.DataProvider);
            }

            InventoryFacade inventoryFacade = new InventoryFacade(this.DataProvider);

            DBDateTime   dateTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
            DeliveryNote deliveryNote = this.facade.CreateNewDN();

            object objDNLine = this.facade.GetDeliveryNote(this.txtDNNOQuery.Text.Trim(), this.txtDnLine.Text);

            if (objDNLine != null)
            {
                deliveryNote.DNLine = this.txtDnLine.Text;

                DeliveryNote deliveryNoteNew = objDNLine as DeliveryNote;

                deliveryNote.DNStatus = deliveryNoteNew.DNStatus;
            }
            else
            {
                //Add by Sandy 20130220
                object       objDNLineHead    = this.facade.GetDeliveryNote(this.txtDNNOQuery.Text.Trim(), "0");
                DeliveryNote deliveryNoteHead = objDNLineHead as DeliveryNote;

                string status = deliveryNoteHead.DNStatus;
                if (status == DNStatus.StatusClose)
                {
                    throw new Exception(string.Format("$Disabled_Status_Colse_Update   $Current_DNCode:{0}    $Current_Status: {1}", deliveryNote.DNCode, this.languageComponent1.GetString(status)));
                }

                object[] obj = facade.GetMaxDNLine(this.txtDNNOQuery.Text);

                if (obj != null)
                {
                    DeliveryNote dnLineMax = obj[0] as DeliveryNote;
                    string       dnLine    = dnLineMax.DNLine;

                    if (dnLine == "0")
                    {
                        deliveryNote.DNLine = "1";
                    }
                    else
                    {
                        int line = int.Parse(dnLine) + 1;

                        deliveryNote.DNLine = line.ToString();
                    }
                }

                deliveryNote.DNStatus = DNStatus.StatusInit;
            }

            deliveryNote.DNCode         = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtDNNOQuery.Text, 40));
            deliveryNote.ShipTo         = " ";
            deliveryNote.ItemCode       = FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtItemCodeEdit.Text, 40));
            deliveryNote.OrganizationID = GlobalVariables.CurrentOrganizations.First().OrganizationID;
            deliveryNote.FromStorage    = this.drpStorageCodeEdit.SelectedValue;

            Storage storage = (Storage)inventoryFacade.GetStorage(GlobalVariables.CurrentOrganizations.First().OrganizationID, this.drpStorageCodeEdit.SelectedValue);

            //if (storage != null)
            //{
            //    deliveryNote.SAPStorage = storage.SAPStorage;
            //}

            //if (this.drpItemGradeEdit.SelectedIndex == 0)
            //{
            //    deliveryNote.ItemGrade = this.drpItemGradeEdit.SelectedValue;
            //}
            //else
            //{
            //    deliveryNote.ItemGrade = FormatHelper.CleanString(this.drpItemGradeEdit.SelectedValue);
            //}
            deliveryNote.DNQuantity   = decimal.Parse(FormatHelper.CleanString(this.txtDNQuantityEdit.Text));
            deliveryNote.RealQuantity = 0;
            deliveryNote.Unit         = " ";
            //deliveryNote.ItemGrade = FormatHelper.CleanString(this.drpItemGradeEdit.SelectedValue);
            deliveryNote.MOCode              = FormatHelper.CleanString(this.txtMOCodeEdit.Text);
            deliveryNote.OrderNo             = FormatHelper.CleanString(this.txtOrderNoEdit.Text);
            deliveryNote.CustomerOrderNo     = " ";
            deliveryNote.CustomerOrderNoType = " ";
            deliveryNote.ToStorage           = " ";
            deliveryNote.MaintainUser        = this.GetUserCode();
            deliveryNote.MaintainDate        = dateTime.DBDate;
            deliveryNote.MaintainTime        = dateTime.DBTime;
            deliveryNote.DNFrom              = DNFrom.MES;

            deliveryNote.RelatedDocument = " ";
            deliveryNote.BusinessCode    = " ";
            deliveryNote.Dept            = " ";
            deliveryNote.Memo            = " ";
            deliveryNote.ReworkMOCode    = FormatHelper.CleanString(this.txtReworkMOEdit.Text);

            this.txtDnLine.Text = "";

            return(deliveryNote);
        }