public ActionResult Create(Expens expens, string expenses_type, string transaction_date, double expenses_amount, string remarks, int staff_id) { DateTime txtmyDate = DateTime.ParseExact(transaction_date, "dd/MM/yyyy", CultureInfo.InvariantCulture); expens.expenses_type = expenses_type; expens.transaction_date = txtmyDate; expens.expenses_amount = expenses_amount; expens.remarks = remarks; expens.staff_id = staff_id; expens.created_by = 1; expens.created_date = System.DateTime.Now; expens.active_flag = true; db.Expenses.Add(expens); db.SaveChanges(); ViewBag.staff_id = new SelectList(db.Staff_Info, "staff_id", "staff_fname", expens.staff_id); ViewBag.created_by = new SelectList(db.Staff_Info, "staff_id", "staff_fname", expens.created_by); return RedirectToAction("Index"); }
public ActionResult Edit(Expens expens) { if (ModelState.IsValid) { db.Entry(expens).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.staff_id = new SelectList(db.Staff_Info, "staff_id", "staff_fname", expens.staff_id); ViewBag.created_by = new SelectList(db.Staff_Info, "staff_id", "staff_fname", expens.created_by); return View(expens); }