// GET: Category/Create public ActionResult Create(StockDiaryReason model, int pageNo = 1) { if (ModelState.IsValid) { //model.Code = AutoNumberHelper.GenerateNumber(ObjectType.Category, db); db.StockDiaryReasons.Add(model); db.SaveChanges(); } return(RedirectToAction("Index", new { PageNo = pageNo })); }
// GET: Category public ActionResult Index(int pageNo = 1, int id = 0, string searchString = "") { var cate = from s in db.StockDiaryReasons select s; if (!String.IsNullOrEmpty(searchString)) { cate = cate.Where(s => s.Text.Contains(searchString)); } var model = new StockDiaryReason(); if (id > 0) { model = db.StockDiaryReasons.Find(id); } BindList(pageNo, cate.ToList()); ViewBag.Types = new SelectList(new [] { new { Id = 1, Text = "Nhập" }, new { Id = 2, Text = "Xuất" } }.ToList(), "Id", "Text", model.Type); return(View(model)); }
// GET: Category/Edit/5 public ActionResult Edit(StockDiaryReason model, int pageNo = 1) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { PageNo = pageNo })); }