Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Response.AppendHeader("Refresh", "10");

        this.lblMessage.Text                = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.SiteUnderMaintenanceCannotAccess);
        this.lblPersentCaption.Text         = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.PersentCaption) + " ";
        this.lblActionCaption.Text          = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.ActionCaption) + " ";
        this.lblAction.Text                 = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.ActionDatabaseUpdate);
        this.lblDatabaseNameCaption.Text    = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.DatabaseNameCaption) + " ";
        this.lblDatabaseVersionCaption.Text = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.DatabaseVersionCaption) + " ";
        this.lblSiteVersionCaption.Text     = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.SiteVersionCaption) + " ";
        this.lblQuestion.Text               = PXMessages.LocalizeNoPrefix(PX.Data.Update.Messages.Question) + " ";

        if (!PX.Data.Update.PXUpdateHelper.CheckUpdateLock() && PX.Data.Maintenance.PXSiteLockout.GetStatus() != PXSiteLockout.Status.Locked)
        {
            this.lblMessage.Text = PX.Data.PXMessages.Localize(PX.Data.InfoMessages.SiteMaintetanceComplite);
            PX.Data.Redirector.RedirectPage(this.Context, PXUrl.MainPagePath);
        }

        if (PXSiteLockout.GetStatus() == PXSiteLockout.Status.Locked)
        {
            this.lblMessage.Text += "<br/>" + string.Format(
                PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message);
        }

        PXUpdateStatusResult result = PXUpdateHelper.GetUpdateStatus();

        if ((result.ProcessStatus == PX.Data.PXLongRunStatus.InProcess))
        {
            if (result.UpdateStatus != null)
            {
                this.statusTable.Visible = true;
                this.lblPersent.Text     = result.UpdateStatus.Peresent.ToString() + "%";
                this.lblAction.Text      = PXMessages.LocalizeNoPrefix(result.UpdateStatus.Message);
            }
            if (result.UpdateQuetion != null)
            {
                this.questionTable.Visible   = true;
                this.lblQuestion.Text        = result.UpdateQuetion.Question;
                this.lblDatabaseVersion.Text = result.UpdateQuetion.DatabaseVersion;
                this.lblSiteVersion.Text     = result.UpdateQuetion.AssemblyVersion;

                if (!String.IsNullOrEmpty(result.UpdateQuetion.DatabaseName))
                {
                    this.applicationTable.Visible = true;
                    this.lblDatabaseName.Text     = result.UpdateQuetion.DatabaseName;
                }
            }
        }
        else
        {
            this.statusTable.Visible      = false;
            this.questionTable.Visible    = false;
            this.applicationTable.Visible = false;
        }
    }
        public string PXMessagesLocalizationSimpleMethods()
        {
            string localizedString;

            localizedString = PXMessages.Localize(MyMessages.CommasInUserName);
            localizedString = PXMessages.Localize(MyMessages.CommasInUserName, out string strPrefix);
            localizedString = PXMessages.LocalizeNoPrefix(MyMessages.CommasInUserName);

            return(localizedString);
        }
        public string PXMessagesSimple()
        {
            string localizedString;

            localizedString = PXMessages.Localize(InnerNamespace.NonLocalizableMessagesInNamespace.CommasInUserName);
            localizedString = PXMessages.Localize(NonLocalizableMessages.CommasInUserName, out string strPrefix);
            localizedString = PXMessages.LocalizeNoPrefix(NonLocalizableMessages.CommasInUserName);

            return(localizedString);
        }
        public string PXMessagesSimple()
        {
            string localizedString;

            localizedString = PXMessages.Localize("Usernames cannot contain commas.");
            localizedString = PXMessages.Localize("Usernames cannot contain commas.", out string strPrefix);
            localizedString = PXMessages.LocalizeNoPrefix("Usernames cannot contain commas.");

            return(localizedString);
        }
Example #5
0
 public virtual void SetMessage(string message)
 {
     if (MessagePrefix != null)
     {
         string strtemp = MessagePrefix + ':';
         int    idx     = message.IndexOf(strtemp);
         if (idx != -1)
         {
             message = message.Substring(message.IndexOf(strtemp) + strtemp.Length);
         }
     }
     _Message = PXMessages.Localize(message);
 }
Example #6
0
 public virtual void SetMessage(string message)
 {
     if (MessagePrefix != null)
     {
         string strtemp = string.Format("{0} #{1}:", MessagePrefix, ExceptionNumber);
         int    idx     = message.IndexOf(strtemp);
         if (idx != -1)
         {
             message = message.Substring(message.IndexOf(strtemp) + strtemp.Length);
         }
     }
     _Message = PXMessages.Localize(message);
 }
        protected virtual void ClearFSSODetReferences(PXGraph graph, POOrder poOrderRow)
        {
            try
            {
                PXUpdateJoin <
                    Set <FSServiceOrder.waitingForParts, Required <FSServiceOrder.waitingForParts> >,
                    FSServiceOrder,
                    InnerJoin <FSSODet,
                               On <
                                   FSSODet.sOID, Equal <FSServiceOrder.sOID> > >,
                    Where <
                        FSSODet.poType, Equal <Required <FSSODet.poType> >,
                        And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > >
                .Update(graph, 1, poOrderRow.OrderType, poOrderRow.OrderNbr);

                PXUpdateJoin <
                    Set <FSAppointment.waitingForParts, Required <FSAppointment.waitingForParts> >,
                    FSAppointment,
                    InnerJoin <FSAppointmentDet,
                               On <
                                   FSAppointmentDet.appointmentID, Equal <FSAppointment.appointmentID> >,
                               InnerJoin <FSSODet,
                                          On <
                                              FSSODet.sODetID, Equal <FSAppointmentDet.sODetID> > > >,
                    Where <
                        FSSODet.poType, Equal <Required <FSSODet.poType> >,
                        And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > >
                .Update(graph, 1, poOrderRow.OrderType, poOrderRow.OrderNbr);

                PXUpdate <
                    Set <FSSODet.poNbr, Required <FSSODet.poNbr>,
                         Set <FSSODet.poStatus, Required <FSSODet.poStatus>,
                              Set <FSSODet.poCompleted, Required <FSSODet.poCompleted> > > >,
                    FSSODet,
                    Where <
                        FSSODet.poType, Equal <Required <FSSODet.poType> >,
                        And <FSSODet.poNbr, Equal <Required <FSSODet.poNbr> > > > >
                .Update(graph, null, null, null, poOrderRow.OrderType, poOrderRow.OrderNbr);
            }
            catch (Exception exception)
            {
                throw new PXException(PXMessages.Localize(TX.Error.UPDATING_FSSODET_PO_REFERENCES) + exception.Message);
            }
        }
