Exemple #1
0
        public ActionResult EditSubMenu(int id)
        {
            var sMenu = Entities.S_SubMenu.Find(id);

            if (sMenu != null)
            {
                SubMenuModels.SubMenuModel model = new SubMenuModels.SubMenuModel();
                model.SubMenuID   = sMenu.SubMenuID;
                model.SubMenuName = sMenu.SubMenuName;
                model.Code        = sMenu.Code;
                model.SortCode    = Convert.ToInt32(sMenu.SortCode);
                model.MainMenuID  = Convert.ToInt32(sMenu.MainMenuID);
                if (sMenu.Photo == null)
                {
                    ViewBag.Photo = false;
                }
                else
                {
                    ViewBag.Photo = true;
                }
                model.Photo      = sMenu.Photo;
                ViewBag.formType = 2;
                GetCompanySetting();
                GetDDLMainMenu();
                return(View("SubMenuEntry", model));
            }
            else
            {
                return(View("SubMenuList", GetSubMenu()));
            }
        }
Exemple #2
0
        public ActionResult InsertSubMenu(SubMenuModels.SubMenuModel subMenu, HttpPostedFileBase file)
        {
            GetCompanySetting();
            GetDDLMainMenu();
            var mCode     = Entities.S_SubMenu.Where(m => m.Code == subMenu.Code).FirstOrDefault();
            var mSortCode = Entities.S_SubMenu.Where(m => m.SortCode == subMenu.SortCode).FirstOrDefault();

            if (mCode == null && mSortCode == null)
            {
                S_SubMenu tblSubMenu = new S_SubMenu();
                tblSubMenu.SubMenuName = subMenu.SubMenuName;
                tblSubMenu.Code        = subMenu.Code;
                tblSubMenu.SortCode    = subMenu.SortCode;
                if (subMenu.MainMenuID != 0)
                {
                    tblSubMenu.MainMenuID = subMenu.MainMenuID;
                }
                else
                {
                    tblSubMenu.MainMenuID = null;
                }
                if (file != null)
                {
                    if (file.ContentLength > 0)
                    {
                        subMenu.Photo = new byte[file.ContentLength];
                        file.InputStream.Read(subMenu.Photo, 0, file.ContentLength);
                        tblSubMenu.Photo = subMenu.Photo;
                    }
                }
                else
                {
                    tblSubMenu.Photo = null;
                }
                Entities.S_SubMenu.Add(tblSubMenu);
                Entities.SaveChanges();
                ViewBag.Message = "New Sub Menu Inserted Successful....";
                ViewBag.Type    = 1;
                ModelState.Clear();
            }
            else
            {
                if (mCode != null && mSortCode == null)
                {
                    ViewBag.Message = "Sub Menu Code Duplicated";
                }
                else if (mCode == null && mSortCode != null)
                {
                    ViewBag.Message = "Sub Menu Sort Code Duplicated";
                }
                else
                {
                    ViewBag.Message = "Sub Menu Code and Sort Code Duplicated";
                }
                ViewBag.Type = 2;
            }
            return(View("SubMenuEntry"));
        }
Exemple #3
0
        public ActionResult UpdateSubMenu(SubMenuModels.SubMenuModel subMenu, HttpPostedFileBase file)
        {
            var sCode     = Entities.S_SubMenu.Where(m => m.SubMenuID != subMenu.SubMenuID && m.Code == subMenu.Code).FirstOrDefault();
            var sSortCode = Entities.S_SubMenu.Where(m => m.SubMenuID != subMenu.SubMenuID && m.SortCode == subMenu.SortCode).FirstOrDefault();

            if (sCode == null && sSortCode == null)
            {
                if (file != null)
                {
                    if (file.ContentLength > 0)
                    {
                        subMenu.Photo = new byte[file.ContentLength];
                        file.InputStream.Read(subMenu.Photo, 0, file.ContentLength);
                        subMenu.Photo = subMenu.Photo;
                        Entities.PrcUpdateSubMenu(subMenu.SubMenuID, subMenu.SubMenuName, subMenu.Code, subMenu.SortCode, subMenu.Photo, subMenu.MainMenuID, 2);
                    }
                }
                else
                {
                    Entities.PrcUpdateSubMenu(subMenu.SubMenuID, subMenu.SubMenuName, subMenu.Code, subMenu.SortCode, subMenu.Photo, subMenu.MainMenuID, 1);
                }
                ViewBag.Message = "Sub menu updated successful...";
                return(View("SubMenuList", GetSubMenu()));
            }
            else
            {
                if (sCode != null && sSortCode != null)
                {
                    ViewBag.Message = "Code and Sort Code Duplicated.";
                }
                else if (sCode != null && sSortCode == null)
                {
                    ViewBag.Message = "Code duplicated.";
                }
                else
                {
                    ViewBag.Message = "SortCode Duplicated...";
                }
                ViewBag.formType = 2;
                GetCompanySetting();
                GetDDLMainMenu();
                return(View("SubMenuEntry", subMenu));
            }
        }
Exemple #4
0
        public List <SubMenuModels.SubMenuModel> SearchingSubMenu(string sMenu, int mMenuID)
        {
            List <SubMenuModels.SubMenuModel> lstSubMenu = new List <SubMenuModels.SubMenuModel>();
            var subMenu = Entities.PrcSearchSubMenu(sMenu, mMenuID);

            foreach (var item in subMenu)
            {
                SubMenuModels.SubMenuModel model = new SubMenuModels.SubMenuModel();
                model.SubMenuID   = item.SubMenuID;
                model.SubMenuName = item.SubMenuName;
                model.SortCode    = Convert.ToInt32(item.SortCode);
                model.Code        = item.Code;
                if (item.MainMenuName == null)
                {
                    model.MainMenuName = "-";
                }
                else
                {
                    model.MainMenuName = item.MainMenuName;
                }
                lstSubMenu.Add(model);
            }
            return(lstSubMenu);
        }
Exemple #5
0
        public List <SubMenuModels.SubMenuModel> GetSubMenu()
        {
            List <SubMenuModels.SubMenuModel> lstSubMenu = new List <SubMenuModels.SubMenuModel>();
            var sMenu = Entities.PrcRetrieveSubMenu();

            foreach (var item in sMenu)
            {
                SubMenuModels.SubMenuModel model = new SubMenuModels.SubMenuModel();
                model.SubMenuID   = item.SubMenuID;
                model.SubMenuName = item.SubMenuName;
                model.SortCode    = Convert.ToInt32(item.SortCode);
                model.Code        = item.Code;
                if (item.MainMenuName == null)
                {
                    model.MainMenuName = "-";
                }
                else
                {
                    model.MainMenuName = item.MainMenuName;
                }
                lstSubMenu.Add(model);
            }
            return(lstSubMenu);
        }