public static void OnLoad1Step(IEditSecurityProfile form, EventArgs args)
        {
            // child is the member of a team or department
            // parent is the team or department
            IOwner child = form.CurrentEntity as IOwner;

            form.HiddenChildId.Value   = child.Id.ToString();
            form.NameTextBox.Text      = child.OwnerDescription;
            form.OwnerTypeTextBox.Text = child.Type.ToString();

            IWebDialogService dialogService = form.Services.Get <IWebDialogService>();

            string parentId = dialogService.DialogParameters["parentId"].ToString();

            form.HiddenParentId.Value = parentId;
            IOwner parent = EntityFactory.GetById <IOwner>(parentId);

            form.ParentTextBox.Text = parent.OwnerDescription;

            string profileId = dialogService.DialogParameters["profileId"].ToString();

            form.HiddenProfileId.Value = profileId;
            IOwnerSecurityProfile profile = EntityFactory.GetById <IOwnerSecurityProfile>(profileId);

            form.SecurityProfileLookup.LookupResultValue = profile;
        }
コード例 #2
0
        /// <summary>
        /// Initializes and invokes the Add Custom Product view.
        /// </summary>
        /// <param name="form">The Sales Order Products form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void btnAddCustomProduct_OnClickStep(ISalesOrderProducts form, EventArgs args)
        {
            ISalesOrder salesOrder = form.CurrentEntity as ISalesOrder;

            if (salesOrder != null)
            {
                IWebDialogService dialogService = form.Services.Get <IWebDialogService>();
                if (dialogService != null)
                {
                    string dialogCaption = String.Format(form.GetResource("btnAddCustomProduct.Caption").ToString(),
                                                         salesOrder.SalesOrderNumber);
                    if (salesOrder.IsContractIntegrationEnabled())
                    {
                        dialogService.SetSpecs(20, 20, 390, 700, "ICEditSalesOrderItem", dialogCaption, true);
                    }
                    else
                    {
                        dialogService.SetSpecs(20, 20, 325, 700, "EditSalesOrderItem", dialogCaption, true);
                    }
                    dialogService.DialogParameters.Add("CustomProductSalesOrder", salesOrder);
                    dialogService.EntityType = typeof(ISalesOrderItem);
                    dialogService.ShowDialog();
                }
            }
        }
        /// <summary>
        /// Saves the new team entity and adds the owner to the team.  Optionally will
        /// add the owner's manager to the team is the add owner's manager checkbox is checked.
        /// </summary>
        /// <param name="form"></param>
        /// <param name="args"></param>
        public static void SaveButton_OnClickStep(IInsertTeam form, EventArgs args)
        {
            IWebDialogService dialogService = form.Services.Get <IWebDialogService>();
            // create the new team
            IOwner ownerTeam = EntityFactory.Create <IOwner>();

            ownerTeam.OwnerDescription = form.OwnerDescription.Text;
            ownerTeam.Type             = OwnerType.Team;

            if (!ownerTeam.IsValidName(form.OwnerDescription.Text))
            {
                string msg = form.GetResource("InvalidNameMessage").ToString();
                if (dialogService != null && !string.IsNullOrEmpty(msg))
                {
                    dialogService.ShowMessage(msg, form.GetResource("InvalidNameMessageTitle").ToString());
                }

                return;
            }

            if (ownerTeam.OwnerNameExists(form.OwnerDescription.Text))
            {
                string msg = form.GetResource("DuplicateOwnerMessage").ToString();
                if (dialogService != null && !string.IsNullOrEmpty(msg))
                {
                    dialogService.ShowMessage(msg, form.GetResource("DuplicateOwnerTitle").ToString());
                }

                return;
            }

            ownerTeam.Save();

            // set a default profile
            IOwnerSecurityProfile securityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000001");

            if (form.securityProfileLookup.LookupResultValue != null)
            {
                securityProfile = form.securityProfileLookup.LookupResultValue as IOwnerSecurityProfile;
            }

            // get a team object.  This is a view of the owner object
            ITeam team = EntityFactory.GetById <ITeam>(ownerTeam.Id);

            // add an ownerJoin record for the new team.  Both the parent and the
            // child ids will point to the team
            team.AddMemberWithSecurityProfile(ownerTeam, securityProfile);

            // get the selected owner of the team.  This will be a user
            IUser teamOwnerUser = form.DefaultOwner.LookupResultValue as IUser;

            if (teamOwnerUser != null)
            {
                // add the team owner as a member of the team
                IOwnerSecurityProfile ownerSecurityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000003");
                team.AddMemberWithSecurityProfile(teamOwnerUser.DefaultOwner, ownerSecurityProfile);
            }
            MySlx.MainView.Show <ITeam>(ownerTeam.Id.ToString());
        }