Example #8
0
        public string All()
        {
            string localizedString;
            object parameter = new object();

            localizedString = PXLocalizer.Localize(MyMessages.CommasInUserName + MyMessages.SomeString);
            localizedString = PXLocalizer.Localize(string.Format(MyMessages.StringToFormat, parameter), typeof(MyMessages).FullName);
            localizedString = PXLocalizer.LocalizeFormat(String.Concat(MyMessages.CommasInUserName, MyMessages.SomeString), parameter);

            localizedString = PXMessages.Localize(MyMessages.CommasInUserName + "123");
            localizedString = PXMessages.Localize(string.Format(MyMessages.StringToFormat, 123), out string strPrefix);
            localizedString = PXMessages.LocalizeNoPrefix(string.Concat(MyMessages.CommasInUserName, "123"));

            localizedString = PXMessages.LocalizeFormat(MyMessages.StringToFormat + "456", parameter);
            localizedString = PXMessages.LocalizeFormat(string.Format(MyMessages.StringToFormat, parameter), out string prefix, parameter);
            localizedString = PXMessages.LocalizeFormatNoPrefix(string.Concat(MyMessages.StringToFormat, "456"), parameter);
            localizedString = PXMessages.LocalizeFormatNoPrefixNLA(string.Concat(MyMessages.StringToFormat, "456", "789"), parameter);

            return(localizedString);
        }
Example #9
0
        public void Notify(PXGraph graph, string siteCD)
        {
            if (AllInventory && AllLocations)
            {
                PXTrace.WriteError(PXMessages.Localize(Messages.PIFullCollisionDetails), PIID, siteCD);
                return;
            }

            if (AllLocations)
            {
                PXTrace.WriteError(
                    PXMessages.Localize(Messages.PIAllLocationsCollisionDetails),
                    PIID,
                    siteCD,
                    string.Join(", ", ReadIdsToString(graph, InventoryItemIds, ReadInventoryCds)));

                return;
            }

            if (AllInventory)
            {
                PXTrace.WriteError(
                    PXMessages.Localize(Messages.PIAllInventoryCollisionDetails),
                    PIID,
                    siteCD,
                    string.Join(", ", ReadIdsToString(graph, LocationIds, ReadLocationCds)));

                return;
            }

            PXTrace.WriteError(
                PXMessages.Localize(Messages.PICollisionDetails),
                PIID,
                siteCD,
                string.Join(", ", ReadIdsToString(graph, InventoryItemIds, ReadInventoryCds)),
                string.Join(", ", ReadIdsToString(graph, LocationIds, ReadLocationCds)));
        }
        /// <summary>
        /// Generates Appointments (Routes Contract) or Service Orders (Service Contract) for each TimeSlot in the [scheduleRules] List.
        /// </summary>
        public void GenerateAPPSOUpdateContracts(List <Schedule> scheduleRules, string recordType, DateTime?fromDate, DateTime?toDate, FSSchedule fsScheduleRow)
        {
            var      generator      = new TimeSlotGenerator();
            DateTime processEndDate = (DateTime)GetProcessEndDate(scheduleRules.ElementAt(0), toDate);

            var period = new Period((DateTime)fromDate, processEndDate);

            // Determines the next generationID number
            if (nextGenerationID == null)
            {
                FSProcessIdentity fsProcessIdentityRow = new FSProcessIdentity();
                fsProcessIdentityRow.ProcessType  = recordType;
                fsProcessIdentityRow.FilterFromTo = fromDate;
                fsProcessIdentityRow.FilterUpTo   = toDate;

                ProcessIdentityMaint graphProcessIdentityMaint = PXGraph.CreateInstance <ProcessIdentityMaint>();
                graphProcessIdentityMaint.processIdentityRecords.Insert(fsProcessIdentityRow);
                graphProcessIdentityMaint.Save.Press();

                nextGenerationID = graphProcessIdentityMaint.processIdentityRecords.Current.ProcessID;
            }

            List <TimeSlot> timeSlots   = generator.GenerateCalendar(period, scheduleRules, nextGenerationID);
            DateTime?       failsOnDate = null;

            // Transaction to create the appointments (Routes Contract) or Service Orders (Service Contract)
            using (PXTransactionScope ts = new PXTransactionScope())
            {
                Customer customerRow = PXSelect <Customer,
                                                 Where <
                                                     Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >
                                       .Select(this, fsScheduleRow.CustomerID)
                                       .FirstOrDefault();

                if (customerRow.Status != BAccount.status.Active && customerRow.Status != BAccount.status.OneTime)
                {
                    throw new PXException(PXMessages.LocalizeFormat(AR.Messages.CustomerIsInStatus, new Customer.status.ListAttribute().ValueLabelDic[customerRow.Status]));
                }

                try
                {
                    foreach (var timeSlot in timeSlots)
                    {
                        failsOnDate = timeSlot.DateTimeBegin;

                        if (recordType == ID.RecordType_ServiceContract.SERVICE_CONTRACT)
                        {
                            bool createAppointmnet = fsScheduleRow.ScheduleGenType == ID.ScheduleGenType_ServiceContract.APPOINTMENT;

                            CreateServiceOrder(timeSlot, createAppointmnet);
                        }
                        else if (recordType == ID.RecordType_ServiceContract.ROUTE_SERVICE_CONTRACT)
                        {
                            CreateServiceOrder(timeSlot, true, true);
                        }
                    }

                    DateTime?lastGenerationDate = null;

                    if (timeSlots.Count > 0)
                    {
                        lastGenerationDate = timeSlots.Max(a => a.DateTimeBegin);
                    }

                    CreateContractGenerationHistory((int)nextGenerationID,
                                                    scheduleRules.ElementAt(0).ScheduleID,
                                                    processEndDate,
                                                    lastGenerationDate,
                                                    recordType);

                    UpdateGeneratedSchedule(scheduleRules.ElementAt(0).ScheduleID, processEndDate, lastGenerationDate, fsScheduleRow);
                }
                catch (Exception e)
                {
                    var exceptionWithContextMessage = ExceptionHelper.GetExceptionWithContextMessage(PXMessages.Localize(TX.Messages.COULD_NOT_PROCESS_RECORD), e);

                    FSGenerationLogError fsGenerationLogErrorRow = new FSGenerationLogError();
                    fsGenerationLogErrorRow.ProcessType  = recordType;
                    fsGenerationLogErrorRow.ErrorMessage = exceptionWithContextMessage.Message;
                    fsGenerationLogErrorRow.ScheduleID   = scheduleRules.ElementAt(0).ScheduleID;
                    fsGenerationLogErrorRow.GenerationID = nextGenerationID;
                    fsGenerationLogErrorRow.ErrorDate    = failsOnDate;

                    ts.Dispose();

                    var grapGenerationLogErrorMaint = PXGraph.CreateInstance <GenerationLogErrorMaint>();

                    grapGenerationLogErrorMaint.LogErrorMessageRecords.Insert(fsGenerationLogErrorRow);
                    grapGenerationLogErrorMaint.Save.Press();
                    throw exceptionWithContextMessage;
                }

                ts.Complete(this);
            }
        }
