Ejemplo n.º 1
0
        private void EditMode()
        {
            if (ObjectID > 0)
            {
                chkChangeimage.Checked = false;
                ddlCategories.Enabled = true;
                chkChangeimage.Visible = true;
                TG.ExpressCMS.DataLayer.Entities.MenuItem MenuItems = new TG.ExpressCMS.DataLayer.Entities.MenuItem();
                MenuItems = MenuItemManager.GetByID(ObjectID);
                if (null == MenuItems)
                    return;
                imguploaded.ImageUrl = imguploaded.ImageUrl = GetArticleImage(MenuItems.Image);
                TG.ExpressCMS.DataLayer.Entities.MenuItem mItem = MenuItemManager.GetByID(MenuItems.MenuID);
                GetArticleImage(MenuItems.Image);
                //   txtPublishFrom.DbSelectedDate = MenuItems.PublishFrom;
                // txtDateTo.DbSelectedDate = MenuItems.PublishTo;
                txtDesc.Text = MenuItems.Description;
                txtDetails.Text = MenuItems.Details;
                txtName.Text = MenuItems.Name;
                txtURL.Text = MenuItems.Url;
                if (MenuItems.RefLangID != 0)
                    ddlMappedLanguageID.SelectedValue = MenuItems.RefLangID.ToString();
                //   ddlLanguages.SelectedValue = MenuItems.LangID.ToString();
                txtOrderNumber.Text = MenuItems.OrderNumber.ToString();
                ddlMenuType.SelectedValue = Convert.ToInt32(MenuItems.Type).ToString();
                ddlCategories.SelectedValue = MenuItems.CategoryId.ToString();
                if (MenuItems.Type == RootEnums.MenuItemURLtype.External)
                {
                    trDetails.Visible = false;
                    trURL.Visible = true;
                }
                else
                {
                    trDetails.Visible = true;
                    trURL.Visible = false;
                }
                rdblstIsPublished.SelectedIndex = -1;
                rdblstIsPublished.SelectedValue = Convert.ToInt32(MenuItems.IsPublished).ToString();

                if (mItem != null)
                    ddlParentMenu.SelectedValue = mItem.ID.ToString();


                plcControls.Visible = true;

            }
        }
