public ActionResult AddExpenses(string catogery, string OfficeName, int values, string Comment, ExpensesModel mod) { if (Session["empName"] != null) { string name = Session["empName"].ToString(); var ss = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault(); var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == ss.id).FirstOrDefault(); ViewBag.cat = new SelectList(_db.Expensestypes.ToList(), "id", "catogery"); ViewBag.office = new SelectList(_db.Offices.ToList(), "id", "OfficeName"); if (_allowAll.Staticis == true) { mod.Expensestype = catogery; mod.office = OfficeName; mod.values = values; mod.Comment = Comment; mod.date = DateTime.Now; _db.Expenses.Add(mod); _db.SaveChanges(); var model = new ExpensesAndTypes(); model.officeX = _db.Offices.ToList(); model.expenTypeX = _db.Expensestypes.ToList(); model.expenX = _db.Expenses.ToList(); return(View("Expenses", model)); } } return(RedirectToAction("HavntAccess", "Employees")); }
public ActionResult EditExpenses(int id, ExpensesModel _expen, string OfficeName, string catogery) { if (Session["empName"] != null) { ViewBag.cat = new SelectList(_db.Expensestypes.ToList(), "id", "catogery"); ViewBag.office = new SelectList(_db.Offices.ToList(), "id", "OfficeName"); if (ModelState.IsValid) { _expen.date = DateTime.Now; _expen.office = OfficeName; _expen.Expensestype = catogery; _db.Entry(_expen).State = EntityState.Modified; _db.SaveChanges(); TempData["EpenEdit"] = "تم التعديل بنجاح"; var model = new ExpensesAndTypes(); model.officeX = _db.Offices.ToList(); model.expenTypeX = _db.Expensestypes.ToList(); model.expenX = _db.Expenses.ToList(); return(View("Expenses", model)); } return(View(_expen)); } return(RedirectToAction("HavntAccess", "Employees")); }
public ActionResult Expenses() { if (Session["empName"] != null) { string name = Session["empName"].ToString(); var ss = _db.Employee.Where(d => d.employeeName == name).FirstOrDefault(); var _allowAll = _db.HowCanAcess.Where(s => s.employeeID == ss.id).FirstOrDefault(); if (_allowAll.Staticis == true) { ViewBag.cat = new SelectList(_db.Expensestypes.ToList(), "id", "catogery"); ViewBag.office = new SelectList(_db.Offices.ToList(), "id", "OfficeName"); var model = new ExpensesAndTypes(); model.officeX = _db.Offices.ToList(); model.expenTypeX = _db.Expensestypes.ToList(); model.expenX = _db.Expenses.ToList(); // var expensesVal= _db.Expenses.Sum(f => f.values); // ViewBag.SumofExpenses = expensesVal; return(View(model)); } } return(RedirectToAction("HavntAccess", "Employees")); }