Example #11
0
 protected override string CreateEditPreventingReason(GetEditPreventingReasonArgs arg, object firstPreventingEntity, string fieldName, string currentTableName, string foreignTableName)
 => PXMessages.Localize(Messages.ItemLotSerClassVerifying);
Example #12
0
    /// <summary>
    ///
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (cmbLang.SelectedValue != null)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cmbLang.SelectedValue);
            btnLogin.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.SignIn);
            txtUser.Attributes["placeholder"]            = PXMessages.LocalizeNoPrefix(Msg.LoginPageUserName);
            txtPass.Attributes["placeholder"]            = PXMessages.LocalizeNoPrefix(Msg.LoginPagePassword);
            txtNewPassword.Attributes["placeholder"]     = PXMessages.LocalizeNoPrefix(Msg.LoginPageNewPassword);
            txtConfirmPassword.Attributes["placeholder"] = PXMessages.LocalizeNoPrefix(Msg.LoginPageConfirmPassword);
            lnkForgotPswd.Text = PXMessages.LocalizeNoPrefix(Msg.LoginPageForgotCredentials);
        }

        lbl2FactorCap.Text    = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.TwoFactorAuth);
        lbl2FactorMethod.Text = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.TwoFactorSelectMethod);
        rememberDevice.Text   = PXMessages.LocalizeNoPrefix(PX.AscxControlsMessages.LoginScreen.RememberDevice);


        if (PX.Data.Update.PXUpdateHelper.CheckUpdateLock())
        {
            throw new PXUnderMaintenanceException();
        }

        var lockoutStatus = PXSiteLockout.GetStatus(true);

        if (lockoutStatus == PXSiteLockout.Status.Locked)
        {
            lblUnderMaintenance.Text    = PXMessages.Localize(PX.Data.Update.Messages.SiteUnderMaintenance);
            lblUnderMaintenance.Visible = true;

            if (!string.IsNullOrWhiteSpace(PXSiteLockout.Message))
            {
                lblUnderMaintenanceReason.Text = string.Format(
                    PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message);
                lblUnderMaintenanceReason.Visible = true;
            }
        }

        if (lockoutStatus == PXSiteLockout.Status.Pending)
        {
            string datetime = string.Format("{0} ({1} UTC)", PXSiteLockout.DateTime, PXSiteLockout.DateTimeUtc);
            lblUnderMaintenance.Text = string.Format(
                PXMessages.Localize(PX.Data.Update.Messages.PendingLockout),

                datetime, PXSiteLockout.Message);
            lblUnderMaintenance.Visible = true;
        }

        if (GetPostBackControl(this.Page) == cmbCompany || GetPostBackControl(this.Page) == cmbLang)
        {
            txtPass.Attributes.Add("value", txtPass.Text);
        }

        if (GetPostBackControl(this.Page) == btnLogin && !String.IsNullOrEmpty(txtDummyCpny.Value))
        {
            cmbCompany.SelectedValue = txtDummyCpny.Value;
        }

        if (string.IsNullOrWhiteSpace(MultiFactorPipelineNotStarted.Value))
        {
            MultiFactorPipelineNotStarted.Value = "true";
        }

        // if user already set password then we should disabling login and password
        if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
        {
            txtPass.Text = txtVeryDummyPass.Value;
            DisablingUserPassword();
            if (!MultiCompaniesSecure)
            {
                EnablingChangingPassword();
            }
        }

        // if (SecureCompanyID) then we should hide combobox before first login.
        // and also we should shrink companies list
        if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider))
        {
            this.cmbCompany.Visible = !String.IsNullOrEmpty(txtVeryDummyPass.Value);

            if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
            {
                List <String> companyFilter = new List <String>(PXAccess.GetCompanies(txtUser.Text, txtVeryDummyPass.Value));
                for (int i = cmbCompany.Items.Count - 1; i >= 0; i--)
                {
                    ListItem item = cmbCompany.Items[i];
                    if (!companyFilter.Contains(item.Value))
                    {
                        cmbCompany.Items.RemoveAt(i);
                    }
                }
            }
        }

        // Is user trying to recover his password using link from Email?
        if (Request.QueryString.AllKeys.Length > 0 && Request.QueryString.GetValues("gk") != null)
        {
            RemindUserPassword();
        }
        try
        {
            this.SetInfoText();
        }
        catch { /*SKIP ERROS*/ }
        this.idStorage.Value = seed;
        //try silent login
        btnLoginSilent_Click(sender, e);
    }