Ejemplo n.º 2
0
        void btnSaveUpdate_Click(object sender, EventArgs e)
        {
            int catid = 0;
            TG.ExpressCMS.DataLayer.Entities.MenuItem menuItems = new TG.ExpressCMS.DataLayer.Entities.MenuItem();
            if (ObjectID <= 0)
            {
                try
                {
                    menuItems.Name = txtName.Text;
                    menuItems.Description = txtDesc.Text;
                    menuItems.Details = txtDetails.Text;


                    int mappedlangID = 0;
                    Int32.TryParse(ddlMappedLanguageID.SelectedValue, out mappedlangID);
                    menuItems.RefLangID = mappedlangID;

                    int.TryParse(ddlCategories.SelectedValue, out catid);

                    menuItems.CategoryId = Convert.ToInt32(ddlMenuCategories.SelectedValue);
                    if (txtOrderNumber.Text.Length > 0)
                        menuItems.OrderNumber = Convert.ToInt32(txtOrderNumber.Text);
                    menuItems.LangID = 1;// Convert.ToInt32(ddlLanguages.SelectedValue);
                    menuItems.CreationDate = DateTime.Now.ToString("dd/MM/yyyy");
                    menuItems.CreationTime = DateTime.Now.ToString("dd/MM/yyyy");
                    menuItems.CreatedBy = SecurityContext.LoggedInUser.ID;
                    menuItems.IsDeleted = false;

                    menuItems.Image = UtilitiesManager.GetSavedFile(fUploader, true);
                    menuItems.Type = (TG.ExpressCMS.DataLayer.Enums.RootEnums.MenuItemURLtype)Convert.ToInt32(ddlMenuType.SelectedValue);
                    // menuItems.PublishFrom = txtPublishFrom.SelectedDate.Value.ToShortDateString();
                    //   menuItems.PublishTo = txtDateTo.SelectedDate.Value.ToShortDateString();
                    menuItems.MenuID = Convert.ToInt32(ddlParentMenu.SelectedValue);
                    menuItems.Url = string.Empty;

                    if (rdblstIsPublished.SelectedValue == "1")
                        menuItems.IsPublished = true;
                    else
                        menuItems.IsPublished = false;


                    MenuItemManager.Add(menuItems);

                    if (ddlMenuType.SelectedValue == Convert.ToInt32(TG.ExpressCMS.DataLayer.Enums.RootEnums.MenuItemURLtype.External).ToString())
                        menuItems.Url = txtURL.Text;
                    else
                        menuItems.Url = ResolveUrl(ExpressoConfig.MenuConfigElement.GetDefaultDetailsPage) + ConstantsManager.MenuID + "=" + menuItems.ID;

                    menuItems.Url = menuItems.Url.Replace("/ar/", "/");
                    MenuItemManager.Update(menuItems);
                    AddMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }

            }
            else
            {
                try
                {
                    menuItems = MenuItemManager.GetByID(ObjectID);
                    if (null == menuItems)
                    {
                        dvProblems.InnerText = Resources.ExpressCMS.ResourceManager.GetString(ConstantsManager.UnknowErronOccures);
                        return;
                    }
                    menuItems.LangID = 1;// Convert.ToInt32(ddlLanguages.SelectedValue);
                    menuItems.Name = txtName.Text;
                    menuItems.Description = txtDesc.Text;
                    menuItems.Details = txtDetails.Text;
                    int.TryParse(ddlCategories.SelectedValue, out catid);
                    menuItems.CategoryId = Convert.ToInt32(ddlMenuCategories.SelectedValue);
                    menuItems.Url = txtURL.Text;
                    if (txtOrderNumber.Text.Length > 0)
                        menuItems.OrderNumber = Convert.ToInt32(txtOrderNumber.Text);
                    menuItems.IsDeleted = false;
                    if (chkChangeimage.Checked)
                        menuItems.Image = UtilitiesManager.GetSavedFile(fUploader, true);
                    menuItems.Type = (TG.ExpressCMS.DataLayer.Enums.RootEnums.MenuItemURLtype)Convert.ToInt32(ddlMenuType.SelectedValue);
                    // menuItems.PublishFrom = txtPublishFrom.SelectedDate.Value.ToString("dd/MM/yyyy");
                    // menuItems.PublishTo = txtDateTo.SelectedDate.Value.ToString("dd/MM/yyyy");

                    if (rdblstIsPublished.SelectedValue == "1")
                        menuItems.IsPublished = true;
                    else
                        menuItems.IsPublished = false;

                    int mappedlangID = 0;
                    Int32.TryParse(ddlMappedLanguageID.SelectedValue, out mappedlangID);
                    menuItems.RefLangID = mappedlangID;

                    menuItems.MenuID = Convert.ToInt32(ddlParentMenu.SelectedValue);
                    menuItems.Url = "";
                    if (ddlMenuType.SelectedValue == Convert.ToInt32(TG.ExpressCMS.DataLayer.Enums.RootEnums.MenuItemURLtype.External).ToString())
                        menuItems.Url = txtURL.Text;
                    else
                        menuItems.Url = ResolveUrl(ExpressoConfig.MenuConfigElement.GetDefaultDetailsPage) + ConstantsManager.MenuID + "=" + menuItems.ID;
                    menuItems.Url = menuItems.Url.Replace("/ar/", "/");
                    MenuItemManager.Update(menuItems);
                    EditMode();
                }
                catch (Exception ex)
                {
                    dvProblems.InnerText = ex.ToString();
                }
            }
            BindGrid(string.Empty);
            RefillMenus();
        }