コード例 #4
0
        /// <summary>
        /// Initializes the view.
        /// </summary>
        /// <param name="form">The Edit Sales Order Item form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void OnFormLoadStep(IEditSalesOrderItem form, EventArgs args)
        {
            ISalesOrderItem   salesOrderItem = form.CurrentEntity as ISalesOrderItem;
            IWebDialogService dialogService  = form.Services.Get <IWebDialogService>();

            if (dialogService != null && dialogService.DialogParameters.ContainsKey("CustomProductSalesOrder"))
            {
                ISalesOrder salesOrder = dialogService.DialogParameters["CustomProductSalesOrder"] as ISalesOrder;
                salesOrderItem.SalesOrder      = salesOrder;
                salesOrderItem.Quantity        = 1;
                salesOrderItem.CalculatedPrice = 0;
                salesOrderItem.Discount        = 0;
                salesOrderItem.ExtendedPrice   = 0;
                salesOrderItem.Price           = 0;
                dialogService.DialogParameters.Remove("CustomProductSalesOrder");
            }
            if (salesOrderItem.SalesOrder.IsMultiCurrencyEnabled())
            {
                form.curMCCalcPrice.ExchangeRate     = salesOrderItem.SalesOrder.ExchangeRate.GetValueOrDefault(1);
                form.curMCCalcPrice.CurrentCode      = salesOrderItem.SalesOrder.CurrencyCode;
                form.curMCCalcPrice.ExchangeRateType = Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate;
                form.curMCCalcPrice.Text             = salesOrderItem.CalculatedPrice.ToString();
            }
            else
            {
                form.ctrlstMCPrice.Visible = false;
            }

            if (salesOrderItem.Product == null)              // AdHocProduct
            {
                salesOrderItem.LineType        = "FreeText"; // Use as literal; represents adhoc product.
                form.ctrlstLineNumber.Visible  = false;
                form.ctrlstPriceLevel.Visible  = false;
                form.curPrice.IsReadOnly       = false;
                form.txtSKU.IsReadOnly         = false;
                form.pklFamily.IsReadOnly      = false;
                form.txtDescription.IsReadOnly = false;
                form.txtProductName.IsReadOnly = false;
            }

            bool closed = (salesOrderItem.SalesOrder.Status.ToUpper().Equals(form.GetResource("SalesOrderStatus_Closed").ToString().ToUpper()));

            form.txtDescription.Enabled     = !closed;
            form.txtSKU.Enabled             = !closed;
            form.pklFamily.Enabled          = !closed;
            form.txtDiscount.Enabled        = !closed;
            form.curCalculatedPrice.Enabled = !closed;
            form.curMCCalcPrice.Enabled     = !closed;
            form.numQuantity.Enabled        = !closed;
            form.btnOK.Visible     = !closed;
            form.btnCancel.Caption = form.GetResource("Closed_Caption").ToString();
        }
コード例 #5
0
        public static void SaveButton_OnClickStep(IInsertDepartment form, EventArgs args)
        {
            IWebDialogService dialogService = form.Services.Get <IWebDialogService>();
            IOwner            owner         = EntityFactory.Create <IOwner>();

            owner.OwnerDescription = form.OwnerDescription.Text;
            owner.Type             = OwnerType.Department;
            if (!owner.IsValidName(form.OwnerDescription.Text))
            {
                string msg = form.GetResource("InvalidNameMessage").ToString();
                if (dialogService != null && !string.IsNullOrEmpty(msg))
                {
                    dialogService.ShowMessage(msg, form.GetResource("InvalidNameMessageTitle").ToString());
                }

                return;
            }

            if (owner.OwnerNameExists(form.OwnerDescription.Text))
            {
                string msg = form.GetResource("DuplicateOwnerMessage").ToString();
                if (dialogService != null && !string.IsNullOrEmpty(msg))
                {
                    dialogService.ShowMessage(msg, form.GetResource("DuplicateOwnerTitle").ToString());
                }

                return;
            }

            owner.Save();

            IOwnerSecurityProfile securityProfile = EntityFactory.GetById <IOwnerSecurityProfile>("PROF00000001");

            if (form.securityProfileLookup.LookupResultValue != null)
            {
                securityProfile = form.securityProfileLookup.LookupResultValue as IOwnerSecurityProfile;
            }

            // get a department object.  This is a view of the owner object
            IDepartment department = EntityFactory.GetById <IDepartment>(owner.Id);

            // add an ownerJoin record for the new team.  Both the parent and the
            // child ids will point to the team
            department.AddMemberWithSecurityProfile(owner, securityProfile);

            HttpContext.Current.Response.Redirect(string.Format("~/Department.aspx?entityId={0}", owner.Id.ToString()), false);
        }