Example #13
0
    /// <summary>
    ///
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (PX.Data.Update.PXUpdateHelper.CheckUpdateLock())
        {
            throw new PXUnderMaintenanceException();
        }

        var lockoutStatus = PXSiteLockout.GetStatus(true);

        if (lockoutStatus == PXSiteLockout.Status.Locked)
        {
            lblUnderMaintenance.Text    = PXMessages.Localize(PX.Data.Update.Messages.SiteUnderMaintenance);
            lblUnderMaintenance.Visible = true;

            if (!string.IsNullOrWhiteSpace(PXSiteLockout.Message))
            {
                lblUnderMaintenanceReason.Text = string.Format(
                    PXMessages.Localize(PX.Data.Update.Messages.LockoutReason), PXSiteLockout.Message);
                lblUnderMaintenanceReason.Visible = true;
            }
        }

        if (lockoutStatus == PXSiteLockout.Status.Pending)
        {
            string datetime = string.Format("{0} ({1} UTC)", PXSiteLockout.DateTime, PXSiteLockout.DateTimeUtc);
            lblUnderMaintenance.Text = string.Format(
                PXMessages.Localize(PX.Data.Update.Messages.PendingLockout),

                datetime, PXSiteLockout.Message);
            lblUnderMaintenance.Visible = true;
        }

        if (GetPostBackControl(this.Page) == cmbCompany)
        {
            txtPass.Attributes.Add("value", txtPass.Text);
        }

        if (GetPostBackControl(this.Page) == btnLogin && !String.IsNullOrEmpty(txtDummyCpny.Value))
        {
            cmbCompany.SelectedValue = txtDummyCpny.Value;
        }

        // if user already set password then we should disabling login and password
        if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
        {
            txtPass.Text = txtVeryDummyPass.Value;
            DisablingUserPassword();
            if (!MultiCompaniesSecure)
            {
                EnablingChangingPassword();
            }
        }

        // if (SecureCompanyID) then we should hide combobox before first login.
        // and also we should shrink companies list
        if (PXDatabase.SecureCompanyID && (Membership.Provider is PXBaseMembershipProvider))
        {
            this.cmbCompany.Visible = !String.IsNullOrEmpty(txtVeryDummyPass.Value);

            if (!String.IsNullOrEmpty(txtVeryDummyPass.Value))
            {
                List <String> companyFilter = new List <String>(PXAccess.GetCompanies(txtUser.Text, txtVeryDummyPass.Value));
                for (int i = cmbCompany.Items.Count - 1; i >= 0; i--)
                {
                    ListItem item = cmbCompany.Items[i];
                    if (!companyFilter.Contains(item.Value))
                    {
                        cmbCompany.Items.RemoveAt(i);
                    }
                }
            }
        }

        // Is user trying to recover his password using link from Email?
        if (Request.QueryString.AllKeys.Length > 0 && Request.QueryString.GetValues("gk") != null)
        {
            RemindUserPassword();
        }
        try
        {
            this.SetInfoText();
        }
        catch { /*SKIP ERROS*/ }
        this.idStorage.Value = seed;
        //try silent login
        btnLoginSilent_Click(sender, e);
    }
