Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SellToCustomers sellToCust = SellToCustomers.Invalid;

            Enum.TryParse(Header.SellToCustomerNo, out sellToCust);

            this.thcExternalDocumentNo.Text = SetExternalDocumentNo(sellToCust, Header.ExternalDocumentNo);

            if (SalesOrderCount == 1)
            {
                this.btnExpandCurrentOrder.Visible = false;
                this.SalesOrderSequence.Text       = "Order";
            }
            else
            {
                this.btnExpandCurrentOrder.Visible = true;
                this.SalesOrderSequence.Text       = "Order " + HeadCount.ToString();
                this.btnExpandCurrentOrder.ID      = "btnExpandCurrentOrder_" + CustID.ToString() + "_" + HeadCount.ToString();
            }

            if (Header.IsExchangeOrder)
            {
                this.SalesOrderSequence.Text = "Exchange Order For " + Header.RMANo;
            }

            if (Header.IsPartRequest)
            {
                this.SalesOrderSequence.Text = "Part Request for " + Header.QuoteOrderNo;
            }

            PopulateHeader();
        }
Example #2
0
        public HeadCount UpdateHeadCount(HeadCount headCount)
        {
            var c = ctx.HeadCount.Where(x => x.ID == headCount.ID).First();

            if (c != null)
            {
                c.EmployeeRoleID     = headCount.EmployeeRoleID;
                c.EmployeeRoleTypeID = headCount.EmployeeRoleTypeID;
                c.CountryID          = headCount.CountryID;
                c.Comment            = headCount.Comment;
                c.Year    = headCount.Year;
                c.Month01 = headCount.Month01;
                c.Month02 = headCount.Month02;
                c.Month03 = headCount.Month03;
                c.Month04 = headCount.Month04;
                c.Month05 = headCount.Month05;
                c.Month06 = headCount.Month06;
                c.Month07 = headCount.Month07;
                c.Month08 = headCount.Month08;
                c.Month09 = headCount.Month09;
                c.Month08 = headCount.Month10;
                c.Month10 = headCount.Month11;
                c.Month11 = headCount.Month12;
                ctx.SaveChanges();
            }
            return(c);
        }