コード例 #6
0
        public static void lueAddUser_OnChangeStep(IOthersAccessToUserCal form, EventArgs args)
        {
            IUser user = form.CurrentEntity as IUser;
            IUser userwantingaccess = form.lueAddUser.LookupResultValue as IUser;

            if (!user.UserCalendarExists(userwantingaccess))
            {
                user.AddUserCalendar(userwantingaccess);

                IWebDialogService dialogService = form.Services.Get <IWebDialogService>();
                dialogService.SetSpecs(235, 420, "EditCalPermissions");
                dialogService.EntityType        = typeof(IUserCalendar);
                dialogService.CompositeKeyNames = "UserId, CalUserId";
                dialogService.EntityID          = string.Format("{0},{1}", userwantingaccess.Id, user.Id);
                dialogService.ShowDialog();
            }
        }
コード例 #7
0
    /// <summary>
    /// Handles the Click event of the hEditAct control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
    protected void hEditAct_Click(object sender, EventArgs e)
    {
        string activityID = hActId.Value;

        if (activityID.Length > 12)
        {
            activityID = activityID.Substring(0, 12);
        }
        Activity activity = EntityFactory.GetById <Activity>(activityID);

        if (activity != null)
        {
            if (activity.Recurring && activity.RecurrencePattern.Range.NumOccurences > -1)
            {
                IWebDialogService dialogService = GetdialogService();
                if (dialogService != null)
                {
                    dialogService.SetSpecs(200, 200, 250, 330, "EditRecurrence", "", true);
                    dialogService.EntityType = typeof(IActivity);
                    dialogService.EntityID   = activityID;
                    dialogService.DialogParameters.Add("recurdate", hOccurrenceDate.Value);
                    var appContext = ApplicationContext.Current.Services.Get <IContextService>();
                    if (appContext != null)
                    {
                        var actParams = new Dictionary <string, string>();
                        actParams.Add("recurdate", hOccurrenceDate.Value);
                        appContext["ActivityParameters"] = actParams;
                    }
                    dialogService.ShowDialog();
                }
                else
                {
                    Link.EditActivity(activityID);
                }
            }
            else
            {
                Link.EditActivity(activityID);
            }
        }
    }
コード例 #8
0
        /// <summary>
        /// Assigns the new job id to the link control.
        /// </summary>
        /// <param name="form">The SyncConfirmation form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void OnLoadStep(ISyncJobConfirmation form, EventArgs args)
        {
            IWebDialogService dialogService = form.Services.Get <IWebDialogService>();

            if (dialogService.DialogParameters.ContainsKey("NewSyncJobName"))
            {
                var jobName = dialogService.DialogParameters["NewSyncJobName"];
                if (jobName != null)
                {
                    ISyncJob syncJob = EntityFactory.GetRepository <ISyncJob>().FindFirstByProperty("JobName", jobName.ToString());
                    if (syncJob != null)
                    {
                        form.lnkViewSyncJob.EntityId = syncJob.Id.ToString();
                        form.lnkViewSyncJob.Text     = String.Format(form.GetResource("jobName.Caption").ToString(), jobName);
                    }
                    else
                    {
                        form.lnkViewSyncJob.Visible = false;
                        form.lblMessage.Text        = form.GetResource("DialogHeader.Caption").ToString();
                    }
                    dialogService.DialogParameters.Remove("NewSyncJobName");
                }
            }
        }
        /// <summary>
        /// Performs the password validation rules. If validation fails an exception is raised from the
        /// ValidateUserPassword method. If validation succeeds, but the password was changed
        /// to an empty string that result is returned, which will be displayed to the UI.
        /// </summary>
        /// <param name="form">The change password form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void btnSave_OnClick(IUserChangePassword form, EventArgs args)
        {
            string newPassword = form.txtNewPassword.Text;

            if (newPassword == form.txtConfirmPassword.Text)
            {
                IUser user = (IUser)form.CurrentEntity;

                if (user.ValidateUserPassword(newPassword))
                {
                    IWebDialogService dialogService = form.Services.Get <IWebDialogService>();
                    user.SavePassword(newPassword);
                    var slxUserService = (ISlxUserService)ApplicationContext.Current.Services.Get <IUserService>(true);
                    var currentUser    = slxUserService.GetUser();
                    if (user.UserName == currentUser.UserName)
                    {
                        var data = (SLXDataService)ApplicationContext.Current.Services.Get <IDataService>(true);
                        var auth = (SLXWebAuthenticationProvider)data.AuthenticationProvider;
                        auth.AuthenticateWithContext(currentUser.UserName, newPassword);
                    }

                    form.lblInvalidPassword.Text = newPassword.Length == 0 ? form.GetResource("PasswordBlank").ToString() : String.Empty;
                    dialogService.ShowMessage(form.GetResource(newPassword.Length == 0 ? "PasswordBlank" : "PasswordChanged").ToString());
                    dialogService.CloseEventHappened(form, null);
                    IPanelRefreshService refresher = form.Services.Get <IPanelRefreshService>();
                    if (refresher != null)
                    {
                        refresher.RefreshAll();
                    }
                }
            }
            else
            {
                throw new ValidationException(form.GetResource("Error_PasswordsDontMatch").ToString());
            }
        }