Example #14
0
        private static void ClaimDetail(List <EPExpenseClaimDetails> details, bool isApiContext, bool singleOperation)
        {
            ExpenseClaimEntry expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
            PXSetup <EPSetup> epsetup           = new PXSetup <EPSetup>(PXGraph.CreateInstance(typeof(ExpenseClaimDetailEntry)));
            bool enabledApprovalReceipt         = PXAccess.FeatureInstalled <FeaturesSet.approvalWorkflow>() && epsetup.Current.ClaimDetailsAssignmentMapID != null;
            bool isError        = false;
            bool notAllApproved = false;
            Dictionary <string, EPExpenseClaim> result = new Dictionary <string, EPExpenseClaim>();

            IEnumerable <Receipts> List;

            if (epsetup.Current.AllowMixedTaxSettingInClaims == true)
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                    ClaimCuryID = GetClaimCuryID(expenseClaimEntry, item)
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    claimCuryID      = key.ClaimCuryID,
                    details          = item
                }
                    );
            }
            else
            {
                List = details.Where(item => string.IsNullOrEmpty(item.RefNbr)).OrderBy(detail => detail.ClaimDetailID).GroupBy(
                    item => new
                {
                    item.EmployeeID,
                    item.BranchID,
                    item.CustomerID,
                    item.CustomerLocationID,
                    item.TaxZoneID,
                    item.TaxCalcMode,
                    ClaimCuryID = GetClaimCuryID(expenseClaimEntry, item)
                },
                    (key, item) => new Receipts
                {
                    employee         = key.EmployeeID,
                    branch           = key.BranchID,
                    customer         = key.CustomerID,
                    customerLocation = key.CustomerLocationID,
                    claimCuryID      = key.ClaimCuryID,
                    details          = item
                }
                    );
            }

            string errorMessage = null;

            foreach (Receipts item in List)
            {
                isError        = false;
                notAllApproved = false;
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    expenseClaimEntry.Clear();
                    expenseClaimEntry.SelectTimeStamp();
                    EPExpenseClaim expenseClaim = (EPExpenseClaim)expenseClaimEntry.ExpenseClaim.Cache.CreateInstance();
                    expenseClaim.EmployeeID         = item.employee;
                    expenseClaim.BranchID           = item.branch;
                    expenseClaim.CustomerID         = item.customer;
                    expenseClaim.DocDesc            = EP.Messages.SubmittedReceipt;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CuryID             = item.claimCuryID;
                    expenseClaim                    = expenseClaimEntry.ExpenseClaim.Update(expenseClaim);
                    expenseClaim.CustomerLocationID = item.customerLocation;
                    expenseClaim.TaxCalcMode        = item.details.First().TaxCalcMode;
                    expenseClaim.TaxZoneID          = item.details.First().TaxZoneID;

                    foreach (EPExpenseClaimDetails detail in item.details)
                    {
                        PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(detail);

                        if (detail.Approved ?? false)
                        {
                            try
                            {
                                if (detail.IsPaidWithCard)
                                {
                                    EPEmployee employee =
                                        PXSelect <EPEmployee,
                                                  Where <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > >
                                        .Select(expenseClaimEntry, item.employee);

                                    if (employee.AllowOverrideCury != true && detail.CardCuryID != employee.CuryID)
                                    {
                                        errorMessage = PXMessages.Localize(Messages.ClaimCannotBeCreatedForReceiptBecauseCuryCannotBeOverriden);

                                        isError = true;
                                    }
                                }

                                if (!isError && detail.TipAmt != 0 && epsetup.Current.NonTaxableTipItem == null)
                                {
                                    errorMessage = Messages.TipItemIsNotDefined;
                                    isError      = true;
                                }

                                if (!isError)
                                {
                                    expenseClaimEntry.ReceiptEntryExt.SubmitReceiptExt(expenseClaimEntry.ExpenseClaim.Cache,
                                                                                       expenseClaimEntry.ExpenseClaimDetails.Cache, expenseClaimEntry.ExpenseClaim.Current, detail);

                                    expenseClaimEntry.Save.Press();
                                    if (!result.ContainsKey(expenseClaim.RefNbr))
                                    {
                                        result.Add(expenseClaim.RefNbr, expenseClaim);
                                    }
                                    detail.RefNbr = expenseClaim.RefNbr;

                                    PXProcessing <EPExpenseClaimDetails> .SetProcessed();
                                }
                            }
                            catch (Exception ex)
                            {
                                errorMessage = ex.Message;
                                isError      = true;
                            }
                        }
                        else
                        {
                            errorMessage = enabledApprovalReceipt
                                                                ? Messages.ReceiptNotApproved
                                                                : Messages.ReceiptTakenOffHold;

                            notAllApproved = true;
                        }

                        if (errorMessage != null)
                        {
                            PXProcessing <EPExpenseClaimDetails> .SetError(errorMessage);
                        }
                    }
                    if (!isError)
                    {
                        ts.Complete();
                    }
                }
            }

            if (!isError && !notAllApproved)
            {
                if (result.Count == 1 && isApiContext == false)
                {
                    expenseClaimEntry = CreateInstance <ExpenseClaimEntry>();
                    PXRedirectHelper.TryRedirect(expenseClaimEntry, result.First().Value, PXRedirectHelper.WindowMode.InlineWindow);
                }
            }
            else
            {
                PXProcessing <EPExpenseClaimDetails> .SetCurrentItem(null);

                if (singleOperation)
                {
                    throw new PXException(errorMessage);
                }
                else
                {
                    throw new PXException(Messages.ErrorProcessingReceipts);
                }
            }
        }
            public static PXFieldState CreateFieldState(string fieldName, string description, int ctype, string entryMask, string list)
            {
                uint   msgnum;
                string msgprefix;
                string displayName = string.Format("${0}$-{1}", PXMessages.Localize(ActionsMessages.Attributes, out msgnum, out msgprefix),
                                                   description);
                PXFieldState fs = null;

                switch (ctype)
                {
                case 1:
                {
                    fs             = PXStringState.CreateInstance(null, null, null, fieldName, null, null, entryMask, null, null, null, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    break;
                }

                case 2:
                case 6:
                {
                    List <string> vals = new List <string>();
                    List <string> lbls = new List <string>();
                    if (!String.IsNullOrEmpty(list))
                    {
                        foreach (string elem in list.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            string[] pair = elem.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
                            if (pair.Length > 0)
                            {
                                vals.Add(pair[0]);
                                if (pair.Length > 1)
                                {
                                    lbls.Add(pair[1]);
                                }
                                else
                                {
                                    lbls.Add(pair[0]);
                                }
                            }
                        }
                    }
                    fs             = PXStringState.CreateInstance(null, null, null, fieldName, null, null, null, vals.ToArray(), lbls.ToArray(), true, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    if (ctype == 6)
                    {
                        ((PXStringState)fs).MultiSelect = true;
                    }
                    break;
                }

                case 4:
                {
                    fs = PXFieldState.CreateInstance(null, typeof(Boolean), null, null, -1, null, null, null, fieldName, null, displayName, null, PXErrorLevel.Undefined, false, false, null, PXUIVisibility.Dynamic, null, null, null);
                    break;
                }

                case 5:
                {
                    fs             = PXDateState.CreateInstance(null, fieldName, null, null, "d", "d", null, null);
                    fs.Visibility  = PXUIVisibility.Dynamic;
                    fs.DisplayName = displayName;
                    fs.Enabled     = false;
                    fs.Visible     = false;
                    break;
                }
                }
                return(fs);
            }
        public virtual FSContractPostDoc CreateInvoiceByContract(PXGraph graphProcess, DateTime?invoiceDate, string invoiceFinPeriodID, FSContractPostBatch fsContractPostBatchRow, FSServiceContract fsServiceContractRow, FSContractPeriod fsContractPeriodRow, List <ContractInvoiceLine> docLines)
        {
            if (docLines.Count == 0)
            {
                return(null);
            }

            FSSetup fsSetupRow = ServiceManagementSetup.GetServiceManagementSetup(graphProcess);

            ARInvoice arInvoiceRow = new ARInvoice();

            arInvoiceRow.DocType = ARInvoiceType.Invoice;

            arInvoiceRow.DocDate     = invoiceDate;
            arInvoiceRow.FinPeriodID = invoiceFinPeriodID;
            arInvoiceRow.Hold        = true;
            arInvoiceRow             = Base.Document.Insert(arInvoiceRow);

            Base.Document.Cache.SetValueExt <ARInvoice.customerID>(arInvoiceRow, fsServiceContractRow.BillCustomerID);
            Base.Document.Cache.SetValueExt <ARInvoice.customerLocationID>(arInvoiceRow, fsServiceContractRow.BillLocationID);
            Base.Document.Cache.SetValueExt <ARInvoice.branchID>(arInvoiceRow, fsServiceContractRow.BranchID);
            Base.Document.Cache.SetValueExt <ARInvoice.docDesc>(arInvoiceRow, "Contract Standardized Billing: " + fsServiceContractRow.RefNbr + " " + fsServiceContractRow.DocDesc);

            string termsID = InvoicingFunctions.GetTermsIDFromCustomerOrVendor(graphProcess, fsServiceContractRow.BillCustomerID, null);

            if (termsID != null)
            {
                Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, termsID);
            }
            else
            {
                Base.Document.Cache.SetValueExt <ARInvoice.termsID>(arInvoiceRow, fsSetupRow.DfltContractTermIDARSO);
            }

            ARTran    arTranRow    = null;
            FSxARTran fsxARTranRow = null;
            int?      acctID;

            foreach (ContractInvoiceLine docLine in docLines)
            {
                arTranRow = new ARTran();
                arTranRow = Base.Transactions.Insert(arTranRow);

                Base.Transactions.Cache.SetValueExt <ARTran.inventoryID>(arTranRow, docLine.InventoryID);
                Base.Transactions.Cache.SetValueExt <ARTran.uOM>(arTranRow, docLine.UOM);
                Base.Transactions.Cache.SetValueExt <ARTran.salesPersonID>(arTranRow, docLine.SalesPersonID);

                arTranRow = Base.Transactions.Update(arTranRow);

                if (docLine.AcctID != null)
                {
                    acctID = docLine.AcctID;
                }
                else
                {
                    acctID = (int?)ServiceOrderCore.Get_INItemAcctID_DefaultValue(
                        graphProcess,
                        fsSetupRow.ContractSalesAcctSource,
                        docLine.InventoryID,
                        fsServiceContractRow);
                }

                Base.Transactions.Cache.SetValueExt <ARTran.accountID>(arTranRow, acctID);

                if (docLine.SubID != null)
                {
                    try
                    {
                        Base.Transactions.Cache.SetValueExt <ARTran.subID>(arTranRow, docLine.SubID);
                    }
                    catch (PXException)
                    {
                        arTranRow.SubID = null;
                    }
                }
                else
                {
                    InvoicingFunctions.SetCombinedSubID(
                        graphProcess,
                        Base.Transactions.Cache,
                        arTranRow,
                        null,
                        null,
                        fsSetupRow,
                        arTranRow.BranchID,
                        arTranRow.InventoryID,
                        arInvoiceRow.CustomerLocationID,
                        fsServiceContractRow.BranchLocationID);
                }

                Base.Transactions.Cache.SetValueExt <ARTran.qty>(arTranRow, docLine.Qty);

                Base.Transactions.Cache.SetValueExt <ARTran.curyUnitPrice>(arTranRow, docLine.CuryUnitPrice);

                Base.Transactions.Cache.SetValueExt <ARTran.tranDesc>(arTranRow, docLine.TranDescPrefix + arTranRow.TranDesc);

                arTranRow = Base.Transactions.Update(arTranRow);

                Base.Transactions.Cache.SetValueExt <ARTran.commissionable>(arTranRow, docLine.Commissionable ?? false);

                fsxARTranRow = Base.Transactions.Cache.GetExtension <FSxARTran>(arTranRow);

                fsxARTranRow.Source             = ID.Billing_By.CONTRACT;
                fsxARTranRow.ServiceContractID  = fsServiceContractRow.ServiceContractID;
                fsxARTranRow.ContractPeriodID   = fsContractPeriodRow.ContractPeriodID;
                fsxARTranRow.BillCustomerID     = fsServiceContractRow.BillCustomerID;
                fsxARTranRow.CustomerLocationID = fsServiceContractRow.BillLocationID;

                arTranRow = Base.Transactions.Update(arTranRow);
            }

            if (Base.ARSetup.Current.RequireControlTotal == true)
            {
                Base.Document.Cache.SetValueExt <ARInvoice.curyOrigDocAmt>(arInvoiceRow, arInvoiceRow.CuryDocBal);
            }

            Base.Document.Cache.SetValueExt <ARInvoice.hold>(arInvoiceRow, false);

            Exception newException = null;

            try
            {
                Base.Save.Press();
            }
            catch (Exception e)
            {
                List <ErrorInfo> errorList = this.GetErrorInfo();

                var exceptionWithContextMessage = ExceptionHelper.GetExceptionWithContextMessage(
                    PXMessages.Localize(TX.Messages.ERROR_CREATING_INVOICE_IN_POSTING_BATCH),
                    e);

                newException = InvoicingFunctions.GetErrorInfoInLines(errorList, exceptionWithContextMessage);
            }

            if (newException != null)
            {
                throw newException;
            }

            arInvoiceRow = Base.Document.Current;

            FSContractPostDoc fsContractCreatedDocRow = new FSContractPostDoc()
            {
                ContractPeriodID    = fsContractPeriodRow.ContractPeriodID,
                ContractPostBatchID = fsContractPostBatchRow.ContractPostBatchID,
                PostDocType         = arInvoiceRow.DocType,
                PostedTO            = ID.Batch_PostTo.AR,
                PostRefNbr          = arInvoiceRow.RefNbr,
                ServiceContractID   = fsServiceContractRow.ServiceContractID
            };

            return(fsContractCreatedDocRow);
        }
        /// <summary>
        /// Creates one or more documents in Inventory depending of the number of FSAppointmentInventoryItem in the list [fsAppointmentInventoryItemRows].
        /// </summary>
        public virtual int CreateDocumentsInIN(FSPostBatch fsPostBatchRow, List <FSAppointmentDet> fsAppointmentInventoryItemRows, List <SharedClasses.AppointmentInventoryItemGroup> listGroupToUpdateInInventory, UpdateInventoryFilter filter)
        {
            INReceiptEntry graphINReceiptEntry = PXGraph.CreateInstance <INReceiptEntry>();
            INIssueEntry   graphINIssueEntry   = PXGraph.CreateInstance <INIssueEntry>();
            int            linesPosted         = 0;

            foreach (SharedClasses.AppointmentInventoryItemGroup groupToUpdateInInventory in listGroupToUpdateInInventory)
            {
                string iNRefNbr  = null;
                string iNDocType = null;

                foreach (SharedClasses.AppointmentInventoryItemInfo appointmentInventoryItemInfoRow in groupToUpdateInInventory.AppointmentInventoryItems)
                {
                    using (var ts_GroupToUpdateInInventory = new PXTransactionScope())
                    {
                        try
                        {
                            if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.PICKED_UP_ITEMS)
                            {
                                // create receipt
                                CreateDocumentReceipt(graphINReceiptEntry,
                                                      appointmentInventoryItemInfoRow,
                                                      fsAppointmentInventoryItemRows[appointmentInventoryItemInfoRow.Index],
                                                      filter.DocumentDate,
                                                      filter.FinPeriodID,
                                                      fsPostBatchRow,
                                                      ref iNRefNbr,
                                                      ref iNDocType);
                            }
                            else if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.DELIVERED_ITEMS)
                            {
                                // create issue
                                CreateDocumentIssue(graphINIssueEntry,
                                                    appointmentInventoryItemInfoRow,
                                                    fsAppointmentInventoryItemRows[appointmentInventoryItemInfoRow.Index],
                                                    filter.DocumentDate,
                                                    filter.FinPeriodID,
                                                    fsPostBatchRow,
                                                    ref iNRefNbr,
                                                    ref iNDocType);
                            }
                            else if (groupToUpdateInInventory.ServiceType == ID.Service_Action_Type.NO_ITEMS_RELATED)
                            {
                                PXProcessing <FSAppointmentDet> .SetError(appointmentInventoryItemInfoRow.Index, TX.Error.APPOINTMENT_ITEM_CANNOT_BE_POSTED_TO_IN_NO_ITEMS_RELATED);
                            }

                            PXProcessing <FSAppointmentDet> .SetInfo(appointmentInventoryItemInfoRow.Index, TX.Messages.RECORD_PROCESSED_SUCCESSFULLY);

                            linesPosted++;
                            ts_GroupToUpdateInInventory.Complete();
                        }
                        catch (Exception e)
                        {
                            Exception latestException = ExceptionHelper.GetExceptionWithContextMessage(PXMessages.Localize(TX.Messages.COULD_NOT_PROCESS_RECORD), e);
                            PXProcessing <FSAppointmentDet> .SetError(appointmentInventoryItemInfoRow.Index, latestException);

                            ts_GroupToUpdateInInventory.Dispose();
                            graphINReceiptEntry.Actions.PressCancel();
                        }
                    }
                }
            }

            return(linesPosted);
        }
