예제 #1
0
        public ActionResult Create(Menu menu)
        {
            var  menudao = new MenuDao();
            long id      = menudao.Insert(menu);

            return(View());
        }
예제 #2
0
 public ActionResult Create([Bind(Include = "ID,Text,Link,Status,Target")] Menu menu)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var dao = new MenuDao();
             menu.Text   = menu.Text;
             menu.Link   = menu.Link;
             menu.Target = menu.Target;
             menu.Status = Convert.ToBoolean(true);
             var id = dao.Insert(menu);
             if (id > 0)
             {
                 SetAlert("Thêm mới thành thành công", "success");
                 ViewBag.Success = "Thêm thành công";
                 menu            = new Menu();
                 return(RedirectToAction("Index", "Menu"));
             }
             else
             {
                 ModelState.AddModelError("", "Thêm mới ko thành công");
             }
         }
     }
     catch (DbEntityValidationException e)
     {
         throw e;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(View(menu));
 }
예제 #3
0
 public ActionResult Add(tb_Menus entity)
 {
     if (ModelState.IsValid)
     {
         entity.Order  = entity.Order ?? 0;
         entity.Status = entity.Status ?? true;
         long Id = Dao.Insert(entity);
         return(RedirectToAction("Edit", "Menus", new { Id = Id }));
     }
     ViewBag.TypeId   = new SelectList(Dao.ListAllType(), "Id", "Name", entity.TypeId);
     ViewBag.ParentId = new SelectList(Dao.ListAll(), "Id", "Text", entity.ParentId);
     return(View(entity));
 }
예제 #4
0
        public string Create(int tenantId, MenuInfo info)
        {
            ArgumentHelper.AssertIsTrue(info != null, "MenuInfo is null");
            ArgumentHelper.AssertNotNullOrEmpty(info.Name, "MenuInfo.Name is null or empty");
            ArgumentHelper.AssertIsTrue(info.TenantId > 0, "MenuInfo.TenantId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(info.AppAccountId, "MenuInfo.AppAccountId is null or empty");
            ArgumentHelper.AssertIsTrue(info.BeisenAppId > 0, "MenuInfo.BeisenAppId is 0");
            ArgumentHelper.AssertNotNullOrEmpty(info.Url, "MenuInfo.Url is null or empty");

            info.MenuId = Guid.NewGuid().ToString();

            MenuDao.Insert(info);

            return(info.MenuId);
        }
예제 #5
0
        public JsonResult SaveData(string strMenu)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Menu   menu    = serializer.Deserialize <Menu>(strMenu);
            bool   status  = false;
            string action  = string.Empty;
            string message = string.Empty;
            bool   res     = new MenuDao().CheckIDExist(menu.ID);

            if (res)
            {
                var model = new MenuDao();
                try
                {
                    model.Insert(menu);
                    status = true;
                    action = "insert";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            else
            {
                //update existing DB
                //save db
                try
                {
                    var model = new MenuDao().Update(menu);
                    status = true;
                    action = "update";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            return(Json(new
            {
                status = status,
                message = message,
                action = action
            }));
        }
예제 #6
0
        public void Submit_OnClick(object sender, EventArgs e)
        {
            _menuInfo.ParentId     = _parentId;
            _menuInfo.Title        = TbTitle.Text;
            _menuInfo.Url          = TbUrl.Text;
            _menuInfo.IsOpenWindow = Convert.ToBoolean(DdlIsOpenWindow.SelectedValue);
            if (_menuId == 0)
            {
                _menuInfo.Id = MenuDao.Insert(_menuInfo);
            }
            else
            {
                MenuDao.Update(_menuInfo);
            }

            Response.Redirect(PageMenu.GetRedirectUrl());
        }
예제 #7
0
 public ActionResult Create(menu idmenu)
 {
     if (ModelState.IsValid)
     {
         var  dao = new MenuDao();
         long id  = dao.Insert(idmenu);
         if (id > 0)
         {
             return(RedirectToAction("Index", "Menu"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm Menu thất bại");
         }
     }
     return(View("Index"));
 }
예제 #8
0
        public ActionResult Create(Menu model)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuDao();

                long id = dao.Insert(model);
                if (id > 0)
                {
                    return(RedirectToAction("Index", "Menu"));
                }
                else
                {
                    ModelState.AddModelError("", "Them menu thanh cong");
                }
            }
            return(View("Index"));
        }
예제 #9
0
 public ActionResult Create(Menu model)
 {
     if (ModelState.IsValid)
     {
         var  dao = new MenuDao();
         long id  = dao.Insert(model);
         if (id > 0)
         {
             SetAlert("Thêm thông tin thành công", "success");
             return(RedirectToAction("Index", "Menu"));
         }
         else
         {
             SetAlert("Thêm user không thành công", "error");
             ModelState.AddModelError("", "Thêm thông tin không thành công");
         }
     }
     return(View());
 }
예제 #10
0
        public ActionResult Create(Menu menu)
        {
            if (ModelState.IsValid)
            {
                var dao = new MenuDao();

                long id = dao.Insert(menu);
                if (id > 0)
                {
                    setAL("Thêm menu thành công", "success");
                    return(RedirectToAction("Index", "MenuAdmin"));
                }
                else
                {
                    setAL("Thêm menu thành công", "error");
                    ModelState.AddModelError("", "Thêm User thành công");
                }
            }
            return(View("Index"));
        }
예제 #11
0
        public ActionResult Create(Menu collection)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // TODO: Add insert logic here

                    MenuDao bdDao = new MenuDao();

                    UserLogin us = (UserLogin)Session[SystemConsts.USER_SESSION];
                    collection.CreatedBy   = us.UserName;
                    collection.CreatedDate = Hepper.GetDateServer();
                    collection.UpdatedBy   = us.UserName;
                    collection.UpdatedDate = Hepper.GetDateServer();
                    collection.LanguageID  = "vi";
                    //collection.CreateBy = us.UserName;
                    //collection.ModifiedBy = us.UserName;
                    if (bdDao.Insert(collection))
                    {
                        SetAlert(@Resources.ResourceAdmin.AdminCreateRecordSuccess, "success");
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        SetAlert(@Resources.ResourceAdmin.AdminCreateRecordFailed, "danger");
                    }
                }
                return(View());
            }
            catch
            {
                SetAlert("Không thêm được", "danger");
                return(View());
            }
        }