/// <summary> Adds pObjRecord. </summary>
        /// <remarks> Ranaya, 08/05/2017. </remarks>
        /// <param name="pObjRecord"> The Object record to add. </param>
        /// <returns> An int. </returns>

        public int Add(DestinationRequest pObjRecord)
        {
            int lIntResult = 0;

            //CREAR
            if (!mObjPermissionsDAO.ExistRequest(pObjRecord.RequestId))
            {
                lIntResult = mObjDestinationRequestDAO.Add(pObjRecord);

                if (lIntResult == 0)
                {
                    LogService.WriteSuccess("[DestinationRequest CREATED]");
                    if (mObjPermissionsDAO.IsRequestPreparedToCreateSaleOrder(pObjRecord.RequestId))
                    {
                        lIntResult = mObjPermissionsDAO.CreateSaleOrder(pObjRecord.RequestId);
                        if (lIntResult == 0)
                        {
                            LogService.WriteSuccess("[DestinationRequest SaleOrder CREATED]");
                        }
                    }
                }
                else
                {
                    LogService.WriteError("[DestinationRequest NO CREATED]");
                }
            }
            //EDITAR
            else
            {
                try
                {
                    pObjRecord.RowCode = mObjPermissionsDAO.GetRowCode("[@UG_PE_WS_DERE]", pObjRecord.RequestId);
                    lIntResult         = mObjDestinationRequestDAO.Update(pObjRecord);

                    if (lIntResult == 0)
                    {
                        LogService.WriteSuccess("[DestinationRequest UPDATE]");
                        lIntResult = mObjPermissionsDAO.UpdateSaleOrder(pObjRecord.RequestId);
                    }
                    else
                    {
                        LogService.WriteError("ERROR:[DestinationRequest UPDATE]");
                    }
                }
                catch (Exception ex)
                {
                    LogService.WriteError("ERROR:[DestinationRequest UPDATE] - " + ex.Message);
                }
            }

            return(lIntResult);
        }
Exemple #2
0
        /// <summary> Adds pObjRecord. </summary>
        /// <remarks> Ranaya, 08/05/2017. </remarks>
        /// <param name="pObjRecord"> The Object record to add. </param>
        /// <returns> An int. </returns>

        public int Add(PermissionRequest pObjRecord)
        {
            int    lIntResult = 0;
            string lStrPrefix = "";

            //CREAR
            if (!mObjPermissionsDAO.ExistsSaleOrder(pObjRecord.RequestId))
            {
                if (pObjRecord.MobilizationTypeId == 2)
                {
                    lStrPrefix = "SM";
                }
                else
                {
                    lStrPrefix = "SX";
                }

                pObjRecord.UgrsRequest = lStrPrefix;
                LogService.WriteError("[Prefix =" + lStrPrefix + "]");
                if (mObjPermissionsDAO.GetNextUgrsFolio(lStrPrefix) == 0)
                {
                    LogService.WriteError("[ERROR:NextUGRSFolio = 0]");
                }
                else
                {
                    pObjRecord.UgrsFolio = mObjPermissionsDAO.GetNextUgrsFolio(lStrPrefix);
                    LogService.WriteError("[UGRSFolio =" + pObjRecord.UgrsFolio + "]");
                    lIntResult = mObjPermissionRequestDAO.Add(pObjRecord);
                    LogService.WriteSuccess("[PermissionRequest CREATE]");
                    if (lIntResult == 0 && mObjPermissionsDAO.IsRequestPreparedToCreateSaleOrder(pObjRecord.RequestId))
                    {
                        lIntResult = mObjPermissionsDAO.CreateSaleOrder(pObjRecord.RequestId);
                    }
                }
            }
            //EDITAR
            else
            {
                try
                {
                    pObjRecord.RowCode   = mObjPermissionsDAO.GetRowCode("[@UG_PE_WS_PERE]", pObjRecord.RequestId);
                    pObjRecord.UgrsFolio = mObjPermissionsDAO.GetUgrsFolio(pObjRecord.RequestId);
                    lIntResult           = mObjPermissionRequestDAO.Update(pObjRecord);

                    if (lIntResult == 0)
                    {
                        LogService.WriteSuccess("[PermissionRequest UPDATE]");
                        lIntResult = mObjPermissionsDAO.UpdateSaleOrder(pObjRecord.RequestId);
                        if (lIntResult == 0)
                        {
                            LogService.WriteSuccess("[PermissionRequest SaleOrder UPDATE]");
                        }
                    }
                    else
                    {
                        LogService.WriteError("ERROR:[PermissionRequest UPDATE]");
                    }
                }
                catch (Exception ex)
                {
                    LogService.WriteError("ERROR:[PermissionRequest UPDATE] - " + ex.Message);
                }
            }

            return(lIntResult);
        }