Beispiel #1
0
        public ActionResult AdjustLeaveQuotaStepOne()
        {
            string EmpNo        = Request.Form["AdjustEmpNo"].ToString();
            User   LoggedInUser = Session["LoggedUser"] as User;
            var    emp          = db.Emps.Where(aa => aa.EmpNo == EmpNo && aa.Status == true).ToList();

            if (emp.Count > 0)
            {
                //Check for Employee lies under user permission
                if (CheckEmpValidation(emp))
                {
                    int EmpID  = emp.FirstOrDefault().EmpID;
                    var lvType = db.LvConsumeds.Where(aa => aa.EmpID == EmpID).ToList();
                    if (lvType.Count > 0)
                    {
                        //go to next page
                        LeaveQuotaModel lvModel = new LeaveQuotaModel();
                        lvModel.EmpID       = emp.FirstOrDefault().EmpID;
                        lvModel.EmpNo       = emp.FirstOrDefault().EmpNo;
                        lvModel.EmpName     = emp.FirstOrDefault().EmpName;
                        lvModel.SectionName = emp.FirstOrDefault().Section.SectionName;
                        foreach (var lv in lvType)
                        {
                            switch (lv.LeaveType)
                            {
                            case "A":    //CL
                                lvModel.CL = (float)lv.YearRemaining;
                                break;

                            case "B":    //AL
                                lvModel.AL = (float)lv.YearRemaining;
                                break;

                            case "C":    //SL
                                lvModel.SL = (float)lv.YearRemaining;
                                break;
                            }
                        }
                        return(View("AdjustLeaves", lvModel));
                    }
                }
                else
                {
                    ViewBag.CMessage = "Employee No " + Request.Form["AdjustEmpNo"].ToString() + ": Create Leave Quota for this employee";
                }
            }
            else
            {
                ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found";
            }
            ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName");
            ViewBag.CatID      = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName");
            ViewBag.TypeID     = new SelectList(db.EmpTypes.OrderBy(s => s.TypeName), "TypeID", "TypeName");
            return(View("Index"));
        }
Beispiel #2
0
        public ActionResult LvQuotaList(string searchString, string currentFilter, int?page)
        {
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            List <LvConsumed> LeavesQuota = new List <LvConsumed>();

            LeavesQuota = db.LvConsumeds.ToList();
            List <LeaveQuotaModel> _leavesQuotaModel = new List <LeaveQuotaModel>();

            foreach (var item in LeavesQuota)
            {
                if (_leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).Count() > 0)
                {
                    switch (item.LeaveType)
                    {
                    case "A":    //casual
                        _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().CL = (float)item.YearRemaining;
                        break;

                    case "B":    //anual
                        _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().AL = (float)item.YearRemaining;
                        break;

                    case "C":    //sick
                        _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().SL = (float)item.YearRemaining;
                        break;
                    }
                }
                else
                {
                    LeaveQuotaModel lvModel = new LeaveQuotaModel();
                    lvModel.EmpID       = item.Emp.EmpID;
                    lvModel.EmpNo       = item.Emp.EmpNo;
                    lvModel.EmpName     = item.Emp.EmpName;
                    lvModel.SectionName = item.Emp.Section.SectionName;
                    switch (item.LeaveType)
                    {
                    case "A":    //casual
                        lvModel.CL = (float)item.YearRemaining;
                        break;

                    case "B":    //anual
                        lvModel.AL = (float)item.YearRemaining;
                        break;

                    case "C":    //sick
                        lvModel.SL = (float)item.YearRemaining;
                        break;
                    }
                    _leavesQuotaModel.Add(lvModel);
                }
            }
            ViewBag.CurrentFilter = searchString;
            if (!String.IsNullOrEmpty(searchString))
            {
                try
                {
                    _leavesQuotaModel = _leavesQuotaModel.Where(s => s.EmpName.ToUpper().Contains(searchString.ToUpper()) ||
                                                                s.EmpNo.ToUpper().Contains(searchString.ToUpper()) ||
                                                                s.SectionName.ToUpper().Contains(searchString.ToUpper())).ToList();
                }
                catch (Exception ex)
                {
                }
            }
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(_leavesQuotaModel.ToPagedList(pageNumber, pageSize)));
            //return View(_leavesQuotaModel);
        }
        public ActionResult AdjustLeaveQuotaStepOne()
        {
            string EmpNo= Request.Form["AdjustEmpNo"].ToString();
            int CompanyID = Convert.ToInt32(Request.Form["CompanyID"].ToString());
            User LoggedInUser = Session["LoggedUser"] as User;
            var emp = db.Emps.Where(aa => aa.CompanyID == CompanyID && aa.EmpNo == EmpNo && aa.Status==true).ToList();
            if (emp.Count > 0)
            {
                //Check for Employee lies under user permission
                if (CheckEmpValidation(emp))
                {
                    int EmpID = emp.FirstOrDefault().EmpID;
                    var lvType = db.LvConsumeds.Where(aa => aa.EmpID == EmpID).ToList();
                    if (lvType.Count > 0)
                    {
                        //go to next page
                        LeaveQuotaModel lvModel = new LeaveQuotaModel();
                        lvModel.EmpID = emp.FirstOrDefault().EmpID;
                        lvModel.EmpNo = emp.FirstOrDefault().EmpNo;
                        lvModel.EmpName = emp.FirstOrDefault().EmpName;
                        lvModel.SectionName = emp.FirstOrDefault().Section.SectionName;
                        foreach (var lv in lvType)
                        {
                            switch (lv.LeaveType)
                            {
                                case "A"://CL
                                    lvModel.CL = (float)lv.YearRemaining;
                                    break;
                                case "B"://AL
                                    lvModel.AL = (float)lv.YearRemaining;
                                    break;
                                case "C"://SL
                                    lvModel.SL = (float)lv.YearRemaining;
                                    break;
                            }
                        }
                        return View("AdjustLeaves", lvModel);
                    }
                }
                else
                {
                    ViewBag.CMessage = "Employee No " + Request.Form["AdjustEmpNo"].ToString() + ": Create Leave Quota for this employee";
                }
            }
            else
            {
                ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found";

            }
            ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(s=>s.CompName), "CompID", "CompName");
            ViewBag.CompanyIDEmp = new SelectList(db.Companies.OrderBy(s=>s.CompName), "CompID", "CompName");
            ViewBag.LocationID = new SelectList(db.Locations.OrderBy(s=>s.LocName), "LocID", "LocName");
            ViewBag.CatID = new SelectList(db.Categories.OrderBy(s=>s.CatName), "CatID", "CatName");
            return View("Index");
        }
        public ActionResult LvQuotaList(string searchString, string currentFilter, int? page)
        {
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            List<LvConsumed> LeavesQuota = new List<LvConsumed>();
            LeavesQuota = db.LvConsumeds.ToList();
            List<LeaveQuotaModel> _leavesQuotaModel = new List<LeaveQuotaModel>();
            foreach (var item in LeavesQuota)
            {
                if (_leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).Count() > 0)
                {
                    switch (item.LeaveType)
                    {
                        case "A"://casual
                            _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().CL = (float)item.YearRemaining;
                            break;
                        case "B"://anual
                            _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().AL = (float)item.YearRemaining;
                            break;
                        case "C"://sick
                            _leavesQuotaModel.Where(aa => aa.EmpID == item.EmpID).FirstOrDefault().SL = (float)item.YearRemaining;
                            break;
                    }
                }
                else
                {
                    LeaveQuotaModel lvModel = new LeaveQuotaModel();
                    lvModel.EmpID = item.Emp.EmpID;
                    lvModel.EmpNo = item.Emp.EmpNo;
                    lvModel.EmpName = item.Emp.EmpName;
                    lvModel.SectionName = item.Emp.Section.SectionName;
                    switch (item.LeaveType)
                    {
                        case "A"://casual
                            lvModel.CL = (float)item.YearRemaining;
                            break;
                        case "B"://anual
                            lvModel.AL = (float)item.YearRemaining;
                            break;
                        case "C"://sick
                            lvModel.SL = (float)item.YearRemaining;
                            break;
                    }
                    _leavesQuotaModel.Add(lvModel);
                }
            }
            ViewBag.CurrentFilter = searchString;
            if (!String.IsNullOrEmpty(searchString))
            {
                try
                {
                    _leavesQuotaModel = _leavesQuotaModel.Where(s => s.EmpName.ToUpper().Contains(searchString.ToUpper())
                     || s.EmpNo.ToUpper().Contains(searchString.ToUpper())
                     || s.SectionName.ToUpper().Contains(searchString.ToUpper())).ToList();
                }
                catch (Exception ex)
                {

                }
            }
            int pageSize = 10;
            int pageNumber = (page ?? 1);
            return View(_leavesQuotaModel.ToPagedList(pageNumber, pageSize));
            //return View(_leavesQuotaModel);
        }
Beispiel #5
0
        public ActionResult AdjustLeaveQuotaStepOne()
        {
            string   EmpNo = Request.Form["AdjustEmpNo"].ToString();
            DateTime dt    = DateTime.Today;

            if (Request.Form["ALQDate"].ToString() != "")
            {
                string date = Request.Form["ALQDate"].ToString();
                dt = Convert.ToDateTime(date);
            }
            int  CompanyID    = Convert.ToInt32(Request.Form["CompanyID"].ToString());
            User LoggedInUser = Session["LoggedUser"] as User;
            var  emp          = db.Emps.Where(aa => aa.CompanyID == CompanyID && aa.EmpNo == EmpNo && aa.Status == true).ToList();

            if (emp.Count > 0)
            {
                //Check for Employee lies under user permission
                if (CheckEmpValidation(emp))
                {
                    int    EmpID  = emp.FirstOrDefault().EmpID;
                    string year   = dt.Year.ToString();
                    var    lvType = db.LvConsumeds.Where(aa => aa.EmpID == EmpID && aa.Year == year).ToList();
                    if (lvType.Count > 0)
                    {
                        //go to next page
                        LeaveQuotaModel lvModel = new LeaveQuotaModel();
                        lvModel.EmpID       = emp.FirstOrDefault().EmpID;
                        lvModel.EmpNo       = emp.FirstOrDefault().EmpNo;
                        lvModel.EmpName     = emp.FirstOrDefault().EmpName;
                        lvModel.Year        = year;
                        lvModel.SectionName = emp.FirstOrDefault().Section.SectionName;
                        foreach (var lv in lvType)
                        {
                            switch (lv.LeaveType)
                            {
                            case "A":    //CL
                                if (lv.YearRemaining != null)
                                {
                                    lvModel.CL = (float)lv.YearRemaining;
                                }
                                break;

                            case "B":    //AL
                                if (lv.YearRemaining != null)
                                {
                                    lvModel.AL = (float)lv.YearRemaining;
                                }
                                break;

                            case "C":    //SL
                                if (lv.YearRemaining != null)
                                {
                                    lvModel.SL = (float)lv.YearRemaining;
                                }
                                break;

                            case "E":    //CPL
                                if (lv.YearRemaining != null)
                                {
                                    lvModel.CPL = (float)lv.YearRemaining;
                                }
                                break;
                            }
                        }
                        return(View("AdjustLeaves", lvModel));
                    }
                }
                else
                {
                    ViewBag.CMessage = "Employee No " + Request.Form["AdjustEmpNo"].ToString() + ": Create Leave Quota for this employee";
                }
            }
            else
            {
                ViewBag.CMessage = "Employee No " + Request.Form["EmpNo"].ToString() + " not found";
            }
            ViewBag.CompanyID    = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.CompanyIDEmp = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.LocationID   = new SelectList(db.Locations.OrderBy(s => s.LocName), "LocID", "LocName");
            ViewBag.CatID        = new SelectList(db.Categories.OrderBy(s => s.CatName), "CatID", "CatName");
            return(View("Index"));
        }