コード例 #10
0
        /// <summary>
        /// Sets view state of the Add Custom Product view based on a set of rules.
        /// </summary>
        /// <param name="form">The Edit Sales Order Item form.</param>
        /// <param name="args">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public static void OnLoad1Step(IICEditSalesOrderItem form, EventArgs args)
        {
            ISalesOrderItem   salesOrderItem = form.CurrentEntity as ISalesOrderItem;
            ISalesOrder       salesOrder     = salesOrderItem.SalesOrder;
            IWebDialogService dialogService  = form.Services.Get <IWebDialogService>();

            if (dialogService != null && dialogService.DialogParameters.ContainsKey("CustomProductSalesOrder"))
            {
                salesOrder = dialogService.DialogParameters["CustomProductSalesOrder"] as ISalesOrder;
                salesOrderItem.SalesOrder      = salesOrder;
                salesOrderItem.Quantity        = 1;
                salesOrderItem.CalculatedPrice = 0;
                salesOrderItem.Discount        = 0;
                salesOrderItem.ExtendedPrice   = 0;
                salesOrderItem.Price           = 0;
                dialogService.DialogParameters.Remove("CustomProductSalesOrder");
            }

            if (salesOrder != null && salesOrder.IsMultiCurrencyEnabled())
            {
                form.curMCCalcPrice.ExchangeRate     = salesOrder.ExchangeRate.GetValueOrDefault(1);
                form.curMCCalcPrice.CurrentCode      = salesOrder.CurrencyCode;
                form.curMCCalcPrice.ExchangeRateType = Sage.Platform.Controls.ExchangeRateTypeEnum.EntityRate;
                form.curMCCalcPrice.Text             = salesOrderItem.CalculatedPrice.ToString();
            }
            else
            {
                form.ctrlstMCPrice.Visible = false;
            }

            form.ctrlstLineNumber.Visible = (salesOrderItem.Id != null);

            if (salesOrderItem.Product == null) // AdHocProduct
            {
                if (String.IsNullOrEmpty(salesOrderItem.LineType))
                {
                    salesOrderItem.LineType = "FreeText"; // Use as literal; represents adhoc product.
                }
                form.curPrice.IsReadOnly       = false;
                form.txtSKU.IsReadOnly         = false;
                form.txtFamily.IsReadOnly      = false;
                form.txtDescription.IsReadOnly = false;
                form.txtProduct.IsReadOnly     = false;
                form.ctrlstWarehouse.Visible   = false;
                form.ctrlstWarehouses.Visible  = false;
            }
            IAppIdMappingService mappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <IAppIdMappingService>(true);
            //if this is a Sales Order that synced from the accounting system or the Sales Order has been submitted then we disable it
            bool isOpen = false;

            if (!String.IsNullOrEmpty(salesOrder.ERPSalesOrder.ERPStatus))
            {
                isOpen = (salesOrder.ERPSalesOrder.ERPStatus.Equals(
                              form.GetResource("erpStatus_Open").ToString()) ||
                          salesOrder.ERPSalesOrder.ERPStatus.Equals(form.GetResource("erpStatus_Rejected").ToString()));
            }
            bool erpSalesOrder = (mappingService.IsIntegrationEnabled() && (salesOrder.GlobalSyncId.HasValue && !isOpen));

            form.txtDescription.Enabled      = !erpSalesOrder;
            form.txtFamily.Enabled           = !erpSalesOrder;
            form.lueLocation.Enabled         = !erpSalesOrder;
            form.numDiscount.Enabled         = !erpSalesOrder;
            form.currCalculatedPrice.Enabled = !erpSalesOrder;
            form.numQuantity.Enabled         = !erpSalesOrder;
            form.lueUnitOfMeasure.Enabled    = !erpSalesOrder;
            form.chkPriceLocked.Enabled      = !erpSalesOrder;
            form.btnOk.Visible       = !erpSalesOrder;
            form.txtComments.Enabled = !erpSalesOrder;
            form.btnCancel.Caption   = form.GetResource("Closed_Caption").ToString();

            IRoleSecurityService roleSecurityService = form.Services.Get <IRoleSecurityService>(true);

            form.chkPriceLocked.Enabled = roleSecurityService.HasAccess("IntegrationContract/LockPricing");
        }