Exemplo n.º 1
0
        private void AddNewList()
        {
            string listName      = txtListName.Text.Trim();
            string value         = txtEntryValue.Text.Trim();
            string text          = txtEntryText.Text.Trim();
            int    parentId      = 0;
            int    level         = 0;
            int    definitionId  = -1;
            int    portalId      = -1;// GetPortalID;
            string createdBy     = GetUsername;
            bool   displayOrder  = false;
            bool   isActive      = false;
            string currencyCode  = txtCurrencyCode.Text.Trim();
            string displayLocale = txtDisplayLocale.Text.Trim();

            if (chkShort.Checked == true)
            {
                displayOrder = true;
            }

            if (chkActive.Checked == true)
            {
                isActive = true;
            }
            if (ddlParentList.SelectedIndex != 0)
            {
                try
                {
                    parentId = int.Parse(ddlParentEntry.SelectedValue.ToString());
                    string   selectedListName  = string.Empty;
                    string[] selectedListNames = SplitString(ddlParentEntry.SelectedItem.Text);
                    selectedListName = selectedListNames[0];

                    ListManagementController  objController = new ListManagementController();
                    List <ListManagementInfo> objList       = objController.GetListEntriesByNameValueAndEntryID(selectedListName, "", int.Parse(ddlParentEntry.SelectedValue.ToString()), GetCurrentCultureName);
                    foreach (ListManagementInfo parentLevel in objList)
                    {
                        level = int.Parse(parentLevel.Level.ToString()) + 1;
                    }
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
            try
            {
                ListManagementController objController = new ListManagementController();
                int ListID = objController.AddNewList(new ListInfo(listName, value, text, parentId, level, currencyCode, displayLocale, displayOrder, definitionId, "", portalId, isActive, createdBy, GetCurrentCultureName));

                if (ListID == 0)
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("ListSettings", "ListAlreadyExists"), "", SageMessageType.Alert);
                }
                else
                {
                    BindTreeView();
                    ViewMode();
                    ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("ListSettings", "ListIsAddedSuccessfully"), "", SageMessageType.Success);
                    BindGridOnPageLoad();
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
Exemplo n.º 2
0
        protected void imgSave_Click(object sender, EventArgs e)
        {
            try
            {
                // string listName = txtListName.Text;
                string value         = txtEntryValue.Text;
                string text          = txtEntryText.Text;
                string currencyCode  = txtCurrencyCode.Text.Trim();
                string displayLocale = txtDisplayLocale.Text.Trim();
                string createdBy     = GetUsername;
                bool   isActive      = false;

                if (!CheckUniqueness(txtListName.Text))
                {
                    if (chkActive.Checked == true)
                    {
                        isActive = true;
                    }

                    if (ViewState["NEWLIST"] != null)
                    {
                        ViewState["NEWLIST"] = null;
                        AddNewList();
                    }
                    else if (ViewState["LISTNAME"] != null && ViewState["ADDSUBLIST"] != null)
                    {
                        ViewState["ADDSUBLIST"] = null;
                        string listName     = ViewState["LISTNAME"].ToString();
                        int    parentId     = 0;
                        int    level        = 0;
                        int    definitionId = -1;
                        int    portalId     = -1;
                        bool   displayOrder = true;
                        if (ViewState["PARENTKEY"] != null)
                        {
                            ListManagementController  objController = new ListManagementController();
                            List <ListManagementInfo> objlist       = objController.GetEntriesByNameParentKeyAndPortalID(listName, ViewState["PARENTKEY"].ToString(), -1, GetCurrentCultureName);
                            foreach (ListManagementInfo listDetail in objlist)
                            {
                                parentId     = listDetail.ParentID;
                                level        = listDetail.Level;
                                definitionId = listDetail.DefinitionID;
                                portalId     = listDetail.PortalID;
                            }
                        }
                        try
                        {
                            ListManagementController objController = new ListManagementController();
                            objController.AddNewList(new ListInfo(listName, value, text, parentId, level, currencyCode, displayLocale, displayOrder, definitionId, "", portalId, isActive, createdBy, GetCurrentCultureName));
                            ViewMode();
                            BindGrid(ViewState["LISTNAME"].ToString(), ViewState["PARENTKEY"].ToString());
                        }
                        catch (Exception ex)
                        {
                            ProcessException(ex);
                        }
                    }
                    else if (ViewState["LISTNAME"] != null && ViewState["ENTRYID"] != null)
                    {
                        int entryId = int.Parse(ViewState["ENTRYID"].ToString());
                        ViewState["ENTRYID"] = null;
                        try
                        {
                            ListManagementController objController = new ListManagementController();
                            objController.UpdateListEntry(entryId, value, text, currencyCode, displayLocale, "", isActive, createdBy, GetCurrentCultureName);
                            ViewMode();
                            BindGrid(ViewState["LISTNAME"].ToString(), ViewState["PARENTKEY"].ToString());
                        }
                        catch (Exception ex)
                        {
                            ProcessException(ex);
                        }
                    }
                }
                else
                {
                    ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("ListSettings", "ListAlreadyExists"), "", SageMessageType.Alert);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }