Esempio n. 1
0
        public ActionResult Edit(string id, LeaveManagementSystemValueCreed.Models.UsersTable user)
        {
            try
            {
                VC_LMSEntities    d = new VC_LMSEntities();
                List <RolesTable> r = new List <RolesTable>();
                foreach (var item in d.RolesTables)
                {
                    if (item.NAME != "Admin")
                    {
                        r.Add(item);
                    }
                }


                //ViewBag.Managers = new SelectList(d.managers, "manager_emp_id", "name");
                ViewBag.Departments = new SelectList(d.department_tbl, "DEPARTMENT", "DEPARTMENT");
                ViewBag.Roles       = new SelectList(r, "NAME", "NAME");
                if (user.Emp_end_date < user.Emp_start_date)
                {
                    ViewBag.Message = "Date of Joining Can't be Before Date of Leaving";
                    return(View());
                }
                // TODO: Add update logic here
                using (VC_LMSEntities db = new VC_LMSEntities())
                {
                    //var row = db.managers.Where(x => x.manager_emp_id == manger_id).FirstOrDefault();
                    //if (row != null)
                    //{
                    //    user.manager_name = row.name;
                    //}
                    //else
                    //{
                    //    ViewBag.Message = "No Such Manager Exists,Please give correct input or Create a manager";
                    //    return View();
                    //}


                    db.Entry(user).State = System.Data.Entity.EntityState.Modified;

                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 2
0
        // GET: Login/Delete/5
        public ActionResult Autherize(LeaveManagementSystemValueCreed.Models.UsersTable userid)
        {
            if (Session["userID"] != null)
            {
                return(View("Index", userid));
            }

            using (VC_LMSEntities d = new VC_LMSEntities())
            {
                ////var detail = dd.userids.Contains(userid);
                //var details = dd.userids.Where(x => x.userName == userid.userName && x.Password == userid.Password && userid.role == x.role).FirstOrDefault();
                //var name = userid.userName.ToString();
                //var role = userid.role.ToString();
                //var role = d.roles.Find(name).NAME.ToString();
                var details = d.UsersTables.Where(x => x.EMAIL == userid.EMAIL && x.Status == "Active").FirstOrDefault();



                if (details == null)
                {
                    ViewBag.Message = "No such Email Id Present in Database";
                    return(View("Index", userid));
                }
                else
                {
                    VC_LMSEntities e  = new VC_LMSEntities();
                    VC_LMSEntities dd = new VC_LMSEntities();


                    var aprover = e.approvers.Where(x => x.approver_id == details.EMPLOYEE_ID).FirstOrDefault();
                    if (aprover != null)
                    {
                        var id = dd.UsersTables.Where(x => x.EMPLOYEE_ID == aprover.approver_id).FirstOrDefault();
                        Session["userID"]   = id.EMPLOYEE_ID;
                        Session["userName"] = id.FIRST_NAME;
                        Session["Name"]     = id.EMAIL;
                        return(RedirectToAction("Index", "approver"));
                    }
                    foreach (var item in d.UsersTables)
                    {
                        if (userid.EMAIL == item.EMAIL)
                        {
                            if (item.ROLES == "Admin")
                            {
                                Session["userName"] = item.FIRST_NAME;
                                Session["Name"]     = item.EMAIL;
                                Session["userID"]   = item.EMPLOYEE_ID;
                                return(RedirectToAction("Index", "admin"));
                            }
                            else if (item.ROLES == "Employee")
                            {
                                Session["userName"] = item.FIRST_NAME;
                                Session["userID"]   = item.EMPLOYEE_ID;
                                Session["Name"]     = item.EMAIL;
                                return(RedirectToAction("Index", "Employee"));
                            }
                            else if (item.ROLES == "HR")
                            {
                                Session["userName"] = item.FIRST_NAME;
                                Session["userID"]   = item.EMPLOYEE_ID;
                                Session["Name"]     = item.EMAIL;
                                return(RedirectToAction("Index", "HR"));
                            }
                        }
                    }
                }


                return(View("Index", userid));
            }
        }
Esempio n. 3
0
        public ActionResult Create(LeaveManagementSystemValueCreed.Models.UsersTable usr)
        {
            try
            {
                bool t = usr.EMAIL.Contains("valuecreed.com");
                if (t == false)
                {
                    ViewBag.Message = "Please Enter internal Email of ValueCreed";
                    return(View());
                }
                VC_LMSEntities e = new VC_LMSEntities();
                //var managername = e.UsersTables.Where(x => x.EMPLOYEE_ID == usr.manager_id).FirstOrDefault();
                //if (managername == null)
                //{
                //    ViewBag.Message = "Please Select Manager ";
                //    return View();
                //}
                //usr.manager_name = managername.FIRST_NAME;
                //var row = e.UsersTables.Where(x => x.EMPLOYEE_ID == usr.manager_id).FirstOrDefault();

                List <department_tbl> l = new List <department_tbl>();
                List <RolesTable>     r = new List <RolesTable>();
                foreach (var item in e.RolesTables)
                {
                    if (item.NAME != "Admin")
                    {
                        r.Add(item);
                    }
                }
                //ViewData["Manager"] = new SelectList(e.managers, "name", "name");
                ViewData["Department"] = new SelectList(e.department_tbl, "DEPARTMENT", "DEPARTMENT");
                ViewData["Roles"]      = new SelectList(r, "NAME", "NAME");
                VC_LMSEntities d = new VC_LMSEntities();
                if (1 <= usr.Emp_start_date.Month && usr.Emp_start_date.Month < 3)
                {
                    if (usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 1, 15))
                    {
                        usr.leaves_alloted = 5;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 1, 15) && usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 2, 15))
                    {
                        usr.leaves_alloted = 3;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 2, 15))
                    {
                        usr.leaves_alloted = 1;
                    }
                }
                else if (4 <= usr.Emp_start_date.Month && usr.Emp_start_date.Month < 6)
                {
                    if (usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 4, 15))
                    {
                        usr.leaves_alloted = 5;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 4, 15) && usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 5, 15))
                    {
                        usr.leaves_alloted = 3;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 5, 15))
                    {
                        usr.leaves_alloted = 1;
                    }
                }
                else if (7 <= usr.Emp_start_date.Month && usr.Emp_start_date.Month < 9)
                {
                    if (usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 7, 15))
                    {
                        usr.leaves_alloted = 5;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 7, 15) && usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 8, 15))
                    {
                        usr.leaves_alloted = 3;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 8, 15))
                    {
                        usr.leaves_alloted = 1;
                    }
                }
                else if (10 <= usr.Emp_start_date.Month && usr.Emp_start_date.Month < 12)
                {
                    if (usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 10, 15))
                    {
                        usr.leaves_alloted = 5;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 10, 15) && usr.Emp_start_date.Date < new DateTime(usr.Emp_start_date.Year, 11, 15))
                    {
                        usr.leaves_alloted = 3;
                    }
                    else if (usr.Emp_start_date.Date > new DateTime(usr.Emp_start_date.Year, 11, 15))
                    {
                        usr.leaves_alloted = 1;
                    }
                }
                using (VC_LMSEntities dd = new VC_LMSEntities())
                {
                    var user = dd.UsersTables.Where(x => x.EMAIL == usr.EMAIL).FirstOrDefault();
                    if (user != null)
                    {
                        ViewBag.Message = "Email Already Present";
                        return(View());
                    }



                    d.UsersTables.Add(usr);
                    d.SaveChanges();
                }

                ModelState.Clear();
                ViewBag.Meassage = "Creation Success";
                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Some Invalid Values have been given,Please Retry";
                return(View());
            }
        }