public ActionResult AffectedUsers()
        {
            Employee e1 = (Employee)Session["Employee"];

            if (Session["EmpID"] != null && e1.isAdmin == true)
            {
                AssignLeaves al = new AssignLeaves();

                System.Data.DataSet ds = null;
                string Querry          = string.Empty;
                al.AssignType = Request.Form["customRadio"].ToString();
                try
                {
                    if (al.AssignType == "Select Employee")
                    {
                        al.EmployeeID  = Request.Form["emp"].ToString();
                        al.LeaveTypeID = int.Parse(Request.Form["lev"].ToString());
                        al.Count       = double.Parse(Request.Form["count"].ToString());
                        Querry         = string.Format("Select EmployeeName,Departments.Department,LeaveType.LeaveType from Employee inner join Departments on Employee.DepartmentID=Departments.DepartmentID inner join LeaveType on LeaveType.LeaveTypeID='{0}' where EmployeeID='{1}'", al.LeaveTypeID, al.EmployeeID);
                        ds             = ad.ShowAffectedUsers(al, Querry);
                    }
                    else if (al.AssignType == "All(Select Department)")
                    {
                        al.LeaveTypeID  = int.Parse(Request.Form["lev"].ToString());
                        al.Count        = double.Parse(Request.Form["count"].ToString());
                        al.DepartmentID = Request.Form["dep"].ToString();

                        Querry = string.Format("select EmployeeName,Departments.Department,LeaveType.LeaveType from Employee inner join Departments on Employee.DepartmentID=Departments.DepartmentID inner join LeaveType on LeaveType.LeaveTypeID='{0}' where Departments.DepartmentID='{1}'", al.LeaveTypeID, al.DepartmentID);

                        ds = ad.ShowAffectedUsers(al, Querry);
                    }
                    else if (al.AssignType == "All Employess")
                    {
                        al.LeaveTypeID = int.Parse(Request.Form["lev"].ToString());
                        al.Count       = double.Parse(Request.Form["count"].ToString());
                        Querry         = string.Format("select EmployeeName,Departments.Department,LeaveType.LeaveType from Employee inner join Departments on Employee.DepartmentID=Departments.DepartmentID inner join LeaveType on LeaveType.LeaveTypeID='{0}'", al.LeaveTypeID);
                        ds             = ad.ShowAffectedUsers(al, Querry);
                    }
                    Session["AffectedEmp"] = al;
                    ViewBag.Count          = al.Count;
                    return(View(ds));
                }
                catch (NullReferenceException)
                {
                    TempData["ValidationError"] = true;

                    return(RedirectToAction("AssignLeave"));
                }
                catch (FormatException)
                {
                    TempData["ValidationError"] = true;

                    return(RedirectToAction("AssignLeave"));
                }
            }
            else
            {
                return(RedirectToAction("Index", "LogIn"));
            }
        }
Exemple #2
0
        public ActionResult add(int?EmployeeId)
        {
            ViewData["BranchId"] = BRANCHID;
            ViewData["RoleCode"] = ROLECODE;
            var count = salaryStructureHeaderBO.GetListByProperty(x => x.BranchId == BRANCHID && x.IsActive == true).Count();

            ViewData["IsEnable"] = false;
            if (count > 0)
            {
                ViewData["IsEnable"] = true;
            }
            if (EmployeeId != null)
            {
                var empObj = new EmployeeVm();

                empObj.empHeader         = empHeaderBO.GetById(EmployeeId.Value);
                empObj.empPersonalDetail = empPersonalDetailBO.GetByProperty(x => x.EmployeeId == EmployeeId.Value);
                empObj.empWorkDetail     = empWorkDetailBO.GetByProperty(x => x.EmployeeId == EmployeeId.Value);
                empObj.address           = addressBO.GetByProperty(x => x.LinkID == EmployeeId.Value && x.AddressType == UTILITY.EMPLOYEE);
                empObj.empBankdetail     = empbankdetailBO.GetByProperty(x => x.EmployeeId == EmployeeId.Value);
                List <EmployeeDocumentDetail> empDocumentDetList = empDocDetailBO.GetAll().ToList();

                var documentTypeLookupids = lookUpBO.GetByAll()
                                            .Where(x => x.LookUpCategory == UTILITY.CONFIG_DOCUMENTTYPE)
                                            .Select(x => x.LookUpID)
                                            .ToList();
                empDocumentDetList = empDocumentDetList
                                     .Where(x => x.EmployeeId == EmployeeId.Value &&
                                            documentTypeLookupids.Contains(x.DocumentType))
                                     .ToList();

                var codeList = empDocumentDetList.Select(x => x.DocumentType).ToList();

                if (empObj != null)
                {
                    if (empDocumentDetList.Count > 0)
                    {
                        List <EmployeeDocumentVm> docVmList = new List <EmployeeDocumentVm>();
                        foreach (EmployeeDocumentDetail item in empDocumentDetList)
                        {
                            EmployeeDocumentVm docVm = new EmployeeDocumentVm()
                            {
                                DocumentType        = item.DocumentType,
                                DocumentDescription = lookUpBO
                                                      .GetByProperty(y => y.LookUpCategory == UTILITY.CONFIG_DOCUMENTTYPE && y.LookUpID == item.DocumentType)
                                                      .LookUpDescription,
                                fileName         = item.FileName,
                                DocumentDetailId = item.DocumentDetailID
                            };
                            docVmList.Add(docVm);
                        }



                        empObj.empDocument = lookUpBO.GetListByProperty(y => y.LookUpCategory == UTILITY.CONFIG_DOCUMENTTYPE)
                                             .Select(y => new EmployeeDocumentVm
                        {
                            DocumentType        = y.LookUpID,
                            DocumentDescription = y.LookUpDescription
                        }).Where(x => !codeList.Contains(x.DocumentType)).ToList();
                        empObj.empDocument.AddRange(docVmList);

                        ViewData["empdocumentsPath"] = "Uploads/" + empObj.empHeader.EmployeeId + "/";
                    }
                    else
                    {
                        empObj.empDocument = lookUpBO.GetListByProperty(y => y.LookUpCategory == UTILITY.CONFIG_DOCUMENTTYPE)
                                             .Select(y => new EmployeeDocumentVm
                        {
                            DocumentType        = y.LookUpID,
                            DocumentDescription = y.LookUpDescription
                        }).ToList();
                    }
                }
                return(View(empObj));
            }
            else
            {
                var documentTypes = lookUpBO.GetListByProperty(y => y.LookUpCategory == UTILITY.CONFIG_DOCUMENTTYPE)
                                    .Select(x => new EmployeeDocumentVm
                {
                    DocumentType        = x.LookUpID,
                    DocumentDescription = x.LookUpDescription
                }).ToList();
                var listleave = new List <OtherLeave>();
                listleave = otherleaveBo.GetListByProperty(x => x.BranchId == BRANCHID && x.IsActive == true).ToList();

                var List = new List <AssignLeaves>();
                foreach (var item in listleave)
                {
                    var AssignLeaves = new AssignLeaves()
                    {
                        LeaveTypeID = item.LeaveTypeId.Value,
                        Description = item.Description,
                    };

                    List.Add(AssignLeaves);
                }

                return(View(new EmployeeVm
                {
                    empHeader = new EmployeeHeader
                    {
                        EmployeeId = -1, IsActive = true
                    },
                    empDocument = documentTypes,
                    ListAssignLeaves = List,
                    empPersonalDetail = new EmployeePersonalDetail()
                    {
                        Gender = 101
                    }
                }));
            }
        }