Example #3
0
        protected void PopulateData()
        {
            tc = new TableCell();
            tr = new TableRow();

            lineRow  = new TableRow();
            lineCell = new TableCell
            {
                Text       = "<hr class='SeperatorOrders'/>",
                Height     = new Unit("100%"),
                ColumnSpan = 6
            };

            singleReturnOrderDetailTable    = LoadControl(singleReturnOrderDetailPath);
            singleReturnOrderDetailTable.ID = "singleReturnOrderDetailTable_" + HeadCount.ToString();
            ((SingleReturnOrderDetail)singleReturnOrderDetailTable).Rh            = Header;
            ((SingleReturnOrderDetail)singleReturnOrderDetailTable).CountID       = HeadCount;
            ((SingleReturnOrderDetail)singleReturnOrderDetailTable).CustID        = CustID;
            ((SingleReturnOrderDetail)singleReturnOrderDetailTable).CustomerCount = CustomerCount;

            tc.Height     = new Unit("100%");
            tc.ColumnSpan = 6;
            tc.Controls.Add(singleReturnOrderDetailTable);
            tr.Cells.Add(tc);
            tr.ID = "singleReturnOrderDetail_" + CustID.ToString() + "_" + HeadCount.ToString();
            this.tblSingleReturnOrderTableHeader.Rows.Add(tr);
            this.tblSingleReturnOrderTableHeader.Rows.Add(lineRow);
        }
        /// <summary>
        /// UpdateHeadcount
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public static HeadCount UpdateHeadcount(HeadCount member)
        {
            Db.Update <HeadCount>(member);
            var isActive = member.Active == true ? "Active" : "Inactive";

            Console.WriteLine(member.Surname + ", " + member.Forename + " is " + isActive);
            return(member);
        }
 /// <summary>
 /// Check if user present in AD
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 public static HeadCount CheckUserInAD(HeadCount headcount)
 {
     if (String.IsNullOrEmpty(headcount.UserID))
     {
         headcount.Active = null;
     }
     else
     {
         var exists = LDAPHelper.SearchAUserByLogin(headcount.UserID);
         headcount.Active = exists != null ? true : false;
     }
     return(headcount);
 }
        public async Task <IActionResult> Index()
        {
            var orgId = getOrg();

            orgDetails();

            var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
            var user   = await _signInManager.UserManager.FindByIdAsync(userId);

            var userRoles = await _signInManager.UserManager.GetRolesAsync(user);

            ViewData["StatusMessage"] = StatusMessage;

            if (userRoles.Contains("Employee"))
            {
                return(RedirectToAction("Index", "EmployeeProfile"));
            }

            var clients = _context.Clients.Where(a => a.OrganisationId == orgId).ToList();
            var leads   = _context.LeadPolicies.Where(l => l.OrganisationId == orgId).ToList();

            HomeDashboardViewModel hdVM = new HomeDashboardViewModel();

            hdVM.HumanCapacityReport = _context.EmployeeDetails.Where(x => x.OrganisationId == orgId).Count();

            List <HeadCount> headCounts = new List <HeadCount>();
            var department = _context.Departments.Where(x => x.OrganisationId == orgId).ToList();

            var       allJobs = _context.Jobs.Where(x => x.OrganisationId == orgId);
            HeadCount hC;

            foreach (var item in department)
            {
                hC = new HeadCount();

                hC.Department = item.DepartmentName;
                hC.Female     = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Female").ToList().Count();
                hC.Male       = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Male").ToList().Count();

                headCounts.Add(hC);
            }

            hdVM.Clients    = clients.Count;
            hdVM.Leads      = leads.Count;
            hdVM.HeadCounts = headCounts;
            return(View(hdVM));
        }
        /// <summary>
        /// Get Headcount by Id
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public HeadCountDTO Get(HeadCountList r)
        {
            HeadCount headcount = null;
            List <UploadFileDetail> uploadedFiles = null;

            using (var dbCmd = Db.CreateCommand())
            {
                dbCmd.CommandType    = CommandType.StoredProcedure;
                dbCmd.CommandTimeout = 300;
                dbCmd.Parameters.Add(new SqlParameter("@Id", r.Id));
                dbCmd.CommandText = "sp_GetHeadcountDetailById";
                using (var reader = dbCmd.ExecuteReader())
                {
                    headcount = reader.ConvertTo <HeadCount>();
                }
            }

            var result = new HeadCountDTO();

            result.HeadCountItem = headcount == null ? new HeadCount() : headcount;

            //Get File Name with Id
            using (var dbCmd = Db.CreateCommand())
            {
                dbCmd.CommandType    = CommandType.StoredProcedure;
                dbCmd.CommandTimeout = 300;
                dbCmd.Parameters.Add(new SqlParameter("@Id", r.Id));
                dbCmd.CommandText = "sp_GetUploadedFilesByHeadcountId";
                using (var reader = dbCmd.ExecuteReader())
                {
                    uploadedFiles = reader.ConvertToList <UploadFileDetail>();
                }
            }

            if (uploadedFiles.Count > 0)
            {
                result.UploadFileDetails = uploadedFiles;
            }
            else
            {
                result.UploadFileDetails = new List <UploadFileDetail>();
            }

            return(result);
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.thcRMANo.Text = Header.RMANo;

            SellToCustomers sellToCust = SellToCustomers.Invalid;

            Enum.TryParse(Header.SellToCustomerNo, out sellToCust);

            this.thcExternalDocumentNo.Text = SetExternalDocumentNo(sellToCust, Header.ExternalDocumentNo);

            if (ReturnOrdersCount == 1)
            {
                this.ReturnOrderSequence.Text       = "Return";
                this.btnExpandCurrentReturn.Visible = false;
            }
            else
            {
                this.btnExpandCurrentReturn.Visible = true;
                this.ReturnOrderSequence.Text       = "Return " + HeadCount.ToString();
                this.btnExpandCurrentReturn.ID      = "btnExpandCurrentReturn_" + CustID.ToString() + "_" + HeadCount.ToString();
            }

            PopulateData();
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="HeadCount"></param>
        /// <returns></returns>
        public int UpdateHeadCount(List <HeadCountDTO> target, int typeID, int year, int projectID)
        {
            var source = GetHeadCountByType(typeID, year, projectID);

            EmployeeRoleRepository employeeRepository = new EmployeeRoleRepository(BaseRepository.SystemUserID);
            CountryRepository      countryRepository  = new CountryRepository(BaseRepository.SystemUserID);

            // find and insert new items.
            var newItems = target.Except(source, new HeadCountDTOComparer());

            foreach (HeadCountDTO headCountDTO in newItems)
            {
                HeadCount HeadCount = new HeadCount();

                HeadCount.ProjectID          = projectID;
                HeadCount.EmployeeRoleTypeID = typeID;
                HeadCount.Year = year;

                HeadCount.EmployeeRoleID = employeeRepository.GetEmployeeRole(headCountDTO.EmployeeRole).ID;
                HeadCount.CountryID      = countryRepository.GetCountry(headCountDTO.Country).ID;

                HeadCount.Incremental = DataUtility.GetBooleanString(headCountDTO.Incremental);

                HeadCount.Comment = headCountDTO.Comment;
                HeadCount.Month01 = DataUtility.GetDecimalValue(headCountDTO.Month01);
                HeadCount.Month02 = DataUtility.GetDecimalValue(headCountDTO.Month02);
                HeadCount.Month03 = DataUtility.GetDecimalValue(headCountDTO.Month03);
                HeadCount.Month04 = DataUtility.GetDecimalValue(headCountDTO.Month04);
                HeadCount.Month05 = DataUtility.GetDecimalValue(headCountDTO.Month05);
                HeadCount.Month06 = DataUtility.GetDecimalValue(headCountDTO.Month06);
                HeadCount.Month07 = DataUtility.GetDecimalValue(headCountDTO.Month07);
                HeadCount.Month08 = DataUtility.GetDecimalValue(headCountDTO.Month08);
                HeadCount.Month09 = DataUtility.GetDecimalValue(headCountDTO.Month09);
                HeadCount.Month10 = DataUtility.GetDecimalValue(headCountDTO.Month10);
                HeadCount.Month11 = DataUtility.GetDecimalValue(headCountDTO.Month11);
                HeadCount.Month12 = DataUtility.GetDecimalValue(headCountDTO.Month12);

                CreateHeadCount(HeadCount);
            }


            // find and insert new items.
            var updateItems = target.Union(source, new HeadCountDTOComparer());

            foreach (HeadCountDTO headCountDTO in updateItems)
            {
                int employeeRoleID = employeeRepository.GetEmployeeRole(headCountDTO.EmployeeRole).ID;

                HeadCount HeadCount = GetHeadCount(typeID, year, projectID, employeeRoleID);

                HeadCount.EmployeeRoleTypeID = typeID;
                HeadCount.Year      = year;
                HeadCount.ProjectID = projectID;

                HeadCount.EmployeeRoleID = employeeRoleID;
                HeadCount.CountryID      = countryRepository.GetCountry(headCountDTO.Country).ID;

                HeadCount.Incremental = DataUtility.GetBooleanString(headCountDTO.Incremental);

                HeadCount.Comment = headCountDTO.Comment;
                HeadCount.Month01 = DataUtility.GetDecimalValue(headCountDTO.Month01);
                HeadCount.Month02 = DataUtility.GetDecimalValue(headCountDTO.Month02);
                HeadCount.Month03 = DataUtility.GetDecimalValue(headCountDTO.Month03);
                HeadCount.Month04 = DataUtility.GetDecimalValue(headCountDTO.Month04);
                HeadCount.Month05 = DataUtility.GetDecimalValue(headCountDTO.Month05);
                HeadCount.Month06 = DataUtility.GetDecimalValue(headCountDTO.Month06);
                HeadCount.Month07 = DataUtility.GetDecimalValue(headCountDTO.Month07);
                HeadCount.Month08 = DataUtility.GetDecimalValue(headCountDTO.Month08);
                HeadCount.Month09 = DataUtility.GetDecimalValue(headCountDTO.Month09);
                HeadCount.Month10 = DataUtility.GetDecimalValue(headCountDTO.Month10);
                HeadCount.Month11 = DataUtility.GetDecimalValue(headCountDTO.Month11);
                HeadCount.Month12 = DataUtility.GetDecimalValue(headCountDTO.Month12);

                UpdateHeadCount(HeadCount);
            }


            // find and delete items
            var deleteItems = source.Except(target, new HeadCountDTOComparer());

            foreach (HeadCountDTO HeadCountDTO in deleteItems)
            {
                int employeeRoleID = employeeRepository.GetEmployeeRole(HeadCountDTO.EmployeeRole).ID;

                HeadCount HeadCount = GetHeadCount(typeID, year, projectID, employeeRoleID);

                DeleteHeadCount(HeadCount.ID);
            }

            ctx.SaveChanges();

            return(0);
        }
Example #10
0
 /// <summary>
 /// Create HeadCount and at least one HeadCount sign in.
 /// </summary>
 /// <param name="HeadCount"></param>
 /// <returns></returns>
 public HeadCount CreateHeadCount(HeadCount HeadCount)
 {
     ctx.HeadCount.Add(HeadCount);
     ctx.SaveChanges();
     return(HeadCount);
 }
        public IActionResult DashboardHR()
        {
            HRDashboardViewModel     HRDVM             = new HRDashboardViewModel();
            List <LatestEmployeeVM>  lastestEmployeeVM = new List <LatestEmployeeVM>();
            List <LeaveDashVM>       leaveDashVM       = new List <LeaveDashVM>();
            List <RecentApplication> recentAppVM       = new List <RecentApplication>();

            LatestEmployeeVM  latestEmployee;
            LeaveDashVM       leaveDash;
            RecentApplication recentApp;

            var orgId      = getOrg();
            var empList    = _context.Users.Where(x => x.OrganisationId == orgId).ToList();
            var empDetails = _context.EmployeeDetails.Where(x => x.OrganisationId == orgId).ToList();
            var jobs       = _context.Jobs.Where(x => x.OrganisationId == orgId).ToList();

            foreach (var item in empList)
            {
                var empdet = empDetails.Where(x => x.UserId == Guid.Parse(item.Id)).FirstOrDefault();
                if (empdet != null)
                {
                    //try
                    //{
                    latestEmployee = new LatestEmployeeVM()
                    {
                        Id           = empdet.Id,
                        EmployeeName = empdet.FirstName + " " + empdet.LastName,
                        //Department = jobs.Where(x => x.EmployeeDetailId == empdet.Id).FirstOrDefault().Department.DepartmentName,
                        //JobTitle = jobs.Where(x => x.EmployeeDetailId == empdet.Id).FirstOrDefault().JobTitle.JobTitleName,
                        //IsActive = item.Status
                    };

                    lastestEmployeeVM.Add(latestEmployee);

                    //}
                    //catch
                    //{

                    //}
                }
            }

            List <HeadCount> headCounts = new List <HeadCount>();
            var department = _context.Departments.Where(x => x.OrganisationId == orgId).ToList();

            var       allJobs = _context.Jobs.Where(x => x.OrganisationId == orgId);
            HeadCount hC;

            foreach (var item in department)
            {
                hC = new HeadCount();

                hC.Department = item.DepartmentName;
                hC.Female     = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Female").ToList().Count();
                hC.Male       = allJobs.Where(x => x.DepartmentId == item.Id).Where(x => x.EmployeeDetail.Gender == "Male").ToList().Count();

                headCounts.Add(hC);
            }

            var leaves = _context.Leaves.Where(x => x.OrganisationId == orgId);

            HRDVM.ActiveLeaves = leaves.Where(c => c.Status == "Pending").ToList();
            HRDVM.PendingLeave = leaves.Where(c => c.Status == "Approved").Where(x => x.StartDate <DateTime.Now && x.EndDate> DateTime.Now).ToList().Count();



            HRDVM.LatestEmployeeVMs = lastestEmployeeVM;
            HRDVM.TotalEmployee     = empDetails.Count();
            HRDVM.HeadCounts        = headCounts;

            return(View(HRDVM));
        }
        public HeadCountDTO Post(HeadCountSave p)
        {
            using (System.Data.IDbTransaction dbTrans = Db.BeginTransaction())
            {
                try
                {
                    HeadCount HeadCountItem = p.Headcount;
                    //If inserting
                    if (HeadCountItem.Id == 0)
                    {
                        HeadCountItem.CreatedBy   = HeadCountItem.UpdatedBy = WindowsHelper.WindowsUserName;
                        HeadCountItem.CreatedDate = HeadCountItem.UpdatedDate = DateTime.Now;
                        HeadCountItem.Id          = Convert.ToInt32(Db.GetLastInsertId());
                    }
                    // Else updating
                    else
                    {
                        HeadCountItem.UpdatedBy   = WindowsHelper.WindowsUserName;
                        HeadCountItem.UpdatedDate = DateTime.Now;
                    }

                    // Save and Commit all changes to the database
                    Db.Save <HeadCount>(HeadCountItem);


                    if (HeadCountItem.Id == 0)
                    {
                        HeadCountItem.Id = Convert.ToInt32(Db.GetLastInsertId());
                    }

                    List <UploadFileDetail> UploadFileDetailsList = p.UploadFileDetailList;
                    Db.Delete <UploadFileDetail>(x => x.HeadCountID == HeadCountItem.Id);



                    foreach (UploadFileDetail item in UploadFileDetailsList)
                    {
                        Db.Insert(new UploadFileDetail
                        {
                            HeadCountID = HeadCountItem.Id,
                            ContentType = item.ContentType,
                            DisplayName = item.DisplayName,
                            Extension   = item.Extension,
                            FileData    = item.FileData,
                            FileSize    = item.FileSize,
                            Name_File   = item.Name_File,
                            UploadType  = item.UploadType,
                            CreatedBy   = WindowsHelper.WindowsUserName,
                            UpdatedBy   = WindowsHelper.WindowsUserName,
                            CreatedDate = DateTime.Now,
                            UpdatedDate = DateTime.Now
                        });
                    }

                    dbTrans.Commit();

                    HeadCountList r = new HeadCountList();
                    r.Id = HeadCountItem.Id;

                    return(Get(r));
                }
                catch (Exception ex)
                {
                    dbTrans.Rollback();
                    ErrorLogger.InsertError("Could not update HeadCount", ex);
                    throw new Exception("Could not update HeadCount", ex);
                }
            }
        }