Esempio n. 1
0
    // Save the new or updated Input form
    private void ApplyChanges()
    {
        ifObj = HyperCatalog.Business.InputForm.GetByKey(ifId);
        ifObj.PLs.Clear();
        Trace.Warn("Calling PLTree.GetCheckedPLs()");
        PLList checkedPLs = PLTree.GetCheckedPLs();

        foreach (PL pl in checkedPLs)
        {
            ifObj.PLs.Add(pl);
        }
        if (!ifObj.Save(true))
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = HyperCatalog.Business.InputForm.LastError;
            lbError.Visible  = true;
        }
        else
        {
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "RefreshTabs", "<script>RefreshTabs('PLs', " + ifObj.PLs.Count.ToString() + ", 'Usage', " + ifObj.Items.Count.ToString() + ");</script>");
            lbError.Text     = "Data saved!";
            lbError.CssClass = "hc_success";
            lbError.Visible  = true;
        }
    }
Esempio n. 2
0
 protected override void OnLoadComplete(EventArgs e)
 {
     base.OnLoadComplete(e);
     if (ifObj != null)
     {
         Trace.Warn("Input Forms -> Check PLs (" + ifObj.PLs.Count.ToString() + " items)");
         PLTree.CheckPLs(ifObj.PLs);
     }
 }
Esempio n. 3
0
    private string GetSelPLNames()
    {
        string selPlNames = string.Empty;
        PLList checkedPLs = PLTree.GetCheckedPLs();

        foreach (PL pl in checkedPLs)
        {
            selPlNames = selPlNames + pl.Name + ",";
        }
        if (selPlNames != string.Empty)
        {
            selPlNames = selPlNames.Remove(selPlNames.Length - 1, 1);
            return(selPlNames);
        }
        else
        {
            return(null);
        }
    }
Esempio n. 4
0
 protected override void OnLoadComplete(EventArgs e)
 {
     base.OnLoadComplete(e);
     Debug.Trace("WEBUI", "User checked PLs = " + SessionState.EditedUser.PLs.Count.ToString() + " items", DebugSeverity.Low);
     PLTree.CheckPLs(SessionState.EditedUser.PLs);
 }
Esempio n. 5
0
    private void Save()
    {
        bool success = true;

        success = SessionState.EditedUser.ClearItemsScope();
        if (success)
        {
            int classesCount = 0;
            foreach (ListItem item in classes.Items)
            {
                if (item.Selected)
                {
                    classesCount++;
                    success = success && SessionState.EditedUser.AddItemInScope(Convert.ToInt64(item.Value));
                }
            }
            if (SessionState.EditedUser.Id == HyperCatalog.Shared.SessionState.User.Id)
            {
                SessionState.User.Dispose();
                HyperCatalog.Shared.SessionState.User = SessionState.EditedUser;
            }

            PLList pls = PLTree.GetCheckedPLs();

            /*if (pls.Count > 0 && classesCount > 0)
             * {*/
            SessionState.EditedUser.PLs.Clear();
            foreach (PL pl in pls)
            {
                SessionState.EditedUser.PLs.Add(pl);
            }
            success = success && SessionState.EditedUser.Save(false, true);
            if (success)
            {
                SessionState.EditedUser.UpdateItemScope();
                if (SessionState.EditedUser.Id == SessionState.User.Id)
                {
                    HyperCatalog.Shared.SessionState.User = SessionState.EditedUser;
                }

                foreach (ListItem item in classes.Items)
                {
                    item.Selected = SessionState.EditedUser.HasItemInScope(Convert.ToInt64(item.Value));
                    item.Enabled  = (SessionState.EditedUser.RoleId != 0);
                    if (SessionState.EditedUser.RoleId == 0)
                    {
                        item.Selected = true;
                    }

                    if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
                    {
                        item.Enabled = false;
                    }
                }

                lbError.Text     = "Data saved! (the product type displayed are only relevant for the selected product lines)";
                lbError.CssClass = "hc_success";
                lbError.Visible  = true;
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = HyperCatalog.Business.User.LastError;
                lbError.Visible  = true;
            }

            SessionState.EditedUser.Dispose();

            /*}
             * else
             * {
             * if (pls.Count == 0 && classesCount > 0)
             * {
             *  lbError.CssClass = "hc_error";
             *  lbError.Text = "You must select at least one Product Line.";
             *  lbError.Visible = true;
             * }
             * else if (pls.Count > 0 && classesCount == 0)
             * {
             *  lbError.CssClass = "hc_error";
             *  lbError.Text = "You must select at least one Classe.";
             *  lbError.Visible = true;
             * }
             * }*/
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = HyperCatalog.Business.User.LastError;
            lbError.Visible  = true;
        }
    }