Example #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ClearMessege();

                int parentMenuId = Convert.ToInt32(hdnParentMenuId.Value);
                int menuId       = Convert.ToInt32(hdnMenuId.Value);

                string menuName = txtMenuName.Text.Trim();
                string menuURL  = txtMenuURL.Text.Trim();

                if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(menuURL))
                {
                    LogicLayer.BusinessObject.Menu menu;
                    if (menuId != 0)
                    {
                        menu = MenuManager.GetById(menuId);
                    }
                    else
                    {
                        menu = new LogicLayer.BusinessObject.Menu();
                    }


                    menu.Name     = menuName;
                    menu.URL      = menuURL;
                    menu.ParentId = parentMenuId == 0 ? null : (Nullable <int>)parentMenuId;

                    if (menuId != 0)
                    {
                        menu.ModifiedBy   = currentUser.Id;
                        menu.ModifiedDate = DateTime.Now;
                        bool isUpdate = MenuManager.Update(menu);
                        if (isUpdate)
                        {
                            ShowMessage("Menu Updated Successfully! Please Refresh Page To See The Change!", Color.Green);
                        }
                    }
                    else
                    {
                        menu.CreatedBy   = currentUser.Id;
                        menu.CreatedDate = DateTime.Now;
                        menuId           = MenuManager.Insert(menu);
                        if (menuId != 0)
                        {
                            ShowMessage("Menu Saved Successfully! Please Refresh Page To See The Change!", Color.Green);
                        }
                    }

                    ClearAll(false);
                }
            }
            catch (Exception ex)
            {
                ShowMessage("Exception Occured !", Color.Red);
            }
        }
Example #2
0
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            int menuId = Convert.ToInt32(tvMenu.SelectedNode.Value);

            LogicLayer.BusinessObject.Menu menu = MenuManager.GetById(menuId);

            hdnParentMenuId.Value = menu.ParentId == null ? "0" : menu.ParentId.ToString();
            hdnMenuId.Value       = menu.Id.ToString();
            txtMenuName.Text      = menu.Name;
            txtMenuURL.Text       = menu.URL;

            ClearMessege();
        }