Example #18
0
    //---------------------------------------------------------------------------
    /// <summary>
    /// The page Load event handler.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        var ds = PXPage.GetDefaultDataSource(this.Page);

        if (ds != null && ds.HasActiveContext)
        {
            if (ControlHelper.IsReloadPage(this))
            {
                var ctx = ds.DataGraph.GetContextViewDescriptor();
                if (ctx != null)
                {
                    if (ctx.HeaderValues != null)
                    {
                        screenTitle = string.Join(" - ", ctx.HeaderValues).ToUpper();
                    }
                    if (this.Visible)
                    {
                        var cm = PXCallbackManager.GetInstance();
                        PXCallbackManager.RegisterJavaScript(
                            string.Format("px.elemByID('{0}').innerHTML = '{1}';", LabelScreen.ClientID, screenTitle));
                    }
                }
            }
            else
            {
                screenTitle = " ";
            }
        }

        if (!string.IsNullOrEmpty(screenTitle))
        {
            this.ScreenTitle = HttpUtility.HtmlDecode(screenTitle);
        }
        if (!Page.IsCallback)
        {
            Page.EnableViewState = false;
            RegisterSyncTreeVars();
        }
        if (!this.Visible)
        {
            return;
        }

        Page.ClientScript.RegisterClientScriptBlock(GetType(), "addToFavorites", "var addToFavorites=\"" + PXMessages.Localize(InfoMessages.AddToFavorites) + "\";", true);
        Page.ClientScript.RegisterClientScriptBlock(GetType(), "removeFromFavorites", "var removeFromFavorites=\"" + PXMessages.Localize(InfoMessages.RemoveFromFavorites) + "\";", true);
        if (!this.Page.IsCallback || ControlHelper.IsReloadPage(tlbPath))
        {
            InitHelpMenu();
            RearrangeAuditMenu();
        }

        if (!willShowWelcomePage && this.Request.RawUrl.IndexOf("CS100000.aspx", StringComparison.InvariantCultureIgnoreCase) < 0 &&
            this.Request.RawUrl.IndexOf("/soap/", StringComparison.InvariantCultureIgnoreCase) == -1 &&
            this.Request.RawUrl.IndexOf("/wiki/", StringComparison.InvariantCultureIgnoreCase) == -1)
        {
            if (!PXAccess.FeatureSetInstalled("PX.Objects.CS.FeaturesSet"))
            {
                PXSiteMapNode cs = PXSiteMap.Provider.FindSiteMapNodeByScreenID("CS100000");
                if (cs != null)
                {
                    string navigateUrl = ResolveUrl(cs.Url);
                    if (!Page.IsCallback)
                    {
                        Response.Redirect(navigateUrl);
                    }
                }
            }
        }

        string localPath = Request.Url.LocalPath;

        if (!PXUrl.IsMainPage(Request.RawUrl) && !Request.Url.Query.Contains("PopupPanel=On"))
        {
            if (!localPath.EndsWith("Default.aspx"))
            {
                string lastUrl = (string)PXContext.Session["LastUrl"];
                if (String.IsNullOrEmpty(lastUrl) || lastUrl.EndsWith("Default.aspx"))
                {
                    Controls.Add(new LiteralControl("<script  type=\"text/javascript\">try { window.top.lastUrl=null; } catch (ex) {}</script>\n"));
                }
            }
            PXContext.Session.SetString("LastUrl", Request.RawUrl);
        }

        if (!Page.IsPostBack && !String.IsNullOrEmpty(ScreenID))
        {
            PX.Data.PXAuditJournal.Register(ScreenID);
        }

        if (!string.IsNullOrEmpty(screenTitle))
        {
            string relPath = ResolveUrl(Request.RawUrl);
            string url     = ResolveUrl(Request.RawUrl);
            LabelScreen.HRef = (Page != null && Page.GetType().Name == "wiki_showwiki_aspx") ? PXSessionStateStore.GetSessionUrl(HttpContext.Current, url) : url;

            if (PXSiteMap.CurrentNode != null && PXList.Provider.HasList(PXSiteMap.CurrentNode.ScreenID))
            {
                string        listScreenID = PXList.Provider.GetListID(PXSiteMap.CurrentNode.ScreenID);
                PXSiteMapNode listNode     = PXSiteMap.Provider.FindSiteMapNodeByScreenID(listScreenID);
                if (listNode != null)
                {
                    LabelScreen.HRef         = ResolveUrl(listNode.Url);
                    LabelScreen.ServerClick += (o, args) =>
                    {
                        PXList.Provider.SetCurrentSearches(PXSiteMap.CurrentNode.ScreenID, null);
                        Response.Redirect(ControlHelper.FixHideScriptUrl(PXPageCache.FixPageUrl(ResolveUrl(listNode.Url)), false));
                    };
                }
            }
            if (screenUrl != null)
            {
                LabelScreen.HRef = screenUrl;
            }

            this.ScreenTitle = screenTitle;
        }

        if (!Page.IsCallback)
        {
            Page.ClientScript.RegisterClientScriptBlock(GetType(), "toolbarNum", "var __toolbarID=\"" + this.tlbTools.ClientID + "\";", true);
        }
        if (ControlHelper.IsReloadPage(this))
        {
            SharedColumnSettings.SaveGrids();
        }
    }
Example #19
0
        protected virtual void INUnit_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INUnit       row   = (INUnit)e.Row;
            PXFieldState state = (PXFieldState)sender.GetStateExt <INUnit.fromUnit>(row);
            uint         msgNbr;
            String       msqPrefix;

            if (Item.Current != null && row.ToUnit == Item.Current.BaseUnit && (state.Error == null || state.Error == PXMessages.Localize(Messages.BaseUnitNotSmallest, out msgNbr, out msqPrefix) || state.ErrorLevel == PXErrorLevel.RowInfo))
            {
                if (row.UnitMultDiv == MultDiv.Multiply && row.UnitRate < 1 || row.UnitMultDiv == MultDiv.Divide && row.UnitRate > 1)
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, new PXSetPropertyException(Messages.BaseUnitNotSmallest, PXErrorLevel.RowWarning));
                }
                else
                {
                    sender.RaiseExceptionHandling <INUnit.fromUnit>(row, row.FromUnit, null);
                }
            }
        }