public ActionResult login(string Username, string Password) { Employee user; using (stationeryEntities1 db = new stationeryEntities1()) { user = (from e in db.Employees where e.UserName == Username select e).FirstOrDefault(); //Debug.WriteLine(user.Password); } if (user != null) { if (Password.Equals(user.Password)) { if (user.Designation == "Head" || user.Designation == "Delegate") { Session.Add("user", user); Session.Add("count", 0); return(RedirectToAction("Index", "Hod")); } else if (user.Designation == "Employee" || user.Designation == "Rep") { Session.Add("user", user); Session.Add("count", 0); return(RedirectToAction("Index", "Employee")); } } else { return(RedirectToAction("Index", new { msg = "invalid password" })); } } return(RedirectToAction("Index", new { msg = "invalid user" })); }
public ActionResult edit_delegate(string new_delegate_id, string from_date, string to_date) { Debug.WriteLine(new_delegate_id + from_date + to_date); Employee delegate_; Employee previous_delegate; using (stationeryEntities1 db = new stationeryEntities1()) { delegate_ = db.Employees.Where(e => e.Id == new_delegate_id).FirstOrDefault(); previous_delegate = db.Employees.Where(e => e.DepartmentCode == delegate_.DepartmentCode && e.Designation == "Delegate").FirstOrDefault(); if (previous_delegate != null) { previous_delegate.Designation = "Employee"; previous_delegate.DelegateFrom = null; previous_delegate.DelegateTo = null; } if (delegate_.Designation != "Head") { delegate_.Designation = "Delegate"; delegate_.DelegateFrom = Convert.ToDateTime(from_date); delegate_.DelegateTo = Convert.ToDateTime(to_date); } db.SaveChanges(); } return(View("index")); }
public ActionResult approve_reject(string form_id, string form_status, string comment, string approved_by) { Debug.WriteLine(form_id + form_status + comment); string notify_status = ""; if (form_status.Equals("APPROVE")) { form_status = "approved"; notify_status = "approved_by_hod"; } else { form_status = "rejected"; notify_status = "rejected_by_hod"; } RequisitionForm form; using (stationeryEntities1 db = new stationeryEntities1()) { form = db.RequisitionForms.Find(form_id); form.Status = form_status; form.Comments = comment; form.DateApproved = DateTime.Now.Date; form.ApprovedBy = approved_by; form.Notification = notify_status; db.SaveChanges(); } return(RedirectToAction("Index", "Hod")); }
public ActionResult updatedeptinfo(string rep_id, string coll_point, string current_dept_code) { DepartmentList dept_to_update_coll_point; Employee rep; Employee current_rep; using (stationeryEntities1 db = new stationeryEntities1()) { rep = db.Employees.Find(rep_id); current_rep = db.Employees.Where(e => e.Designation == "Rep" && e.DepartmentCode == rep.DepartmentCode).FirstOrDefault(); if (current_rep != null) { current_rep.Designation = "Employee"; } dept_to_update_coll_point = db.DepartmentLists.Find(current_dept_code); if (rep.Designation != "Head") { rep.Designation = "Rep"; } dept_to_update_coll_point.CollectionPoint = coll_point; db.SaveChanges(); } Debug.WriteLine(dept_to_update_coll_point.DepartmentName + rep.FirstName + current_dept_code); return(View("Index")); }
public ActionResult editdeptinfo(string id) { Employee user = (Employee)Session["user"]; Employee hod; Employee current_rep; DepartmentList dept; List <Employee> emp_list; List <CollectionPoint> coll_list; using (stationeryEntities1 db = new stationeryEntities1()) { hod = db.Employees.Find(user.Id); current_rep = db.Employees.Where(e => e.Designation == "Rep" && e.DepartmentCode == user.DepartmentCode).FirstOrDefault(); if (current_rep == null) { current_rep = hod; } dept = (DepartmentList)db.DepartmentLists.Where(d => d.DepartmentCode == hod.DepartmentCode).FirstOrDefault(); emp_list = db.Employees.Where(e => e.DepartmentCode == hod.DepartmentCode).ToList(); coll_list = db.CollectionPoints.ToList(); } ViewData["current_rep"] = current_rep; ViewData["coll_list"] = coll_list; ViewData["hod"] = hod; ViewData["dept"] = dept; ViewData["emp_list"] = emp_list; return(View()); }
public ActionResult notify() { Employee user = (Employee)Session["user"]; List <RequisitionForm> notify_form_list; using (stationeryEntities1 db = new stationeryEntities1()) { notify_form_list = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).ToList(); } Session["count"] = null; return(RedirectToAction("index")); }
public ActionResult req_forms(string form_id, string notify) { if (notify == "seen") { using (stationeryEntities1 db = new stationeryEntities1()) { db.RequisitionForms.Where(f => f.FormNumber == form_id).FirstOrDefault().Notification = "seen_by_hod"; db.SaveChanges(); } } int count; List <RequisitionForm> notify_form_list; using (stationeryEntities1 db = new stationeryEntities1()) { notify_form_list = db.RequisitionForms.Where(f => f.Notification == "sent_to_hod").ToList(); count = db.RequisitionForms.Where(f => f.Notification == "sent_to_hod").Count(); } Session["count"] = count; Session["notify_form_list"] = notify_form_list; Employee user = (Employee)Session["user"]; List <RequisitionFormDetail> form_cart; RequisitionForm form; List <StationeryCatalog> items; Employee emp; DepartmentList dept; using (stationeryEntities1 db = new stationeryEntities1()) { form = db.RequisitionForms.Find(form_id); form_cart = db.RequisitionFormDetails.Where(f => f.FormNumber == form_id).ToList(); items = db.StationeryCatalogs.ToList(); emp = db.Employees.Where(e => e.Id == form.EmployeeId).FirstOrDefault(); dept = db.DepartmentLists.Where(e => e.DepartmentCode == emp.DepartmentCode).FirstOrDefault(); } ViewData["form_cart"] = form_cart; ViewData["form_number"] = form_id; ViewData["emp"] = emp; ViewData["emp_dept"] = dept; ViewData["catalog_list"] = items; if (form.Status == "pending") { ViewData["req_pending_forms"] = true; } ViewData["req_form"] = form; return(View()); }
// GET: Hod public ActionResult Index() { Employee user = (Employee)Session["user"]; int count; List <RequisitionForm> notify_form_list; using (stationeryEntities1 db = new stationeryEntities1()) { notify_form_list = db.RequisitionForms.Where(f => f.Notification == "sent_to_hod").ToList(); count = db.RequisitionForms.Where(f => f.Notification == "sent_to_hod").Count(); } Session["count"] = count; Session["notify_form_list"] = notify_form_list; return(View()); }
public ActionResult stationaryrequesthistory() { Employee user = (Employee)Session["user"]; List <RequisitionForm> requestlist; List <Employee> emp_list; using (stationeryEntities1 db = new stationeryEntities1()) { emp_list = db.Employees.ToList(); requestlist = db.RequisitionForms.Where(f => db.Employees.Where(e => e.DepartmentCode == user.DepartmentCode).Select(e => e.Id).Contains(f.EmployeeId) && (f.Status == "approved" || f.Status == "rejected")).OrderByDescending(f => f.DateReceived).ToList(); } ViewData["emp_list"] = emp_list; ViewData["userobj"] = user; ViewData["requestlist"] = requestlist; return(View()); }
public ActionResult assigndelegate(string id) { Employee user = (Employee)Session["user"]; Employee delegate_; List <Employee> dept_emp_list; using (stationeryEntities1 db = new stationeryEntities1()) { delegate_ = db.Employees.Where(e => e.Designation == "Delegate" && e.DepartmentCode == user.DepartmentCode).FirstOrDefault(); dept_emp_list = db.Employees.Where(e => e.DepartmentCode == user.DepartmentCode).ToList(); } ViewData["delegate_"] = (delegate_ != null) ? delegate_ : user; ViewData["dept_emp_list"] = dept_emp_list; return(View()); }
// GET: Employee public ActionResult Index(string id) { Employee user = (Employee)Session["user"]; Session["count"] = 0; int count; List <RequisitionForm> notify_form_list; using (stationeryEntities1 db = new stationeryEntities1()) { notify_form_list = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).ToList(); count = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).Count(); } Session["count"] = count; Session["notify_form_list"] = notify_form_list; ViewData["userobj"] = user; return(View()); }
public ActionResult dummy() { List <StationeryCatalog> items; List <RequisitionFormDetail> req_form_details; using (stationeryEntities1 db = new stationeryEntities1()) { items = db.StationeryCatalogs.ToList(); req_form_details = db.RequisitionFormDetails.Where(fdetails => db.RequisitionForms.Where(f => f.Status == "approved").Select(f => f.FormNumber).Contains(fdetails.FormNumber)).ToList(); } foreach (var item in req_form_details) { Debug.WriteLine(item.FormNumber + item.Quantity + item.ItemNumber); } ViewData["req_form_details"] = req_form_details; ViewData["items"] = items; return(View()); }
public ActionResult view_single_request(string form_id, string notify) { employee_utility eu = new employee_utility(); Employee user = (Employee)Session["user"]; List <RequisitionForm> notify_form_list; int count; if (notify == "seen") { using (stationeryEntities1 db = new stationeryEntities1()) { RequisitionForm old_rec_to_update = db.RequisitionForms.Where(e => e.FormNumber == form_id).FirstOrDefault(); if (old_rec_to_update != null) { old_rec_to_update.Notification = "seen_by_emp"; } db.SaveChanges(); } } using (stationeryEntities1 db = new stationeryEntities1()) { notify_form_list = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).ToList(); count = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).Count(); } Session["count"] = count; Session["notify_form_list"] = notify_form_list; ViewData["form_cart"] = eu.get_RequisitionFormDetails(form_id); ViewData["form_number"] = form_id; ViewData["emp"] = eu.get_employee(user); ViewData["emp_dept"] = eu.get_department(user); ViewData["catalog_list"] = eu.get_catalog_items(); ViewData["single_form_view"] = true; ViewData["req_form"] = eu.get_single_form_details(form_id); return(View("newrequest")); }