コード例 #1
0
        public ModelSOTPEmpDetail GetDetailPending(int prid, int EmpID, ViewUserEmp LoggedInUser)
        {
            ModelSOTPEmpDetail vm  = new ModelSOTPEmpDetail();
            PR_PayrollPeriod   prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), prid);
            HR_Employee        emp = db.HR_Employee.First(aa => aa.EmployeeID == EmpID);

            //if (DateTime.Today > prp.SupervisorCutOffDate)
            //    vm.IsLate = true;
            //else
            vm.IsLate  = false;
            vm.EmpID   = (int)EmpID;
            vm.EmpName = emp.FullName;
            vm.DeptID  = (int)emp.SectionID;
            vm.List    = OTHelperRecommended.GetConvertedDailyOTList(db.ViewDailyOTEntries.Where(aa => aa.EmployeeID == vm.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList());
            if (vm.List.Count > 0)
            {
                vm.SystemOT    = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.SystemOTMins));
                vm.ClaimedOT   = OTHelperManager.ConverMinIntoHours(vm.List.Sum(aa => aa.ClaimedOTMins));
                vm.TotalDays   = vm.List.Count();
                vm.TotalAmount = vm.List.Sum(aa => aa.OTAmount);
            }
            vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(OTHelperManager.GetDivisionIDs(OTHelperManager.ConvertDeptIDList(emp.SectionID), db.HR_Section.ToList()), db.BG_OTDivision.ToList(), (int)prp.FinYearID);
            vm.PeriodName         = prp.PName;
            vm.PeriodID           = prp.PID;
            vm.OTPolicy           = "OT Days Forward Policy: Maximum Days in Week = " + emp.Att_OTPolicy.DaysInWeek.ToString() + " , Maximum Days in Month = " + emp.Att_OTPolicy.DaysInMonth.ToString();
            vm.OTPolicyDays       = "OT Claimed Hours Policy: Normal Day= " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayOTStartLimitHour) + " to " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayOTEndLimitHour) + ", Rest & GZ Day= " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayGOTStartLimitHour) + " to " + OTHelperManager.ConverMinIntoHours((int)emp.Att_OTPolicy.PerDayGOTEndLimitHour);
            vm.Count = vm.List.Count;

            ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForApprover(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
            ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForRecommender(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            return(vm);
        }
コード例 #2
0
        public ActionResult DeleteMulti(string Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();

            string[] arrId   = Id.Split(new char[] { ',', '-' }, StringSplitOptions.RemoveEmptyEntries);
            int      counter = 0;

            foreach (var item in arrId)
            {
                int         tid     = Convert.ToInt32(item);
                HR_Employee model   = ctx.HR_Employee.FirstOrDefault(c => c.ID == tid);
                Tapp_User   appUser = ctx.Tapp_User.FirstOrDefault(c => c.UserName == model.uid);
                if (model != null)
                {
                    model.isDelete    = 1;
                    model.Delete_time = DateTime.Now;
                    counter++;
                }
                if (appUser != null)
                {
                    appUser.State = 0;
                }
            }
            if (ctx.SaveChanges() >= 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Id = counter }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", id = counter }), this.JsonContentType()));
        }
コード例 #3
0
 public int Edit(HR_Employee employee)
 {
     try
     {
         HR_Employee _o = this.HR_Employees.Single(o => o.Id == employee.Id);
         _o.FirstName    = employee.FirstName;
         _o.LastName     = employee.LastName;
         _o.FullName     = employee.FullName;
         _o.DepartmentId = employee.DepartmentId;
         _o.JobId        = employee.JobId;
         _o.WorkAddress  = employee.WorkAddress;
         _o.Birthday     = employee.Birthday;
         _o.Email        = employee.Email;
         _o.MobilePhone  = employee.MobilePhone;
         _o.WorkPhone    = employee.WorkPhone;
         _o.WorkEmail    = employee.WorkEmail;
         _o.EmployeeNo   = employee.EmployeeNo;
         this.SubmitChanges();
         return(Core.Variable.DB_UPDATE_SUCCESS);
     }
     catch (Exception _ex)
     {
         throw new Exception(ClassName, _ex);
         //SingletonLogger.Instance.Error(ClassName, _ex);
     }
 }
コード例 #4
0
 public int UploadImageInDataBase(HttpPostedFileBase file, int empID)
 {
     using (var context = new HRMEntities())
     {
         List <HR_EmpImage> _empPhotoList = new List <HR_EmpImage>();
         HR_EmpImage        _EmpPhoto     = new HR_EmpImage();
         HR_Employee        _Emp          = new HR_Employee();
         int empPhotoID = 0;
         _Emp = context.HR_Employee.First(aa => aa.EmployeeID == empID);
         if (context.HR_EmpImage.Where(aa => aa.EmpID == _Emp.EmployeeID).Count() > 0)
         {
             //Update Existing Image
             _EmpPhoto        = context.HR_EmpImage.First(aa => aa.EmpID == _Emp.EmployeeID);
             _EmpPhoto.EmpPic = ConvertToBytes(file);
         }
         else
         {
             //Add New Image
             _EmpPhoto.EmpPic = ConvertToBytes(file);
             _EmpPhoto.EmpID  = _Emp.EmployeeID;
             context.HR_EmpImage.Add(_EmpPhoto);
         }
         try
         {
             empPhotoID = _EmpPhoto.EmpID;
             context.SaveChanges();
             return(empPhotoID);
         }
         catch (Exception ex)
         {
             return(empPhotoID);
         }
     }
 }
コード例 #5
0
 public static Common.Business.HR_Employee Fetch(HR_Employee data)
 {
     Common.Business.HR_Employee item = (Common.Business.HR_Employee)Activator.CreateInstance(typeof(Common.Business.HR_Employee));
     //using (ObjectFactory.BypassPropertyChecks(item))
     {
         item.Client              = data.Client;
         item.EmpCode             = data.EmpCode;
         item.PersonId            = data.PersonId;
         item.EmpTypeCode         = data.EmpTypeCode;
         item.StaffTypeCode       = data.StaffTypeCode;
         item.EmpName             = data.EmpName;
         item.Sex                 = data.Sex;
         item.Country             = data.Country;
         item.Nation              = data.Nation;
         item.Hometown            = data.Hometown;
         item.Addr                = data.Addr;
         item.Birth               = data.Birth;
         item.Photo               = data.Photo;
         item.DepCode             = data.DepCode;
         item.CostCtr             = data.CostCtr;
         item.PositionCode        = data.PositionCode;
         item.PoliStatesCode      = data.PoliStatesCode;
         item.BankCardNo          = data.BankCardNo;
         item.PrimDepCode         = data.PrimDepCode;
         item.RDDepCode           = data.RDDepCode;
         item.Tel                 = data.Tel;
         item.MobTel              = data.MobTel;
         item.Email               = data.Email;
         item.QQNo                = data.QQNo;
         item.WeiNo               = data.WeiNo;
         item.Graduated           = data.Graduated;
         item.GraduatedPro        = data.GraduatedPro;
         item.EduBackground       = data.EduBackground;
         item.Degree              = data.Degree;
         item.TitlesCode          = data.TitlesCode;
         item.PositionTypeCode    = data.PositionTypeCode;
         item.PostCode            = data.PostCode;
         item.SubDirection        = data.SubDirection;
         item.TeacherNo           = data.TeacherNo;
         item.IDCardTypeCode      = data.IDCardTypeCode;
         item.IdNo                = data.IdNo;
         item.PerStatus           = data.PerStatus;
         item.CreatedUser         = data.CreatedUser;
         item.CreatedDate         = data.CreatedDate;
         item.ChangedUser         = data.ChangedUser;
         item.ChangedDate         = data.ChangedDate;
         item.RetireID            = data.RetireID;
         item.IsInReg             = data.IsInReg;
         item.IsSalary            = data.IsSalary;
         item.IsSalReturn         = data.IsSalReturn;
         item.IsInsReturn         = data.IsInsReturn;
         item.SocialSecurityNo    = data.SocialSecurityNo;
         item.OldSocialSecurityNo = data.OldSocialSecurityNo;
         item.HousingFundNo       = data.HousingFundNo;
         item.memo                = data.memo;
     }
     ObjectFactory.MarkAsChild(item);
     ObjectFactory.MarkOld(item);
     return(item);
 }
コード例 #6
0
 public ActionResult Edit(THR_Needs dto)
 {
     if (dto.Id > 0)
     {
         HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
         //THR_Needs needmodel = ctx.THR_Needs.FirstOrDefault(c => c.DeptId == dto.DeptId && c.PostId == dto.PostId && c.IsDelete == 0 && c.Id != dto.Id);
         //if (needmodel != null)
         //{ return Content(this.GetJSON(new { Result = false, Msg = "部门和职位已存在,不能重复添加" }), this.JsonContentType()); }
         THR_Needs model = ctx.THR_Needs.FirstOrDefault(c => c.Id == dto.Id);
         if (dto.NeedQuantity < model.HaveBeenQuantity)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "招聘人数不能小于已招聘人数" }), this.JsonContentType()));
         }
         this.CopyObject <THR_Needs>(model, dto);
         Tapp_User user = this.AppUser();
         model.EditBy   = user.UserName;
         model.EditTime = DateTime.Now;
         if (ctx.SaveChanges() >= 0)
         {
             var m = ctx.THR_Needs.Where(c => c.Id == dto.Id).Select(c => new Hr_NeedDto
             {
                 Id                = c.Id,
                 DeptId            = c.DeptId,
                 DeptName          = c.TErp_Department.DeptName,
                 PostId            = c.PostId,
                 PostName          = c.TErp_Position.PositionName,
                 CutTime           = c.CutTime,
                 Demander          = c.Demander,
                 NeedQuantity      = c.NeedQuantity,
                 Remarks           = c.Remarks,
                 CreateBy          = c.CreateBy,
                 CreateTime        = c.CreateTime,
                 IsDelete          = c.IsDelete,
                 DeleteBy          = c.DeleteBy,
                 DeleteTime        = c.DeleteTime,
                 EditBy            = c.EditBy,
                 EditTime          = c.EditTime,
                 HaveBeenQuantity  = c.HaveBeenQuantity,
                 FileWord          = c.FileWord,
                 JobResponsibility = c.JobResponsibility,
                 PostRequest       = c.PostRequest,
                 IsHaveBeen        = c.IsHaveBeen.Value,
                 InterviewAddress  = c.InterviewAddress,
                 Principal         = c.Principal
             }).FirstOrDefault();
             HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == model.CreateBy);
             if (emp != null)
             {
                 m.CreateBy = emp.name;
             }
             return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), this.JsonContentType()));
         }
         return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
     }
     else
     {
         return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据", Dto = dto }), this.JsonContentType()));
     }
 }
コード例 #7
0
 bool checkPermis(HR_Employee obj, int actionUser, bool isOwner)
 {
     if (isOwner)
     {
         return(true);
     }
     return(obj.CreatedUser == actionUser);
 }
コード例 #8
0
        //Work Times calculation controller
        public void ProcessDailyAttendance(Att_DailyAttendance _attData)
        {
            try
            {
                Att_DailyAttendance       attendanceRecord = _attData;
                HR_Employee               employee         = attendanceRecord.HR_Employee;
                List <Att_ShiftChngedEmp> _shiftEmpCh      = new List <Att_ShiftChngedEmp>();
                _shiftEmpCh = context.Att_ShiftChngedEmp.ToList();
                List <Att_OutPass> _OutPasses = new List <Att_OutPass>();
                _OutPasses = context.Att_OutPass.Where(aa => aa.EmpID == _attData.EmpID && aa.Dated == _attData.AttDate.Value).ToList();
                List <Att_Shift> shifts = new List <Att_Shift>();
                shifts = context.Att_Shift.ToList();
                List <Att_ShiftChanged> cshifts = new List <Att_ShiftChanged>();
                cshifts = context.Att_ShiftChanged.ToList();
                if (_attData.StatusLeave == true)
                {
                    _attData.ShifMin = 0;
                }
                //If TimeIn and TimeOut are not null, then calculate other Atributes
                if (_attData.TimeIn != null && _attData.TimeOut != null)
                {
                    Att_Shift _shift = ProcessSupportFunc.GetEmployeeChangedShift(_attData.HR_Employee, _shiftEmpCh.Where(aa => aa.EmpID == _attData.EmpID).ToList(), _attData.AttDate.Value, shifts);
                    MyShift   shift  = ProcessSupportFunc.GetEmployeeShift(_shift);
                    if (_attData.StatusHL == true)
                    {
                        _attData.ShifMin = ProcessSupportFunc.CalculateShiftMinutes(shift, _attData.AttDate.Value.DayOfWeek);
                        _attData.ShifMin = (short)(_attData.ShifMin / 2);
                    }
                    //If TimeIn = TimeOut then calculate according to DutyCode
                    if (_attData.TimeIn == _attData.TimeOut)
                    {
                        CalculateInEqualToOut(_attData);
                    }
                    else
                    {
                        if (_attData.DutyTime == new TimeSpan(0, 0, 0))
                        {
                            //CalculateWorkMins.CalculateOpenShiftTimes(_attData, shift, _attData.HR_Employee.Att_OTPolicy);
                        }
                        Att_OutPass aop = new Att_OutPass();
                        if (_OutPasses.Where(aa => aa.Dated == _attData.AttDate && aa.EmpID == _attData.EmpID).Count() > 0)
                        {
                            aop = _OutPasses.First(aa => aa.Dated == _attData.AttDate && aa.EmpID == _attData.EmpID);
                        }
                        //CalculateWorkMins.CalculateShiftTimes(_attData, shift, _attData.HR_Employee.Att_OTPolicy, aop);
                    }
                }
                else
                {
                    CalculateInEqualToOut(_attData);
                }
            }
            catch (Exception ex)
            {
            }

            context.SaveChanges();
        }
コード例 #9
0
        public static void BindingManager2Combo(ComboBox cbo)
        {
            HR_EmployeeController _controller = new HR_EmployeeController();
            List <HR_Employee>    _list       = _controller.GetEmployees(-1, -1, -1, string.Empty);

            HR_Employee _item = new HR_Employee();

            _item.Id       = -1;
            _item.FullName = "-- Chọn quản lý --";
            _list.Insert(0, _item);
            cbo.DataSource    = _list;
            cbo.DisplayMember = "FullName";
            cbo.ValueMember   = "Id";
        }
コード例 #10
0
 public int Add(HR_Employee employee)
 {
     try
     {
         this.HR_Employees.InsertOnSubmit(employee);
         this.SubmitChanges();
         return(Core.Variable.DB_INSERT_SUCCESS);
     }
     catch (Exception _ex)
     {
         throw new Exception(ClassName, _ex);
         //SingletonLogger.Instance.Error(ClassName, _ex);
     }
 }
コード例 #11
0
        public ActionResult Add(HR_Employee dto)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            string uid = dto.uid;

            if (ctx.Tapp_User.Count(c => c.UserName == uid) > 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "账号[" + uid + "]已使用", Dto = dto }), this.JsonContentType()));
            }
            if (!dto.dptid.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "请选择部门", Dto = dto }), this.JsonContentType()));
            }
            if (!dto.postid.HasValue)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "请选择职位", Dto = dto }), this.JsonContentType()));
            }
            int deptId = dto.dptid.Value;
            int postId = dto.postid.Value;

            if (ctx.TErp_Department.Count(c => c.Id == deptId && c.IsDelete == 0) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在", Dto = dto }), this.JsonContentType()));
            }
            if (ctx.TErp_Position.Count(c => c.Id == postId && c.IsDelete == 0) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在", Dto = dto }), this.JsonContentType()));
            }
            ctx.HR_Employee.Add(dto);

            Tapp_User use = new Tapp_User();

            use.UserName = dto.uid;
            use.UserPwd  = "123456";

            use.State   = 1;
            use.UserPwd = Md5.Encrypt(dto.uid + "123456");
            ctx.Tapp_User.Add(use);

            if (ctx.SaveChanges() >= 0)
            {
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = dto }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
        }
コード例 #12
0
        public ActionResult Detail(int Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Hr_NeedDto             dto = ctx.THR_Needs.Select(c => new Hr_NeedDto
            {
                Id                = c.Id,
                DeptId            = c.DeptId,
                DeptName          = c.TErp_Department.DeptName,
                PostId            = c.PostId,
                PostName          = c.TErp_Position.PositionName,
                CutTime           = c.CutTime,
                Demander          = c.Demander,
                NeedQuantity      = c.NeedQuantity,
                Remarks           = c.Remarks,
                CreateBy          = c.CreateBy,
                CreateTime        = c.CreateTime,
                IsDelete          = c.IsDelete,
                DeleteBy          = c.DeleteBy,
                DeleteTime        = c.DeleteTime,
                EditBy            = c.EditBy,
                EditTime          = c.EditTime,
                HaveBeenQuantity  = c.HaveBeenQuantity,
                FileWord          = c.FileWord,
                JobResponsibility = c.JobResponsibility,
                PostRequest       = c.PostRequest,
                IsHaveBeen        = c.IsHaveBeen.Value,
                InterviewAddress  = c.InterviewAddress,
                Principal         = c.Principal
            }).FirstOrDefault(c => c.Id == Id);
            HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy);

            if (emp != null)
            {
                dto.CreateBy = emp.name;
            }
            if (dto != null)
            {
                return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType()));
            }
            else
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType()));
            }
        }
コード例 #13
0
        public ActionResult Detail(int Id)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            RecruitModel           dto = ctx.THR_Recruit.Select(c => new RecruitModel
            {
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                Id          = c.Id,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                Status      = c.Status.Value,
                Interview   = c.Interview,
                Email       = c.Email,
                EntryType   = c.EntryType.Value,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                Interviewer = c.Interviewer
            }).FirstOrDefault(c => c.Id == Id);

            if (dto != null)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy);
                if (emp != null)
                {
                    dto.CreateBy = emp.name;
                }
                return(Content(this.GetJSON(new { Result = true, Dto = dto }), this.JsonContentType()));
            }
            else
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "未找到数据" }), this.JsonContentType()));
            }
        }
コード例 #14
0
ファイル: BLLEmployee.cs プロジェクト: war-man/IED_ALone
        private bool CheckExists(string checkValue, int?companyId, int employeeId, int typeOfCheck, IEDEntities db)
        {
            try
            {
                HR_Employee employee = null;
                checkValue = checkValue.Trim().ToUpper();
                if (typeOfCheck == 1)
                {
                    employee = db.HR_Employee.FirstOrDefault(x => !x.IsDeleted && x.CompanyId == companyId && x.Id != employeeId && x.Code.Trim().ToUpper().Equals(checkValue));
                }

                if (employee == null)
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #15
0
        internal static Att_Shift GetEmployeeChangedShift(HR_Employee emp, List <Att_ShiftChngedEmp> empshiftCh, DateTime currentDate, List <Att_Shift> shifts)
        {
            Att_Shift shift = emp.Att_Shift;

            foreach (var item in empshiftCh)
            {
                if (item.EndDate == null)
                {
                    if (currentDate >= item.StartDate)
                    {
                        shift = shifts.First(aa => aa.ShftID == item.ShiftID);
                    }
                }
                else
                {
                    if (currentDate >= item.StartDate && currentDate <= item.EndDate)
                    {
                        shift = shifts.First(aa => aa.ShftID == item.ShiftID);
                    }
                }
            }
            return(shift);
        }
コード例 #16
0
        /// <summary>
        /// model
        /// </summary>
        /// <param name="pId"></param>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private static RecruitModel GetRecruitModel(int pId, HKSJRecruitmentContext pctx)
        {
            RecruitModel dto = pctx.THR_Recruit.Select(c => new RecruitModel
            {
                Id          = c.Id,
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                NeedsId     = c.NeedsId,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                Status      = c.Status.Value,
                StatusName  = c.Tapp_Param.ParamsName,
                Interview   = c.Interview,
                Email       = c.Email,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                DeleteBy    = c.DeleteBy,
                DeleteTime  = c.DeleteTime,
                EditBy      = c.EditBy,
                EditTime    = c.EditTime,
                Interviewer = c.Interviewer,
                IsHaveBeen  = c.THR_Needs.IsHaveBeen.Value
            }).FirstOrDefault(c => c.Id == pId);
            HR_Employee emp = pctx.HR_Employee.FirstOrDefault(c => c.uid == dto.CreateBy);

            if (emp != null)
            {
                dto.CreateBy = emp.name;
            }
            return(dto);
        }
コード例 #17
0
        public ModelSOTPEmpDetail GetDetailPendingHR(int prid, int EmpID, ViewUserEmp LoggedInUser)
        {
            ModelSOTPEmpDetail vm  = new ModelSOTPEmpDetail();
            PR_PayrollPeriod   prp = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), prid);
            HR_Employee        emp = db.HR_Employee.First(aa => aa.EmployeeID == EmpID);

            if (DateTime.Today > prp.SupervisorCutOffDate)
            {
                vm.IsLate = true;
            }
            else
            {
                vm.IsLate = false;
            }
            vm.EmpID   = (int)EmpID;
            vm.EmpName = emp.FullName;
            int amount = 0;

            if (LoggedInUser.UserType == "H" || LoggedInUser.UserType == "A")
            {
                ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
                ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            }
            else
            {
                ViewBag.DecisionID  = new SelectList(OTHelperManager.GetOTStatusForSupervisor(db.Att_OTStatus.ToList()), "PSID", "StatusName", "F");
                ViewBag.RecommendID = new SelectList(OTHelperManager.GetUsersForSupervisor(db.ViewUserEmps.Where(aa => aa.EmpStatus == "Active").ToList()), "UserID", "FullName");
            }
            vm.List = OTHelperRecommended.GetConvertedDailyOTListSimple(db.ViewDailyOTEntries.Where(aa => aa.EmpID == EmpID && aa.OTProcessingPeriodID == prp.PID).ToList());
            vm.DivRemainingBudget = OTHelperManager.GetDivRemainingBudget(OTHelperManager.ConvertDeptIDList(emp.SectionID), db.BG_OTDivision.ToList(), (int)prp.FinYearID);
            vm.PeriodName         = prp.PName;
            vm.PeriodID           = prp.PID;
            vm.OTPolicy           = "Policy Details: Maximum Days in Week = " + emp.Att_OTPolicy.DaysInWeek.ToString() + " , Maximum Days in Month = " + emp.Att_OTPolicy.DaysInMonth.ToString();
            vm.TotalAmount        = amount;
            vm.Count = vm.List.Count;
            return(vm);
        }
コード例 #18
0
 public int UploadImageInDataBase(string Path, HR_Employee _Emp)
 {
     using (var context = new HRMEntities())
     {
         List <HR_EmpImage> _empPhotoList = new List <HR_EmpImage>();
         HR_EmpImage        _EmpPhoto     = new HR_EmpImage();
         int empPhotoID = 0;
         _empPhotoList = context.HR_EmpImage.Where(aa => aa.EmpID == _Emp.EmployeeID).ToList();
         Image  img  = Image.FromFile(Path);
         byte[] bArr = imgToByteArray(img);
         _EmpPhoto.EmpPic = bArr;
         if (_empPhotoList.Count > 0)
         {
             //Update Existing Image
             _EmpPhoto        = context.HR_EmpImage.First(aa => aa.EmpID == _Emp.EmployeeID);
             _EmpPhoto.EmpID  = _empPhotoList.FirstOrDefault().EmpID;
             _EmpPhoto.EmpPic = bArr;
         }
         else
         {
             //Add New Image
             _EmpPhoto.EmpID = _Emp.EmployeeID;
             context.HR_EmpImage.Add(_EmpPhoto);
         }
         try
         {
             //empPhotoID = _EmpPhoto.EmpPic;
             context.SaveChanges();
             return(empPhotoID);
         }
         catch (Exception ex)
         {
             return(empPhotoID);
         }
     }
 }
コード例 #19
0
        public ActionResult Add(THR_Needs dto)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            int deptId = dto.DeptId;
            int postId = dto.PostId;

            if (ctx.TErp_Department.Count(c => c.Id == deptId) == 0)
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在,请在组织架构中维护" }), this.JsonContentType()));
            }
            if (dto.NeedsPostId > 0)
            {
                if (ctx.TErp_Position.Count(c => c.Id == dto.NeedsPostId) == 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
                }
                dto.PostId = dto.NeedsPostId;
            }
            else
            {
                if (ctx.TErp_Position.Count(c => c.Id == postId) == 0)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在,请在职位管理中维护" }), this.JsonContentType()));
                }
                dto.NeedsPostId = 0;
            }
            if (string.IsNullOrEmpty(dto.CutTime.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "截止时间不能为空" }), this.JsonContentType()));
            }
            DateTime cuttime;

            if (!DateTime.TryParse(dto.CutTime.ToString(), out cuttime) && !string.IsNullOrEmpty(dto.CutTime.ToString()))
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "截止时间格式不正确" }), this.JsonContentType()));
            }
            //THR_Needs needmodel = ctx.THR_Needs.FirstOrDefault(c => c.DeptId == dto.DeptId && c.PostId == dto.PostId && c.IsDelete == 0 && c.IsHaveBeen == 0);
            //if (needmodel != null)
            //{ return Content(this.GetJSON(new { Result = false, Msg = "部门和职位已存在,不能重复添加" }), this.JsonContentType()); }
            Tapp_User user = this.AppUser();

            dto.CreateBy   = user.UserName;
            dto.CreateTime = DateTime.Now;
            dto.IsHaveBeen = 0;
            ctx.THR_Needs.Add(dto);
            if (ctx.SaveChanges() >= 0)
            {
                var model = ctx.THR_Needs.Where(c => c.Id == dto.Id).Select(c => new Hr_NeedDto
                {
                    Id                = c.Id,
                    DeptId            = c.DeptId,
                    DeptName          = c.TErp_Department.DeptName,
                    PostId            = c.PostId,
                    PostName          = c.TErp_Position.PositionName,
                    CutTime           = c.CutTime,
                    Demander          = c.Demander,
                    NeedQuantity      = c.NeedQuantity,
                    Remarks           = c.Remarks,
                    CreateBy          = c.CreateBy,
                    CreateTime        = c.CreateTime,
                    IsDelete          = c.IsDelete,
                    DeleteBy          = c.DeleteBy,
                    DeleteTime        = c.DeleteTime,
                    EditBy            = c.EditBy,
                    EditTime          = c.EditTime,
                    HaveBeenQuantity  = c.HaveBeenQuantity,
                    FileWord          = c.FileWord,
                    JobResponsibility = c.JobResponsibility,
                    PostRequest       = c.PostRequest,
                    IsHaveBeen        = c.IsHaveBeen.Value,
                    InterviewAddress  = c.InterviewAddress,
                    Principal         = c.Principal
                }).FirstOrDefault();
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == model.CreateBy);
                if (emp != null)
                {
                    model.CreateBy = emp.name;
                }
                return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = model }), this.JsonContentType()));
            }
            return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
        }
コード例 #20
0
        public ActionResult AOTDetailList(ModelSOTPEmpDetail model)
        {
            List <string>    messages        = new List <string>();
            ViewUserEmp      LoggedInUser    = Session["LoggedUser"] as ViewUserEmp;
            var              checkedEmpDates = Request.Form.GetValues("cbEmployee");
            HR_Employee      emp             = db.HR_Employee.First(aa => aa.EmployeeID == model.EmpID);
            PR_PayrollPeriod prp             = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), model.PeriodID);

            model.Certified = true;
            messages        = IsValidate(model, checkedEmpDates);
            if (messages.Count == 0)
            {
                List <Att_OTDailyEntry> attOts     = db.Att_OTDailyEntry.Where(aa => aa.EmpID == model.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList();
                List <Att_OTDailyEntry> TempattOts = new List <Att_OTDailyEntry>();
                foreach (var id in checkedEmpDates)
                {
                    int              chNo    = Convert.ToInt32(id);
                    string           EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                    string           COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                    int              COTMins = OTHelperManager.ConvertStringTimeToMin(COTHour);
                    Att_OTDailyEntry obj     = attOts.First(aa => aa.EmpDate == EmpDate);
                    obj.ApprovedOTMin = COTMins;
                    obj.OTAmount      = OTHelperManager.GetOTAmount(emp.HR_Grade, obj.ApprovedOTMin, obj.DutyCode);
                    TempattOts.Add(obj);
                }
                if (emp.Att_OTPolicy.DaysInMonth > 0)
                {
                    List <Att_OTDailyEntry> atoTemp = new List <Att_OTDailyEntry>();
                    atoTemp.AddRange(TempattOts);
                    //atoTemp.AddRange(attOts.Where(aa => aa.StatusID == "F" || aa.StatusID == "A").ToList());
                    // check for Monthly Limit
                    if (atoTemp.Count > emp.Att_OTPolicy.DaysInMonth)
                    {
                        messages.Add("Your Monthly overtime claim limit exceeds.");
                    }
                    else
                    {
                        // check for weekly limit
                        if (emp.Att_OTPolicy.DaysInWeek > 0)
                        {
                            if (OTHelperManager.IsValidWeekPolicy(atoTemp.OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.Att_OTPolicy.DaysInWeek))
                            {
                                messages.Add("Your weekly overtime claim limit exceeds.");
                            }
                        }
                    }
                }
                // check for daily ot limit
                {
                    List <string> msgs = OTHelperManager.IsValidDailyOT(TempattOts, emp.Att_OTPolicy);
                    if (msgs.Count > 0)
                    {
                        messages.AddRange(msgs);
                    }
                }
                if (checkedEmpDates != null)
                {
                    if (messages.Count == 0)
                    {
                        int CurrentPeriodID = db.PR_PayrollPeriod.OrderByDescending(aa => aa.PID).First().PID;
                        foreach (var id in checkedEmpDates)
                        {
                            int              chNo      = Convert.ToInt32(id);
                            string           oldStatus = "P";
                            string           EmpDate   = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                            string           COTHour   = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                            Att_OTDailyEntry atot      = attOts.First(aa => aa.EmpDate == EmpDate);
                            // Save Log
                            db.Att_OTDForward.Add(OTHelperManager.CreateOTLog(atot, LoggedInUser, model.RecommendID, model.Justification, model.DecisionID, "Recommend", CurrentPeriodID));
                            oldStatus     = atot.StatusID;
                            atot.StatusID = model.DecisionID;
                            if (LoggedInUser.UserType == "R")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                    atot.CancelByID           = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = CurrentPeriodID;
                                }
                                else
                                {
                                    if (model.IsLate == true)
                                    {
                                        atot.Remarks = model.Justification;
                                    }
                                    atot.ApprovedByID         = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = CurrentPeriodID;
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                }
                            }
                        }
                        db.SaveChanges();

                        // Cancel All others
                        foreach (var item in attOts.Where(aa => aa.EmpID == model.EmpID && aa.StatusID == "P").ToList())
                        {
                            item.StatusID             = "R";
                            item.PtoFCDateTime        = DateTime.Now;
                            item.PtoFCUserID          = LoggedInUser.UserID;
                            item.CancelByID           = LoggedInUser.UserID;
                            item.OTProcessingPeriodID = CurrentPeriodID;
                        }
                        db.SaveChanges();
                        return(Json("OK"));
                    }
                }
                else
                {
                    messages.Add("No Entry Selected");
                }
            }
            return(Json(messages));
        }
コード例 #21
0
        private IPageList <Hr_NeedDto> GetNeedData(Hr_NeedQueryParam queryParam)
        {
            HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            Expression <Func <THR_Needs, bool> > predicate = SearchPredicate(queryParam);


            //var models = ctx.THR_Needs
            //    .Join(ctx.HR_Employee, left => left.CreateBy, right => right.uid, (left, right) => new Hr_NeedDto
            //    {
            //        Id = left.Id,
            //        DeptId = left.DeptId,
            //        DeptName = left.TErp_Department.DeptName,
            //        PostId = left.PostId,
            //        PostName = left.TErp_Position.PositionName,
            //        CutTime = left.CutTime,
            //        Demander = left.Demander,
            //        NeedQuantity = left.NeedQuantity,
            //        Remarks = left.Remarks,
            //        CreateBy = right.name,
            //        CreateTime = left.CreateTime,
            //        IsDelete = left.IsDelete,
            //        DeleteBy = left.DeleteBy,
            //        DeleteTime = left.DeleteTime,
            //        EditBy = left.EditBy,
            //        EditTime = left.EditTime,
            //        HaveBeenQuantity = left.HaveBeenQuantity,
            //        FileWord = left.FileWord
            //    })
            //    .Where(predicate)
            //    .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
            //    .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            IPageList <Hr_NeedDto> models = ctx.THR_Needs
                                            .Where(predicate)
                                            .OrderUsingSortExpression(queryParam.Sort.Replace("deptname", "deptid").Replace("postname", "postid"), queryParam.Order)
                                            .Select(c => new Hr_NeedDto
            {
                Id                = c.Id,
                DeptId            = c.DeptId,
                DeptName          = c.TErp_Department.DeptName,
                PostId            = c.PostId,
                PostName          = c.TErp_Position.PositionName,
                CutTime           = c.CutTime,
                Demander          = c.Demander,
                NeedQuantity      = c.NeedQuantity,
                Remarks           = c.Remarks,
                CreateBy          = c.CreateBy,
                CreateTime        = c.CreateTime,
                IsDelete          = c.IsDelete,
                DeleteBy          = c.DeleteBy,
                DeleteTime        = c.DeleteTime,
                EditBy            = c.EditBy,
                EditTime          = c.EditTime,
                HaveBeenQuantity  = c.HaveBeenQuantity,
                FileWord          = c.FileWord,
                JobResponsibility = c.JobResponsibility,
                PostRequest       = c.PostRequest,
                IsHaveBeen        = c.IsHaveBeen.Value,
                InterviewAddress  = c.InterviewAddress,
                Principal         = c.Principal
            })
                                            .ToPagedList(queryParam.PageIndex, queryParam.PageSize);

            foreach (var item in models)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == item.CreateBy);
                if (emp != null)
                {
                    item.CreateBy = emp.name;
                }
            }
            return(models);
        }
コード例 #22
0
    protected void btnJournalEntry_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["ID"] != null)
        {
            #region Update preentry process

            HR_Employee employee = new HR_Employee();
            employee.EmployeeID = Convert.ToString(Request.QueryString["ID"]);
            employee.ResignDescription = txtResignDescription.Text.Trim();
            employee.ResignDate = Convert.ToDateTime(txtResignDate.Text.Trim());
            employee.Flag = false;

            string userID = Profile.card_id;
            employee.ModifiedBy = userID;
            employee.ModifiedDate = DateTime.Now;

            HR_ProvidentFundRegister providentFundRegister = new HR_ProvidentFundRegister();
            if (lblEmpPortionFund.Text.Trim() != string.Empty)
            {
                providentFundRegister.EmployeeID = Convert.ToString(Request.QueryString["ID"]);
                providentFundRegister.PayrollMonthDate = DateTime.Now;
                providentFundRegister.WithdrawAmount = Convert.ToDecimal(lblEmpPortionFund.Text.Trim());
                providentFundRegister.WithdrawLastDate = DateTime.Now;
                providentFundRegister.AddedBy = userID;
                providentFundRegister.AddedDate = DateTime.Now;

            }
            bool isUpdate = HR_EmployeeManager.UpdateHR_EmployeeResignInfo(employee);
            if (isUpdate)
            {
                if (providentFundRegister.EmployeeID != string.Empty)
                {
                    HR_ProvidentFundRegisterManager.InsertHR_ProvidentFundRegisterWithdrawAmount(providentFundRegister);
                }
                lblMessage.Text = "Information is saved successfully";
                lblMessage.ForeColor = System.Drawing.Color.Green;
            }

            if (Convert.ToDecimal(txtRemainingSalary.Text) > 0)
            {
                ACC_EmployPayRoleSalary paySalary = new ACC_EmployPayRoleSalary();
                paySalary.AddedBy = userID;
                paySalary.AddedDate = DateTime.Now;
                paySalary.UpdatedBy = userID;
                paySalary.UpdatedDate = DateTime.Now;
                paySalary.EmployeeID = Request.QueryString["ID"];
                paySalary.SalaryAmount = Convert.ToDecimal(txtRemainingSalary.Text);
                paySalary.PaidSalaryAmount = Convert.ToDecimal("0");
                paySalary.UnpaidSalaryAmount = Convert.ToDecimal(txtRemainingSalary.Text);
                paySalary.Status = 35;
                paySalary.RowStatusID = 1;
                paySalary.SalaryOfDate = DateTime.Parse(txtResignDate.Text).ToString("MMMM, yyyy");
                paySalary.ExtraField1 = lblSalaryBreakDown.Text;
                paySalary.ExtraField2 = paySalary.SalaryAmount.ToString("00");
                paySalary.ExtraField3 = string.Empty;
                paySalary.ExtraField4 = string.Empty;
                paySalary.ExtraField5 = string.Empty;
                paySalary.ExtraField6 = string.Empty;
                paySalary.ExtraField7 = string.Empty;
                paySalary.ExtraField8 = string.Empty;
                paySalary.ExtraField9 = string.Empty;
                paySalary.ExtraField10 = string.Empty;

                int insertedID = ACC_EmployPayRoleSalaryManager.InsertEmployPayRoleSalary(paySalary);
            }
            #endregion

            #region Journal entry
            List<ACC_Journal> doubleEntry = new List<ACC_Journal>();
            doubleEntry = (List<ACC_Journal>)Session["doubleEntry"];

            List<ACC_CUCCheck> cucChecks = new List<ACC_CUCCheck>();
            if (Session["cucCheck"] != null) cucChecks = (List<ACC_CUCCheck>)Session["cucCheck"];

            ACC_JournalMaster aCC_JournalMaster = new ACC_JournalMaster();
            aCC_JournalMaster.JournalMasterName = "";
            aCC_JournalMaster.AddedBy = Profile.card_id;
            aCC_JournalMaster.AddedDate = DateTime.Now;
            aCC_JournalMaster.UpdatedBy = Profile.card_id;
            aCC_JournalMaster.UpdateDate = DateTime.Now;
            aCC_JournalMaster.RowStatusID = 1;
            aCC_JournalMaster.JournalMasterID = ACC_JournalMasterManager.InsertACC_JournalMaster(aCC_JournalMaster);

            if (doubleEntry != null)
            {
                foreach (ACC_Journal eachJournal in doubleEntry)
                {
                    int temp = eachJournal.JournalID;
                    string checkno = eachJournal.JournalVoucherNo;

                    eachJournal.JournalVoucherNo = "";
                    eachJournal.JournalMasterID = aCC_JournalMaster.JournalMasterID;
                    eachJournal.JournalID = ACC_JournalManager.InsertACC_Journal(eachJournal);

                    foreach (ACC_CUCCheck cucCheck in cucChecks)
                    {
                        if (temp == cucCheck.PaytoHeadID)
                        {
                            cucCheck.PaytoHeadID = eachJournal.JournalID;
                            ACC_CUCCheckManager.InsertACC_CUCCheck(cucCheck);
                        }
                    }
                }
            }
            if (Session["cucCheck"] != null) Session.Remove("cucCheck");
            if (Session["doubleEntry"] != null) Session.Remove("doubleEntry");

            #endregion
            /*
             * <option value="46">Employee Provident Fund</option>
             * <option value="47" selected="selected">Company Provident Fund</option>
             * <option value="3" selected="selected">Advance Salary</option>
             * <option value="17" selected="selected">Employee(Fulltime) Salary</option>
             * <option value="49" selected="selected">Allowance (Provident Fund)</option>
             */

            decimal advanceSalaryAmount = decimal.Parse(txtAdvanceSalary.Text);
            decimal salaryOfthisMonth = decimal.Parse(txtSalaryOfThisMonth.Text);
            decimal totalJournalEntryMoney = decimal.Parse(txtFinalAmountToWithDraw.Text);
            decimal EPFMoney = decimal.Parse(txtEmpContributionAmount.Text);
            decimal CPFMoney =decimal.Parse(lblEmpPortionFund.Text) - decimal.Parse(txtEmpContributionAmount.Text);

            //CPF need to process
            //Refund CPF
            if (decimal.Parse(lblReturnFundToCompany.Text) > 0)
            {
                processRefundCPF(decimal.Parse(lblReturnFundToCompany.Text));
            }

            #region Advance Salary process

            //advance salary deduction form the fulltime salary
            if (advanceSalaryAmount > 0)
            {
                if (salaryOfthisMonth > 0)
                {
                   if (advanceSalaryAmount <= salaryOfthisMonth)
                    {
                       processAdvanceSalary(advanceSalaryAmount);
                       advanceSalaryAmount = 0;
                       salaryOfthisMonth -= advanceSalaryAmount;
                    }
                    else
                    {
                        processAdvanceSalary(salaryOfthisMonth);
                        salaryOfthisMonth = 0;
                        advanceSalaryAmount -= salaryOfthisMonth;
                    }
                }
            }

            //remaining salary deduction from the Employee Provident fund contribution
            if (advanceSalaryAmount > 0)
            {
                if (EPFMoney > 0)
                {
                    if (advanceSalaryAmount <= EPFMoney)
                    {
                        processAdvanceSalaryFromEPF(advanceSalaryAmount);
                        advanceSalaryAmount = 0;
                        EPFMoney -= advanceSalaryAmount;
                    }
                    else
                    {
                        processAdvanceSalaryFromEPF(EPFMoney);
                        EPFMoney = 0;
                        advanceSalaryAmount -= EPFMoney;
                    }
                }
            }
            bool IsNeedtoCollectMoneyFortheAdvanceSalary = false;
            //remaining salary deduction from the Company Provident fund contribution
            if (advanceSalaryAmount > 0)
            {
                if (CPFMoney > 0)
                {
                    if (advanceSalaryAmount <= CPFMoney)
                    {
                        processAdvanceSalaryFromCPF(advanceSalaryAmount);
                        advanceSalaryAmount = 0;
                        CPFMoney -= advanceSalaryAmount;
                    }
                    else
                    {
                        processAdvanceSalaryFromCPF(EPFMoney);
                        CPFMoney = 0;
                        advanceSalaryAmount -= CPFMoney;
                        IsNeedtoCollectMoneyFortheAdvanceSalary = true;
                    }
                }
            }
            #endregion

            #region Fulltime Salary Process
            if (salaryOfthisMonth > 0)
            {
                processFullTimeSalary(salaryOfthisMonth, aCC_JournalMaster.JournalMasterID);
                totalJournalEntryMoney -= salaryOfthisMonth;
                salaryOfthisMonth = 0;
            }
            #endregion

            #region EPF Process
            if (EPFMoney > 0)
            {
                processEPF(EPFMoney, aCC_JournalMaster.JournalMasterID);
                totalJournalEntryMoney -= EPFMoney;
                EPFMoney = 0;
            }
            #endregion

            #region CPF Process
            if (CPFMoney > 0)
            {
                processCPF(CPFMoney, aCC_JournalMaster.JournalMasterID);
                totalJournalEntryMoney -= CPFMoney;
                CPFMoney = 0;
            }
            #endregion

            if (decimal.Parse(txtSalaryOfThisMonth.Text) > 0)
            {
                DataSet dsHeadUserFulltimeSalary = ACC_HeadUserManager.GetACC_UserByUserIDnUserTypeIDnAccountID(hfEmployeeID.Value, 2, int.Parse(ddlAccountForMoney.SelectedValue));
            }

            //if (IsNeedtoCollectMoneyFortheAdvanceSalary)
            //{
            //    Response.Redirect("");
            //}
            btnJournalEntry.Visible = false;
        }
    }
コード例 #23
0
ファイル: HR_EmployeeProvider.cs プロジェクト: anam/mal
    public bool UpdateHR_EmployeeResignInfo(HR_Employee hR_Employee)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateHR_EmployeeResignInfo", connection);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = hR_Employee.EmployeeID;
            cmd.Parameters.Add("@ResignDate", SqlDbType.DateTime).Value = hR_Employee.ResignDate;
            cmd.Parameters.Add("@ResignDescription", SqlDbType.NVarChar).Value = hR_Employee.ResignDescription;
            cmd.Parameters.Add("@Flag", SqlDbType.Bit).Value = hR_Employee.Flag;
            cmd.Parameters.Add("@ModifiedBy", SqlDbType.NVarChar).Value = hR_Employee.ModifiedBy;
            cmd.Parameters.Add("@ModifiedDate", SqlDbType.DateTime).Value = hR_Employee.ModifiedDate;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
コード例 #24
0
ファイル: BLLEmployee.cs プロジェクト: war-man/IED_ALone
        public ResponseBase CreateOrUpdate(EmployeeModel model)
        {
            ResponseBase result   = null;
            HR_Employee  employee = null;
            bool         flag     = false;

            try
            {
                using (db = new IEDEntities())
                {
                    result = new ResponseBase();
                    if (!string.IsNullOrEmpty(model.Code))  // kiem tra ma nhan vien neu có
                    {
                        if (CheckExists(model.Code, model.CompanyId, model.Id, 1, db))
                        {
                            result.IsSuccess = false;
                            result.Errors.Add(new Error()
                            {
                                MemberName = "add new", Message = "Mã nhân viên này đã tồn tại. Vui lòng chọn lại Mã Khác"
                            });
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        if (model.Id == 0)
                        {
                            employee = new HR_Employee();
                            Parse.CopyObject(model, ref employee);
                            employee.Image       = employee.Image == "0" ? "" : employee.Image;
                            employee.CreatedUser = model.ActionUser;
                            employee.CreatedDate = DateTime.Now;
                            db.HR_Employee.Add(employee);
                        }
                        else
                        {
                            employee = db.HR_Employee.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id && x.CompanyId == model.CompanyId);
                            if (employee != null)
                            {
                                employee.FirstName = model.FirstName;
                                employee.LastName  = model.LastName;
                                employee.Gender    = model.Gender;
                                employee.Birthday  = model.Birthday;
                                employee.Code      = model.Code;
                                employee.CompanyId = model.CompanyId;
                                if (model.Image != null)
                                {
                                    employee.Image = model.Image; // hinh
                                }
                                employee.UpdatedUser = model.ActionUser;
                                employee.UpdatedDate = DateTime.Now;
                            }
                            else
                            {
                                result.IsSuccess = false;
                                result.Errors.Add(new Error()
                                {
                                    MemberName = "update employee", Message = "Không tìm thấy Nhân Viên này. \nCó thể nhân viên đã bị xóa hoặc không tồn tại. \nVui lòng kiểm tra lại dữ liệu."
                                });
                            }
                        }
                        db.SaveChanges();
                        result.IsSuccess = true;
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #25
0
ファイル: myCommon.cs プロジェクト: eric33230/wrjitnew
            private HR_Employee EmpToModel(DataRow row)//建立要导入的文件的model
            {
                HR_Employee emps = new HR_Employee();

                for (int i = 0; i < row.ItemArray.Length; i++)
                {
                    if (row.ItemArray.Length > 0)
                    {
                        emps.AID = Convert.ToDecimal(row.ItemArray[0].ToString());
                    }
                    if (row.ItemArray.Length > 1)
                    {
                        emps.DeptID = Convert.ToInt16(row.ItemArray[1].ToString());
                    }
                    if (row.ItemArray.Length > 2)
                    {
                        emps.EnrollNo = Convert.ToSingle(row.ItemArray[2].ToString());
                    }
                    if (row.ItemArray.Length > 3)
                    {
                        emps.EmpID = row.ItemArray[3].ToString();
                    }
                    if (row.ItemArray.Length > 4)
                    {
                        emps.KhName = row.ItemArray[4].ToString();
                    }
                    if (row.ItemArray.Length > 5)
                    {
                        emps.Accountno = Convert.ToInt16(row.ItemArray[5].ToString());
                    }
                    if (row.ItemArray.Length > 6)
                    {
                        emps.NationalID = Convert.ToInt16(row.ItemArray[6].ToString());
                    }
                    if (row.ItemArray.Length > 7)
                    {
                        emps.JobID = Convert.ToInt16(row.ItemArray[7].ToString());
                    }
                    if (row.ItemArray.Length > 8)
                    {
                        emps.ProvinceID = Convert.ToInt16(row.ItemArray[8].ToString());
                    }
                    if (row.ItemArray.Length > 9)
                    {
                        emps.ShiftID = Convert.ToInt16(row.ItemArray[9].ToString());
                    }
                    if (row.ItemArray.Length > 10)
                    {
                        emps.CallName = row.ItemArray[10].ToString();
                    }
                    if (row.ItemArray.Length > 11)
                    {
                        emps.Gender = row.ItemArray[11].ToString();
                    }
                    if (row.ItemArray.Length > 12)
                    {
                        emps.Status = row.ItemArray[12].ToString();
                    }
                    if (row.ItemArray.Length > 13)
                    {
                        emps.PersonalID = row.ItemArray[13].ToString();
                    }
                    if (row.ItemArray.Length > 14)
                    {
                        emps.NSSF = row.ItemArray[14].ToString();
                    }
                    if (row.ItemArray.Length > 15)
                    {
                        emps.Education = row.ItemArray[15].ToString();
                    }
                    if (row.ItemArray.Length > 16)
                    {
                        emps.WorkBook = row.ItemArray[16].ToString();
                    }
                    if (row.ItemArray.Length > 17)
                    {
                        emps.CardNo = row.ItemArray[17].ToString();
                    }
                    if (row.ItemArray.Length > 18)
                    {
                        emps.Address = row.ItemArray[18].ToString();
                    }
                    if (row.ItemArray.Length > 19)
                    {
                        emps.IsPermanent = Convert.ToBoolean(row.ItemArray[19].ToString());
                    }
                    if (row.ItemArray.Length > 20)
                    {
                        emps.IsContract = Convert.ToBoolean(row.ItemArray[20].ToString());
                    }
                    if (row.ItemArray.Length > 21)
                    {
                        emps.IsResign = Convert.ToBoolean(row.ItemArray[21].ToString());
                    }
                    if (row.ItemArray.Length > 22)
                    {
                        emps.ResignType = row.ItemArray[22].ToString();
                    }
                    if (row.ItemArray.Length > 23)
                    {
                        emps.ResignReason = row.ItemArray[23].ToString();
                    }
                    if (row.ItemArray.Length > 24)
                    {
                        if (row.ItemArray[24].ToString().Trim() == "")
                        {
                            emps.ResignDate = null;
                        }
                        else
                        {
                            emps.ResignDate = Convert.ToDateTime(row.ItemArray[24].ToString());
                        }
                    }
                    if (row.ItemArray.Length > 25)
                    {
                        if (row.ItemArray[25].ToString().Trim() == "")
                        {
                            emps.BirthDate = null;
                        }
                        else
                        {
                            emps.BirthDate = Convert.ToDateTime(row.ItemArray[25].ToString().Trim());
                        }
                    }
                    if (row.ItemArray.Length > 26)
                    {
                        if (row.ItemArray[26].ToString().Trim() == "")
                        {
                            emps.CreateDate = null;//
                        }
                        else
                        {
                            emps.CreateDate = Convert.ToDateTime(row.ItemArray[26].ToString());
                        }
                    }
                    if (row.ItemArray.Length > 27)
                    {
                        emps.Union1 = Convert.ToInt16(row.ItemArray[27].ToString());
                    }
                    if (row.ItemArray.Length > 28)
                    {
                        emps.Union2 = Convert.ToInt16(row.ItemArray[28].ToString());
                    }
                    if (row.ItemArray.Length > 29)
                    {
                        emps.Union3 = Convert.ToInt16(row.ItemArray[29].ToString());
                    }
                    if (row.ItemArray.Length > 30)
                    {
                        emps.Union4 = Convert.ToInt16(row.ItemArray[30].ToString());
                    }
                    if (row.ItemArray.Length > 31)
                    {
                        emps.Union5 = Convert.ToInt16(row.ItemArray[31].ToString());
                    }
                    if (row.ItemArray.Length > 32)
                    {
                        emps.Union6 = Convert.ToInt16(row.ItemArray[32].ToString());
                    }
                    if (row.ItemArray.Length > 33)
                    {
                        emps.Union7 = Convert.ToInt16(row.ItemArray[33].ToString());
                    }
                    if (row.ItemArray.Length > 34)
                    {
                        emps.Union8 = Convert.ToInt16(row.ItemArray[34].ToString());
                    }
                    if (row.ItemArray.Length > 35)
                    {
                        emps.Union9 = Convert.ToInt16(row.ItemArray[35].ToString());
                    }
                    if (row.ItemArray.Length > 36)
                    {
                        emps.Union10 = Convert.ToInt16(row.ItemArray[36].ToString());
                    }
                    if (row.ItemArray.Length > 37)
                    {
                        emps.Union11 = Convert.ToInt16(row.ItemArray[37].ToString());
                    }
                    if (row.ItemArray.Length > 38)
                    {
                        emps.Union12 = Convert.ToInt16(row.ItemArray[38].ToString());
                    }
                }
                return(emps);
            }
コード例 #26
0
ファイル: AdminHR_Employee.aspx.cs プロジェクト: anam/mal
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        var employeerPhoto = string.Empty;
        var employeerID = hfEmployeeID.Value.ToString();

        //Membership membership = membership. //.GetUser(txtUserID.Text.Trim());
        //Membership.UpdateUser() //.CreateUser(txtUserID.Text.ToString(), "123456", txtEmailAddress.Text, "a", "a", true, out result);

        if (Session["imagePath"] != null)
        {
            try
            {
                string dirUrl = "upload/employeer/";
                string dirPath = Server.MapPath(dirUrl);

                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                string picPath = Session["imagePath"].ToString();

                string[] st = picPath.ToString().Split('.');
                string st_pic = st[1];
                string fileName = employeerID + "." + st_pic;
                string fileUrl = dirUrl + "/" + fileName;

                System.Drawing.Image stImage = System.Drawing.Image.FromFile(picPath);
                stImage.Save(Server.MapPath(fileUrl));

                employeerPhoto = fileName;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
        else
        {
            if (fileEmployerPhoto.HasFile)
            {
                employeerPhoto = UpLoadCompanyEmployeerPicture(fileEmployerPhoto, employeerID);
            }
        }
        //else
        //{
        //    string dirPathOnly = String.Format("~/HR/upload/employeer/");
        //    dirPathOnly = Server.MapPath(dirPathOnly);
        //    string dirPathWithName = String.Format("~/HR/upload/employeer/showPicture.Jpeg");
        //    dirPathWithName = Server.MapPath(dirPathWithName);
        //    System.IO.FileInfo file;
        //    file = new System.IO.FileInfo(dirPathWithName);
        //    if (file.Exists)
        //    {
        //        System.Drawing.Image originalImage = System.Drawing.Image.FromFile(dirPathOnly + hdnEmployeerImage.Value);

        //        originalImage.Save(dirPathOnly + employeerID, System.Drawing.Imaging.ImageFormat.Jpeg);
        //        employeerPhoto = employeerID + ".Jpeg";
        //    }
        //}
        HR_Employee hR_Employee = new HR_Employee();
        hR_Employee.EmployeeID = Request.QueryString["ID"].ToString();
        hR_Employee.EmployeeName = txtEmployeeName.Text;
        hR_Employee.EmployeeNo = txtUserID.Text.Trim();
        hR_Employee.EmailAddress = txtEmailAddress.Text.Trim();
        hR_Employee.EmployeeType = ddlEmployeerType.SelectedValue;
        hR_Employee.DesignationID = int.Parse(ddlDesignationID.SelectedValue);
        hR_Employee.EmployeeRank = ddlRank.SelectedValue.ToString();
        hR_Employee.FathersName = txtFathersName.Text;
        hR_Employee.MothersName = txtMothersName.Text;
        hR_Employee.SpouseName = txtSpouseName.Text;
        hR_Employee.DateOfBirth = DateTime.Parse(txtDateOfBirth.Text);
        hR_Employee.PlaceOfBirth = txtPlaceOfBirth.Text;
        hR_Employee.BloodGroupID = Int16.Parse(ddlBloodGroupID.SelectedValue);
        hR_Employee.GenderID = ddlGenderID.SelectedValue;
        hR_Employee.ReligionID = int.Parse(ddlReligionID.SelectedValue);
        hR_Employee.MaritualStatusID = Int16.Parse(ddlMaritualStatusID.SelectedValue);
        hR_Employee.NationalityID = int.Parse(ddlNationalityID.SelectedValue);
        if (employeerPhoto != string.Empty)
        {
            hR_Employee.Photo = employeerPhoto;
        }
        else
        {
            hR_Employee.Photo = hdnEmployeerImage.Value;
        }
        hR_Employee.Address = txtAddress.Text;
        hR_Employee.JoiningDate = txtJoiningDate.Text == null ? DateTime.MinValue : Convert.ToDateTime(txtJoiningDate.Text.Trim());
        hR_Employee.ExtraField1 = txtNickName.Text.Trim();
        hR_Employee.ExtraField2 = txtNickNameDetail.Text.Trim();
        hR_Employee.Flag = radFlag.SelectedValue == "Active" ? true : false;//

        string userID = Profile.card_id;

        hR_Employee.AddedBy = userID;
        hR_Employee.AddedDate = DateTime.Now;
        hR_Employee.ModifiedBy = userID;
        hR_Employee.ModifiedDate = DateTime.Now;
        bool resutl = HR_EmployeeManager.UpdateHR_Employee(hR_Employee);
        lblError.Text = "Employee information is updated successfully.";
        lblError.ForeColor = System.Drawing.Color.Green;

        if (hR_Employee.Photo.ToString() == "")
        {
            imgEmployeerImage.ImageUrl = String.Format("~/App_Themes/CoffeyGreen/images/NoImage.jpg");
        }
        else
        {
            hdnEmployeerImage.Value = hR_Employee.Photo.ToString();
            imgEmployeerImage.ImageUrl = String.Format("~/HR/upload/employeer/{0}", hR_Employee.Photo.ToString());
        }
    }
コード例 #27
0
ファイル: HR_EmployeeProvider.cs プロジェクト: anam/mal
    public HR_Employee GetHR_EmployeeFromReader(IDataReader reader)
    {
        try
        {
            HR_Employee hR_Employee = new HR_Employee
                (
                     DataAccessObject.IsNULL<string>(reader["EmployeeID"].ToString()),
                     DataAccessObject.IsNULL<string>(reader["EmployeeName"]),

                     DataAccessObject.IsNULL<string>(reader["EmployeeNo"]),
                     DataAccessObject.IsNULL<string>(reader["EmailAddress"]),

                     DataAccessObject.IsNULL<string>(reader["EmployeeType"]),
                     DataAccessObject.IsNULL<int>(reader["DesignationID"]),
                     DataAccessObject.IsNULL<string>(reader["EmployeeRank"]),
                     DataAccessObject.IsNULL<string>(reader["FathersName"]),
                     DataAccessObject.IsNULL<string>(reader["MothersName"]),
                     DataAccessObject.IsNULL<string>(reader["SpouseName"]),
                     DataAccessObject.IsNULL<DateTime>(reader["DateOfBirth"]),
                     DataAccessObject.IsNULL<string>(reader["PlaceOfBirth"]),
                     DataAccessObject.IsNULL<int>(reader["BloodGroupID"]),
                     DataAccessObject.IsNULL<string>(reader["GenderID"]),
                     DataAccessObject.IsNULL<int>(reader["ReligionID"]),
                     DataAccessObject.IsNULL<int>(reader["MaritualStatusID"]),
                     DataAccessObject.IsNULL<int>(reader["NationalityID"]),
                     DataAccessObject.IsNULL<string>(reader["Photo"]),
                     DataAccessObject.IsNULL<string>(reader["Address"]),

                     DataAccessObject.IsNULL<DateTime>(reader["JoiningDate"]),
                     DataAccessObject.IsNULL<DateTime>(reader["ResignDate"]),
                     DataAccessObject.IsNULL<string>(reader["ResignDescription"]),

                     DataAccessObject.IsNULL<bool>(reader["Flag"]),

                     DataAccessObject.IsNULL<string>(reader["ExtraField1"]),
                     DataAccessObject.IsNULL<string>(reader["ExtraField2"]),

                     DataAccessObject.IsNULL<string>(reader["AddedBy"].ToString()),
                     DataAccessObject.IsNULL<DateTime>(reader["AddedDate"]),
                     DataAccessObject.IsNULL<string>(reader["ModifiedBy"].ToString()),
                     DataAccessObject.IsNULL<DateTime>(reader["ModifiedDate"])
                );

            try
            {
                hR_Employee.DepartmentID = DataAccessObject.IsNULL<int>(reader["DepartmentID"]);
            }
            catch (Exception ex)
            { }

            //hR_Employee.DepartmentName= DataAccessObject.IsNULL<string>(reader["DepartmentName"].ToString());
            return hR_Employee;
        }
        catch (Exception ex)
        {
            return null;
        }
    }
コード例 #28
0
ファイル: HR_EmployeeProvider.cs プロジェクト: anam/mal
    public bool UpdateHR_Employee(HR_Employee hR_Employee)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateHR_Employee", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = hR_Employee.EmployeeID;
            cmd.Parameters.Add("@EmployeeName", SqlDbType.NVarChar).Value = hR_Employee.EmployeeName;

            cmd.Parameters.Add("@EmployeeNo", SqlDbType.NVarChar).Value = hR_Employee.EmployeeNo;
            cmd.Parameters.Add("@EmailAddress", SqlDbType.NVarChar).Value = hR_Employee.EmailAddress;

            cmd.Parameters.Add("@EmployeeType", SqlDbType.NVarChar).Value = hR_Employee.EmployeeType;
            cmd.Parameters.Add("@DesignationID", SqlDbType.Int).Value = hR_Employee.DesignationID;
            cmd.Parameters.Add("@EmployeeRank", SqlDbType.NVarChar).Value = hR_Employee.EmployeeRank;
            cmd.Parameters.Add("@FathersName", SqlDbType.NVarChar).Value = hR_Employee.FathersName;
            cmd.Parameters.Add("@MothersName", SqlDbType.NVarChar).Value = hR_Employee.MothersName;
            cmd.Parameters.Add("@SpouseName", SqlDbType.NVarChar).Value = hR_Employee.SpouseName;
            cmd.Parameters.Add("@DateOfBirth", SqlDbType.DateTime).Value = hR_Employee.DateOfBirth;
            cmd.Parameters.Add("@PlaceOfBirth", SqlDbType.NVarChar).Value = hR_Employee.PlaceOfBirth;
            cmd.Parameters.Add("@BloodGroupID", SqlDbType.NVarChar).Value = hR_Employee.BloodGroupID;
            cmd.Parameters.Add("@GenderID", SqlDbType.NVarChar).Value = hR_Employee.GenderID;
            cmd.Parameters.Add("@ReligionID", SqlDbType.Int).Value = hR_Employee.ReligionID;
            cmd.Parameters.Add("@MaritualStatusID", SqlDbType.NVarChar).Value = hR_Employee.MaritualStatusID;
            cmd.Parameters.Add("@NationalityID", SqlDbType.Int).Value = hR_Employee.NationalityID;
            cmd.Parameters.Add("@Photo", SqlDbType.NVarChar).Value = hR_Employee.Photo;
            cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = hR_Employee.Address;
            cmd.Parameters.Add("@JoiningDate", SqlDbType.DateTime).Value = hR_Employee.JoiningDate; // == DateTime.MinValue ? DBNull : hR_Employee.JoiningDate;
            cmd.Parameters.Add("@Flag", SqlDbType.Bit).Value = hR_Employee.Flag;
            cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value = hR_Employee.ExtraField1;
            cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value = hR_Employee.ExtraField2;

            cmd.Parameters.Add("@ModifiedBy", SqlDbType.NVarChar).Value = hR_Employee.ModifiedBy;
            cmd.Parameters.Add("@ModifiedDate", SqlDbType.DateTime).Value = hR_Employee.ModifiedDate;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
コード例 #29
0
        public ActionResult List(RecruitQueryParam queryParam)
        {
            Expression <Func <THR_Recruit, bool> > predicate = c => c.IsDelete == 0;

            if (!string.IsNullOrEmpty(queryParam.Name))
            {
                predicate = predicate.And(c => c.Name.StartsWith(queryParam.Name));
            }
            if (!string.IsNullOrEmpty(queryParam.Tel))
            {
                predicate = predicate.And(c => c.Tel.StartsWith(queryParam.Tel));
            }
            if (queryParam.Status > 0)
            {
                predicate = predicate.And(c => c.Status == queryParam.Status);
            }
            if (queryParam.DptId > 0)
            {
                predicate = predicate.And(c => c.DptId == queryParam.DptId);
            }
            if (queryParam.PostId > 0)
            {
                predicate = predicate.And(c => c.PostId == queryParam.PostId);
            }
            if (!string.IsNullOrEmpty(queryParam.CreateBy))
            {
                predicate = predicate.And(c => c.CreateBy == queryParam.CreateBy);
            }
            if (queryParam.IntervieweStart.HasValue && queryParam.IntervieweEnd.HasValue && queryParam.IntervieweStart.Value < queryParam.IntervieweEnd.Value)
            {
                predicate = predicate.And(c => c.Interview >= queryParam.IntervieweStart.Value && c.Interview <= queryParam.IntervieweEnd.Value);
            }
            if (queryParam.CreateTimeStart.HasValue && queryParam.CreateTimeEnd.HasValue && queryParam.CreateTimeStart.Value < queryParam.CreateTimeEnd.Value)
            {
                predicate = predicate.And(c => c.CreateTime >= queryParam.CreateTimeStart.Value && c.CreateTime <= queryParam.CreateTimeEnd.Value);
            }
            HKSJRecruitmentContext   ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <RecruitModel> models = ctx.THR_Recruit
                                              .Where(predicate)
                                              .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                              .Select(c => new RecruitModel
            {
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                Id          = c.Id,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                Status      = c.Status.Value,
                StatusName  = c.Tapp_Param.ParamsName,
                Interview   = c.Interview,
                Email       = c.Email,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                NeedsId     = c.NeedsId,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                Interviewer = c.Interviewer
            })
                                              .ToPagedList(queryParam.PageIndex, queryParam.PageSize);
            List <RecruitModel> dtos = models.ToList();

            foreach (var item in dtos)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == item.CreateBy);
                if (emp != null)
                {
                    item.CreateBy = emp.name;
                }
            }
            return(Content(this.GetJSON(new { total = models.PageInfo.TotalCount, rows = dtos }), this.JsonContentType()));
        }
コード例 #30
0
 public ActionResult Edit(HR_Employee dto)
 {
     if (dto.ID > 0)
     {
         HKSJRecruitmentContext ctx = HttpContext.GetDbContext <HKSJRecruitmentContext>();
         int         id             = dto.ID;
         HR_Employee model          = ctx.HR_Employee.FirstOrDefault(c => c.ID == id);
         if (model == null)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "找不到要修改的员工信息" }), this.JsonContentType()));
         }
         if (!dto.dptid.HasValue)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "部门不能为空" }), this.JsonContentType()));
         }
         if (!dto.postid.HasValue)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "职位不能为空" }), this.JsonContentType()));
         }
         int deptId = dto.dptid.Value;
         int postId = dto.postid.Value;
         if (ctx.TErp_Department.Count(c => c.Id == deptId && c.IsDelete == 0) == 0)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "部门不存在" }), this.JsonContentType()));
         }
         if (ctx.TErp_Position.Count(c => c.Id == postId && c.IsDelete == 0) == 0)
         {
             return(Content(this.GetJSON(new { Result = false, Msg = "职位不存在" }), this.JsonContentType()));
         }
         model.sex       = dto.sex;
         model.idcard    = dto.idcard;
         model.tel       = dto.tel;
         model.EntryDate = dto.EntryDate;
         model.birthday  = dto.birthday;
         model.dptid     = dto.dptid.Value;
         model.dptname   = dto.dptname;
         model.postid    = dto.postid.Value;
         model.post      = dto.post;
         model.schools   = dto.schools;
         model.education = dto.education;
         model.status    = dto.status;
         model.address   = dto.address;
         if (dto.status == "离职")
         {
             string    uid = model.uid;
             Tapp_User use = ctx.Tapp_User.FirstOrDefault(c => c.UserName == uid);
             if (use != null)
             {
                 use.State = 0;
             }
         }
         if (ctx.SaveChanges() >= 0)
         {
             return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = model }), this.JsonContentType()));
         }
         return(Content(this.GetJSON(new { Result = false, Msg = "失败" }), this.JsonContentType()));
     }
     else
     {
         return(Content(this.GetJSON(new { Result = false, Msg = "失败,未找到要修改的数据" }), this.JsonContentType()));
     }
 }
コード例 #31
0
ファイル: AdminHR_Employee.aspx.cs プロジェクト: anam/mal
    private void ShowHREmployeeData()
    {
        try
        {
            lblTmpMobile.Visible = false;
            lblTmpSalary.Visible = false;
            txtTmpMobile.Visible = false;
            txtTmpSalary.Visible = false;
            HR_Employee hR_Employee = new HR_Employee();
            hR_Employee = HR_EmployeeManager.GetHR_EmployeeByEmployeeID(Request.QueryString["ID"]);
            txtEmployeeName.Text = hR_Employee.EmployeeName.ToString();
            txtEmailAddress.Text = hR_Employee.EmailAddress;
            txtUserID.Text = hR_Employee.EmployeeNo;
            ddlEmployeerType.SelectedValue = hR_Employee.EmployeeType.ToString();
            ddlDesignationID.SelectedValue = hR_Employee.DesignationID.ToString();
            ddlDepartment.SelectedValue = hR_Employee.DepartmentID.ToString();
            ddlRank.SelectedValue = hR_Employee.EmployeeRank; //HR_RankManager.GetHR_RankByRankID(Convert.ToInt32(hR_Employee.EmployeeRank)).RankID.ToString();
            txtFathersName.Text = hR_Employee.FathersName.ToString();
            txtMothersName.Text = hR_Employee.MothersName.ToString();
            txtSpouseName.Text = hR_Employee.SpouseName.ToString();
            txtDateOfBirth.Text = hR_Employee.DateOfBirth.ToString("dd MMM yyyy");
            txtPlaceOfBirth.Text = hR_Employee.PlaceOfBirth.ToString();
            ddlBloodGroupID.SelectedValue = hR_Employee.BloodGroupID.ToString();
            ddlGenderID.SelectedValue = hR_Employee.GenderID.ToString();
            ddlReligionID.SelectedValue = hR_Employee.ReligionID.ToString();
            ddlMaritualStatusID.SelectedValue = hR_Employee.MaritualStatusID.ToString();
            ddlNationalityID.SelectedValue = hR_Employee.NationalityID.ToString();
            if (hR_Employee.Photo.ToString() == "")
            {
               // imgEmployeerImage.ImageUrl = "~/App_Themes/CoffeyGreen/images/NoImage.jpg";
                imgEmployeerImage.ImageUrl = String.Format("~/App_Themes/CoffeyGreen/images/NoImage.jpg");

            }
            else
            {
                //imgEmployeerImage.ImageUrl = hR_Employee.Photo.ToString();
                hdnEmployeerImage.Value = hR_Employee.Photo.ToString();

                imgEmployeerImage.ImageUrl = String.Format("~/HR/upload/employeer/{0}", hR_Employee.Photo.ToString());
            }
            txtAddress.Text = hR_Employee.Address.ToString();
            txtJoiningDate.Text = hR_Employee.JoiningDate == DateTime.MinValue ? "" : hR_Employee.JoiningDate.ToString("dd MMM yyyy");
            txtNickName.Text = hR_Employee.ExtraField1;
            txtNickNameDetail.Text = hR_Employee.ExtraField2;
            radFlag.SelectedValue = hR_Employee.Flag == true ? "Active" : "Inactive";

            _jobExperienceColl = COMN_JobExperienceManager.GetCOMN_JobExperiencesByEmpUserID(hfEmployeeID.Value.ToString());
            gvHR_JobExperience.DataSource = _jobExperienceColl;
            gvHR_JobExperience.DataBind();

            _childrenInfoColl = HR_ChildrenInfoManager.GetHR_ChildrenInfosByEmployeeID(hfEmployeeID.Value.ToString());
            gvHR_ChildrenInfo.DataSource = _childrenInfoColl;
            gvHR_ChildrenInfo.DataBind();

            Session["_educationalBackgroundColl"] = COMN_EducatinalBackgroundManager.GetCOMN_EducatinalBackgroundsByEmpUserID(hfEmployeeID.Value.ToString());
            gv_educationalBackground.DataSource = (List<COMN_EducatinalBackground>)Session["_educationalBackgroundColl"];
            gv_educationalBackground.DataBind();

            RefreshContact();
            btnAddContact.Visible = false;
            btnUpdateContacts.Visible = true;

            RefreshBankAccount();
            btnAddBank.Visible = false;
            btnUpdateBank.Visible = true;

            RefreshAttendenceRules();
            btnAddAttendenceRules.Visible = false;
            btnUpdateAttendenceRules.Visible = true;

            RefreshWorkingDaysShifting();
            btnAddWorkingDaysShifting.Visible = false;
            btnUpdateWorkingDaysShifting.Visible = true;

            RefreshEmployeeSalary();
            btnSaveEmployeeSalary.Visible = false;
            btnUpdateEmployeeSalary.Visible = true;

            RefreshProvidentFundddl();
            btnAddProvidenedFund.Visible = false;
            btnUpdateProvidenedFund.Visible = true;

            RefreshBenefitPackageRules();

            RefreshLunchRuleControl();

            RefreshSalaryTaxPackage();

            RefreshSalaryAdjustmentListRules();

        }
        catch (Exception ex)
        {

        }
    }
コード例 #32
0
        public ActionResult Edit(THR_Recruit dto)
        {
            if (dto.Id > 0)
            {
                HKSJRecruitmentContext ctx   = HttpContext.GetDbContext <HKSJRecruitmentContext>();
                THR_Recruit            model = ctx.THR_Recruit.FirstOrDefault(c => c.Id == dto.Id);
                //状态为已入职,不能修改
                if (model.EntryType == 3)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "状态为【已入职】,不能修改!" }), this.JsonContentType()));
                }
                if (dto.EntryType == 3 && dto.HireTime == null)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "已入职时,报到时间不能为空!" }), this.JsonContentType()));
                }
                if (dto.HireTime != null && DateTime.Compare(dto.HireTime.Value, DateTime.Now) > 0 && dto.EntryType == 3)
                {
                    return(Content(this.GetJSON(new { Result = false, Msg = "报到时间不能超过今天!" }), this.JsonContentType()));

                    //this.CopyObject<THR_Recruit>(model, dto);
                }
                model.HireTime  = dto.HireTime;
                model.EntryType = dto.EntryType.Value;
                model.Remark    = dto.Remark;
                model.EditTime  = DateTime.Now;
                model.EditBy    = this.AppUser().UserName;

                if (ctx.SaveChanges() >= 0)
                {
                    var m = ctx.THR_Recruit.Where(c => c.Id == dto.Id).Select(c => new RecruitModel
                    {
                        DptId       = c.DptId.Value,
                        DptName     = c.TErp_Department.DeptName,
                        Id          = c.Id,
                        PostId      = c.PostId.Value,
                        PostName    = c.TErp_Position.PositionName,
                        Userurl     = c.Userurl,
                        Remark      = c.Remark,
                        Name        = c.Name,
                        Tel         = c.Tel,
                        Status      = c.Status.Value,
                        Interview   = c.Interview,
                        Email       = c.Email,
                        EntryType   = c.EntryType.Value,
                        NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                        CreateBy    = c.CreateBy,
                        CreateTime  = c.CreateTime,
                        HireTime    = c.HireTime,
                        Interviewer = c.Interviewer
                    }).FirstOrDefault();
                    HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == model.CreateBy);
                    if (emp != null)
                    {
                        m.CreateBy = emp.name;
                    }
                    if (model.EntryType == 3)//已入职
                    {
                        WcfRestClient       client     = new HKSJRecruitment.Web.WcfRestClientAppBase("Employee");
                        EditRecord <string> resultname = client.Get <EditRecord <string> >("Uid/" + m.Name);
                        string uid = resultname.Dto;
                        HKSJRecruitment.Models.proModels.EmployeeDto empdto = new HKSJRecruitment.Models.proModels.EmployeeDto
                        {
                            FullName   = model.Name,
                            CreateBy   = 0,
                            Uid        = uid,
                            CreateTime = DateTime.Now,
                            Sex        = "男",
                            Mobile     = model.Tel,
                            EntryDate  = model.HireTime.Value,
                            Status     = 2,
                            IsDelete   = 0,
                            Education  = "大专",
                            DeptId     = 0,
                            PostId     = 0,
                            EditBy     = 0,
                            DeleteBy   = 0,
                            Email      = model.Email
                        };
                        EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> result = client.Post <HKSJRecruitment.Models.proModels.EmployeeDto, EditRecord <HKSJRecruitment.Models.proModels.EmployeeDto> >(empdto);
                    }

                    return(Content(this.GetJSON(new { Result = true, Msg = "成功", Dto = m }), this.JsonContentType()));
                }
                return(Content(this.GetJSON(new { Result = false, Msg = "失败", Dto = dto }), this.JsonContentType()));
            }
            else
            {
                return(Content(this.GetJSON(new { Result = false, Msg = "失败,报到时间不能超过今天!", Dto = dto }), this.JsonContentType()));
            }
        }
コード例 #33
0
ファイル: AdminHR_Employee.aspx.cs プロジェクト: anam/mal
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        divPersonalDoucument.Visible = true;
        contenttab.Visible = true;
        btnUpdate.Visible = true;
        btnAdd.Visible = false;

        lblError.ForeColor = System.Drawing.Color.Red;
        var employeerPhoto = string.Empty;
        var employeerID = "";
        MembershipCreateStatus result;
        try
        {
            txtUserID.Text = HR_EmployeeManager.GetEmployeeNo();
            if (txtEmailAddress.Text.Trim() == string.Empty)
            {
                txtEmailAddress.Text = txtUserID.Text + "@cucedu.com";
                txtEmail.Text = txtUserID.Text + "@cucedu.com";
            }
            Membership.DeleteUser(txtUserID.Text.Trim().ToString());
            Membership.CreateUser(txtUserID.Text.ToString(), "123456", txtEmailAddress.Text, "a", "a", true, out result);

            switch (result)
            {
                case MembershipCreateStatus.Success:

                    FormsAuthentication.SetAuthCookie(txtUserID.Text.ToString(), true);

                    var role = "hr";
                    //if (rbUserType.SelectedItem.Value.ToString() == "1")
                    //{

                    MembershipUser myObject = Membership.GetUser(txtUserID.Text.Trim());
                    employeerID = myObject.ProviderUserKey.ToString();
                    hfEmployeeID.Value = employeerID;
                    //Roles.AddUserToRole(txtUserID.Text.ToString(), "hr");
                    txtUserID.Enabled = false;
                    txtEmailAddress.Enabled = false;
                    ////Roles.AddUserToRole(UserName.Text, "Student");
                    //Response.Redirect("StudentsProfilePage.aspx?&usertype=" + rbUserType.SelectedItem.Value.ToString());
                    //}

                    //if (rbUserType.SelectedItem.Value.ToString() == "2")
                    //{
                    //Roles.AddUserToRole(UserName.Text, "Teacher");
                    //Response.Redirect("TeachersProfilePage.aspx?&usertype=" + rbUserType.SelectedItem.Value.ToString());
                    //}

                    lblError.Text = "User successfully created!";
                    lblError.ForeColor = System.Drawing.Color.Green;
                    break;
                case MembershipCreateStatus.InvalidUserName:
                    lblError.Text = "The username format was invalid. Please enter a different username.";
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    lblError.Text = "The password was invalid: A password cannot be an empty string and must also meet the pasword strength requirements of the configured provider. Please enter a new password.";
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    lblError.Text = "The email format was invalid. Please enter a different username.";
                    break;
                case MembershipCreateStatus.InvalidQuestion:
                    lblError.Text = "The password question format was invalid. Please enter a different question.";
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    lblError.Text = "The password answer format was invalid. Please enter a different answer.";
                    break;
                case MembershipCreateStatus.DuplicateUserName:
                    lblError.Text = "The username is already in use. Please enter a new username.";
                    break;
                case MembershipCreateStatus.DuplicateEmail:
                    lblError.Text = "The email address is already in use. Please enter a different email address.";
                    break;
                default:
                    lblError.Text = "An error occurred while creating the user.";
                    break;
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;

            return;
            //lblError.Text = ex.Message.ToString();
        }

        if (result != MembershipCreateStatus.Success)
        {
            return;
        }

        if (Session["imagePath"] != null)
        {
            try
            {
                string dirUrl = "upload/employeer/";
                string dirPath = Server.MapPath(dirUrl);

                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }

                string picPath = Session["imagePath"].ToString();
                Session.Remove("imagePath");
                string[] st = picPath.ToString().Split('.');
                string st_pic = st[1];
                string fileName = employeerID + "." + st_pic;
                string fileUrl = dirUrl + "/" + fileName;

                System.Drawing.Image stImage = System.Drawing.Image.FromFile(picPath);
                stImage.Save(Server.MapPath(fileUrl));

                employeerPhoto = fileName;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }
        else
        {
            if (fileEmployerPhoto.HasFile)
            {
                employeerPhoto = UpLoadCompanyEmployeerPicture(fileEmployerPhoto, employeerID);
                string locationOfImage = Server.MapPath(fileEmployerPhoto.FileName);
                imgEmployeerImage.ImageUrl = String.Format(locationOfImage);
            }
            else
            {
                employeerPhoto = "upload/employeer/NoImage.jpg";
            }
        }

        //else
        //{
        //    string dirPathOnly= String.Format("~/HR/upload/employeer/");
        //    string dirPathWithName = String.Format("~/HR/upload/employeer/showPicture.Jpeg");
        //    System.IO.FileInfo file;
        //    file = new System.IO.FileInfo(dirPathWithName);
        //    if (file.Exists)
        //    {
        //        System.Drawing.Image originalImage = System.Drawing.Image.FromFile(dirPathOnly + hdnEmployeerImage.Value);

        //        originalImage.Save(dirPathOnly + employeerID, System.Drawing.Imaging.ImageFormat.Jpeg);
        //        employeerPhoto = employeerID + ".Jpeg";
        //        file.Delete();
        //    }
        //}

        //load The loggedin user
        FormsAuthentication.SetAuthCookie(hfLoggedInUserID.Value, true);
        MembershipUser myObjectLoggedInUser = Membership.GetUser(hfLoggedInUserID.Value);

        HR_Employee hR_Employee = new HR_Employee();
        hR_Employee.EmployeeID = employeerID;
        hR_Employee.EmployeeName = txtEmployeeName.Text;
        hR_Employee.EmployeeNo = txtUserID.Text.Trim();
        hR_Employee.EmailAddress = txtEmailAddress.Text.Trim();
        hR_Employee.EmployeeType = ddlEmployeerType.SelectedValue;
        hR_Employee.DesignationID = int.Parse(ddlDesignationID.SelectedValue);
        hR_Employee.EmployeeRank = ddlRank.SelectedValue.ToString();
        hR_Employee.FathersName = txtFathersName.Text;
        hR_Employee.MothersName = txtMothersName.Text;
        hR_Employee.SpouseName = txtSpouseName.Text;
        hR_Employee.DateOfBirth = (txtDateOfBirth.Text =="" ?DateTime.Today.AddYears(-20):DateTime.Parse(txtDateOfBirth.Text));
        hR_Employee.PlaceOfBirth = txtPlaceOfBirth.Text;
        hR_Employee.BloodGroupID = Int16.Parse(ddlBloodGroupID.SelectedValue);
        hR_Employee.GenderID = ddlGenderID.SelectedValue;
        hR_Employee.ReligionID = int.Parse(ddlReligionID.SelectedValue);
        hR_Employee.MaritualStatusID = Int16.Parse(ddlMaritualStatusID.SelectedValue);
        hR_Employee.NationalityID = int.Parse(ddlNationalityID.SelectedValue);
        hR_Employee.Photo = employeerPhoto;
        hR_Employee.Address = txtAddress.Text;
        hR_Employee.JoiningDate = txtJoiningDate.Text == null ? DateTime.MinValue : Convert.ToDateTime(txtJoiningDate.Text.Trim());
        hR_Employee.ExtraField1 = txtNickName.Text.Trim();
        hR_Employee.ExtraField2 = txtNickNameDetail.Text.Trim();
        hR_Employee.Flag = radFlag.SelectedValue == "Active" ? true : false;

        //if (Session["userID"] ==null)
        //{
        //    FormsAuthentication.SignOut();
        //}
        string userID = Profile.card_id;
           // if(userID!= string.Empty)
        hR_Employee.AddedBy = userID;
        hR_Employee.AddedDate = DateTime.Now;
        hR_Employee.ModifiedBy = userID;
        hR_Employee.ModifiedDate = DateTime.Now;
        int resutl = HR_EmployeeManager.InsertHR_Employee(hR_Employee);
        hfEmployeeID.Value = employeerID;

        autoAddedInfo();

        if (hR_Employee.Photo.ToString() == "")
        {
            imgEmployeerImage.ImageUrl = String.Format("~/App_Themes/CoffeyGreen/images/NoImage.jpg");
        }
        else
        {
            hdnEmployeerImage.Value = hR_Employee.Photo.ToString();
            imgEmployeerImage.ImageUrl = String.Format("~/HR/upload/employeer/{0}", hR_Employee.Photo.ToString());
        }
    }
コード例 #34
0
        private IPageList <RecruitModel> GetRecruitList(RecruitQueryParam queryParam)
        {
            Expression <Func <THR_Recruit, bool> > predicate = c => c.IsDelete == 0 && c.Status == 82;

            if (!string.IsNullOrEmpty(queryParam.Name))
            {
                predicate = predicate.And(c => c.Name.StartsWith(queryParam.Name));
            }
            if (!string.IsNullOrEmpty(queryParam.Tel))
            {
                predicate = predicate.And(c => c.Tel.StartsWith(queryParam.Tel));
            }
            if (!string.IsNullOrEmpty(queryParam.interviewer))
            {
                predicate = predicate.And(c => c.Interviewer.StartsWith(queryParam.interviewer));
            }
            if (queryParam.DptId > 0)
            {
                predicate = predicate.And(c => c.DptId == queryParam.DptId);
            }
            if (queryParam.PostId > 0)
            {
                predicate = predicate.And(c => c.PostId == queryParam.PostId);
            }
            if (queryParam.QueryType > 0)
            {
                predicate = predicate.And(c => c.EntryType == queryParam.QueryType);
            }
            if (queryParam.IntervieweStart.HasValue && queryParam.IntervieweEnd.HasValue && queryParam.IntervieweStart.Value < queryParam.IntervieweEnd.Value)
            {
                predicate = predicate.And(c => c.Interview >= queryParam.IntervieweStart.Value && c.Interview <= queryParam.IntervieweEnd.Value);
            }
            if (!string.IsNullOrEmpty(queryParam.CreateBy))
            {
                predicate = predicate.And(c => c.CreateBy == queryParam.CreateBy);
            }
            if (queryParam.CreateTimeStart.HasValue && queryParam.CreateTimeEnd.HasValue && queryParam.CreateTimeStart.Value < queryParam.CreateTimeEnd.Value)
            {
                predicate = predicate.And(c => c.CreateTime >= queryParam.CreateTimeStart.Value && c.CreateTime <= queryParam.CreateTimeEnd.Value);
            }
            HKSJRecruitmentContext   ctx    = HttpContext.GetDbContext <HKSJRecruitmentContext>();
            IPageList <RecruitModel> models = ctx.THR_Recruit
                                              .Where(predicate)
                                              .OrderUsingSortExpression(queryParam.Sort, queryParam.Order)
                                              .Select(c => new RecruitModel
            {
                DptId       = c.DptId.Value,
                DptName     = c.TErp_Department.DeptName,
                Id          = c.Id,
                PostId      = c.PostId.Value,
                PostName    = c.TErp_Position.PositionName,
                Userurl     = c.Userurl,
                Remark      = c.Remark,
                Name        = c.Name,
                Tel         = c.Tel,
                Status      = c.Status.Value,
                Interview   = c.Interview,
                Email       = c.Email,
                EntryType   = c.EntryType.Value,
                NeedsName   = c.THR_Needs.TErp_Department.DeptName + "  " + c.THR_Needs.TErp_Position.PositionName,
                CreateBy    = c.CreateBy,
                CreateTime  = c.CreateTime,
                HireTime    = c.HireTime,
                Interviewer = c.Interviewer
            })
                                              .ToPagedList(queryParam.PageIndex, queryParam.PageSize);

            foreach (var item in models)
            {
                HR_Employee emp = ctx.HR_Employee.FirstOrDefault(c => c.uid == item.CreateBy);
                if (emp != null)
                {
                    item.CreateBy = emp.name;
                }
            }
            return(models);
        }
コード例 #35
0
        public SYS_UserAccountResult UserLogin(SYS_UserAccountParam param)
        {
            var result = new SYS_UserAccountResult();

            try
            {
                #region 用户帐号判定

                param.Account.ThrowIfNullOfEmpty("请指定用户名!");
                param.CompanyName.ThrowIfNullOfEmpty("请指定公司名称!");
                param.PWD.ThrowIfNullOfEmpty("请指定登录密码!");
                #endregion
                #region 验证公司
                //正式版验证时需要排除平台用户相关的公司
                WhereClip coInfoWhereClip =
                    SYS_CompanyInfo._.CompanyName == param.CompanyName &&
                    SYS_CompanyInfo._.IsActive != (int)ZNLCRM.Utility.CommonEnum.IsActive.Deleted;

                if (!string.IsNullOrEmpty(param.PartnerCode))
                {
                    coInfoWhereClip = coInfoWhereClip && SYS_CompanyInfo._.PartnerCode == param.PartnerCode;
                }
                else
                {
                    coInfoWhereClip = coInfoWhereClip && SYS_CompanyInfo._.PartnerCode.IsNull();
                }
                SYS_CompanyInfo coInfo = Select <SYS_CompanyInfo>(coInfoWhereClip);
                coInfo.ThrowIfNull("未找到公司帐户信息!");
                SYS_UserAccount userAccount = Select <SYS_UserAccount>(
                    SYS_UserAccount._.GCompanyID == coInfo.CompanyID &&
                    SYS_UserAccount._.Account == param.Account &&
                    SYS_UserAccount._.IsActive != (int)ZNLCRM.Utility.CommonEnum.IsActive.Deleted &&
                    SYS_UserAccount._.IsDeleted == false
                    );
                userAccount.ThrowIfNull("未找到公司用户信息!");
                userAccount.IsActive.ThrowIfEqual(
                    (int?)ZNLCRM.Utility.CommonEnum.IsActive.Disabled,
                    "当前用户已被禁用!"
                    );

                HR_Employee userEmpInfo = Select <HR_Employee>(
                    HR_Employee._.GCompanyID == coInfo.CompanyID &&
                    HR_Employee._.EmpCode == param.Account &&
                    HR_Employee._.IsActive != (int)ZNLCRM.Utility.CommonEnum.IsActive.Deleted &&
                    HR_Employee._.IsDeleted == false
                    );
                userEmpInfo.ThrowIfNull("未找到公司用户信息!");
                userEmpInfo.IsActive.ThrowIfEqual(
                    (int?)ZNLCRM.Utility.CommonEnum.IsActive.Disabled,
                    "当前用户已被禁用!"
                    );

                bool isMater = false;
                userEmpInfo.EmpStatus.ThrowIfEqual(3, "当前用户状态已离职!");

                //子帐号需要做验证逻辑判断
                if (!isMater)
                {
                    if (userAccount.NeedValidate.ToBooleanHasNull() &&
                        !string.IsNullOrEmpty(userAccount.MacAddress.ToStringHasNull()) &&
                        !string.IsNullOrEmpty(userAccount.HardDiskSN.ToStringHasNull()))
                    {
                        if (userAccount.MacAddress.ToStringHasNull().Trim().ToLower() != param.MacAddress.ToStringHasNull().Trim().ToLower() ||
                            userAccount.HardDiskSN.ToStringHasNull().Trim().ToLower() != param.HardSN.ToStringHasNull().Trim().ToLower())
                        {
                            throw new WarnException("您不能在本机登录!");
                        }
                    }
                    if (!string.IsNullOrEmpty(userAccount.UseTimeBegin.ToStringHasNull()) &&
                        !string.IsNullOrEmpty(userAccount.UseTimeOver.ToStringHasNull()))
                    {
                        DateTime start = (DateTime.Now.ToString("yyyy-MM-dd") + " " + userAccount.UseTimeBegin).ToDateTime();
                        DateTime end   = (DateTime.Now.ToString("yyyy-MM-dd") + " " + userAccount.UseTimeOver).ToDateTime();
                        if (!(DateTime.Now >= start && DateTime.Now <= end))
                        {
                            throw new WarnException("您不能在非工作时间(" + userAccount.UseTimeBegin + " - " + userAccount.UseTimeOver + ")登录!");
                        }
                    }
                }
                #endregion

                #region 判断登录用户数

                SYS_SignLogInfoBLL signBll = new SYS_SignLogInfoBLL();
                signBll.SessionInfo = this.SessionInfo;
                signBll.CheckLogUserRuler(
                    userAccount.GCompanyID,
                    userEmpInfo.EmpID,
                    userEmpInfo.EmpGuid,
                    userEmpInfo.EmpName,
                    SessionInfo.ClientIP,
                    SessionInfo.AdapterAddress);

                #endregion

                #region 修改登录统计信息

                this.Update <SYS_UserAccount>(new Field[] {
                    SYS_UserAccount._.SignInTimes,
                    SYS_UserAccount._.LastSignIP,
                    SYS_UserAccount._.LastSignTime,
                    SYS_UserAccount._.MacAddress,
                    SYS_UserAccount._.HardDiskSN
                }, new object[] {
                    userAccount.SignInTimes.GetValueOrDefault(0) + 1,
                    param.ClientIP,
                    DateTime.Now,
                    param.MacAddress,
                    param.HardSN
                }, SYS_UserAccount._.UserID == userAccount.UserID);
                #endregion

                #region 修改登录session
                SYS_SignLogInfoResult signParam = new SYS_SignLogInfoResult();
                signBll.SessionInfo   = this.SessionInfo;
                signParam.GCompanyID  = userAccount.GCompanyID;
                signParam.UserID      = userAccount.UserID;
                signParam.UserName    = userEmpInfo.EmpName;
                signParam.UserAdapter = this.SessionInfo.AdapterAddress;
                signParam.UserIP      = this.SessionInfo.ClientIP;
                signBll.UpdateUserOnline(signParam);
                #endregion
                #region 返回值
                result.GCompanyID   = userAccount.GCompanyID;
                result.UserID       = userAccount.UserID;
                result.EmpName      = userEmpInfo.EmpName;
                result.UserGUID     = userAccount.UserGUID;
                result.Account      = userAccount.Account;
                result.SaleCurrency = userEmpInfo.DefaultSaleCurreny;
                result.BuyCurrency  = userEmpInfo.DefaultBuyCurreny;
                result.OrgID        = userEmpInfo.OrgID;
                result.DeptID       = userEmpInfo.DeptID;
                result.LoginSucceed = 1;
                #endregion
                #region 获取部门名称和机构名称
                HR_OrgBLL        orgBll  = new HR_OrgBLL();
                HR_DepartmentBLL deptBll = new HR_DepartmentBLL();
                orgBll.SessionInfo  = this.SessionInfo;
                deptBll.SessionInfo = this.SessionInfo;
                result.OrgName      = orgBll.GetOrgName(result.OrgID.ToInt32());
                result.DeptName     = deptBll.GetDeptName(result.DeptID.ToInt32());
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }



            return(result);
        }
コード例 #36
0
        public ActionResult HROTDetailList(ModelSOTPEmpDetail model)
        {
            List <string>    messages        = new List <string>();
            ViewUserEmp      LoggedInUser    = Session["LoggedUser"] as ViewUserEmp;
            var              checkedEmpDates = Request.Form.GetValues("cbEmployee");
            HR_Employee      emp             = db.HR_Employee.First(aa => aa.EmployeeID == model.EmpID);
            PR_PayrollPeriod prp             = OTHelperManager.GetPayrollPeriod(db.PR_PayrollPeriod.ToList(), model.PeriodID);

            //messages = IsValidate(model);
            if (messages.Count == 0)
            {
                List <Att_OTDailyEntry> attOts     = db.Att_OTDailyEntry.Where(aa => aa.EmpID == model.EmpID && aa.OTDate >= prp.PStartDate && aa.OTDate <= prp.PEndDate).ToList();
                List <Att_OTDailyEntry> TempattOts = new List <Att_OTDailyEntry>();
                foreach (var id in checkedEmpDates)
                {
                    int    chNo    = Convert.ToInt32(id);
                    string EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                    string COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                    TempattOts.Add(attOts.First(aa => aa.EmpDate == EmpDate));
                }
                if (emp.Att_OTPolicy.DaysInMonth > 0)
                {
                    // check for Monthly Limit
                    if (TempattOts.Count > emp.Att_OTPolicy.DaysInMonth)
                    {
                        messages.Add("Your Monthly overtime claim limit exceeds.");
                    }
                    else
                    {
                        // check for weekly limit
                        if (emp.Att_OTPolicy.DaysInWeek > 0)
                        {
                            if (OTHelperManager.IsValidWeekPolicy(TempattOts.OrderByDescending(aa => aa.OTDate).ToList(), prp, emp.Att_OTPolicy.DaysInWeek))
                            {
                                messages.Add("Your weekly overtime claim limit exceeds.");
                            }
                        }
                    }
                }
                // check for daily ot limit
                {
                    //if (OTHelperManager.IsValidDailyOT(TempattOts, emp.Att_OTPolicy))
                    //    messages.Add("Your daily overtime claim limit exceeds.");
                }
                if (checkedEmpDates != null)
                {
                    if (messages.Count == 0)
                    {
                        foreach (var id in checkedEmpDates)
                        {
                            int              chNo    = Convert.ToInt32(id);
                            string           EmpDate = Request.Form["ED" + (chNo - 1).ToString()].ToString();
                            string           COTHour = Request.Form["ClaimOT" + (chNo - 1).ToString()].ToString();
                            Att_OTDailyEntry atot    = attOts.First(aa => aa.EmpDate == EmpDate);
                            atot.StatusID = Request.Form["DecisionID"].ToString();
                            if (LoggedInUser.UserType == "N")
                            {
                                if (atot.StatusID == "C")
                                {
                                    //atot.NtoPDateTime = DateTime.Now;
                                    atot.CancelByID = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ForwardToID = Convert.ToInt32(Request.Form["RecommendID"]);
                                    //atot.NtoPDateTime = DateTime.Now;
                                    //atot.NtoPUserID = LoggedInUser.UserID;
                                    //atot.OTProcessingPeriod = model.PeriodID;
                                }
                            }
                            else if (LoggedInUser.UserType == "R")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.PtoFCDateTime = DateTime.Now;
                                    atot.RejectByID    = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ForwardToID          = Convert.ToInt32(Request.Form["RecommendID"]);
                                    atot.PtoFCDateTime        = DateTime.Now;
                                    atot.PtoFCUserID          = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = model.PeriodID;
                                }
                            }
                            else if (LoggedInUser.UserType == "P")
                            {
                                if (atot.StatusID == "R")
                                {
                                    atot.FtoARDateTime = DateTime.Now;
                                    atot.RejectByID    = LoggedInUser.UserID;
                                }
                                else
                                {
                                    atot.ApprovedByID         = LoggedInUser.UserID;
                                    atot.FtoARDateTime        = DateTime.Now;
                                    atot.FtoARUserID          = LoggedInUser.UserID;
                                    atot.OTProcessingPeriodID = model.PeriodID;
                                }
                            }
                            db.SaveChanges();
                        }
                        return(RedirectToAction("REmpPending", new { DeptID = emp.SectionID, PayrollPeriodID = prp.PID }));
                    }
                }
            }
            ModelSOTPEmpDetail vm = new ModelSOTPEmpDetail();

            //vm = GetDetailPending(model.PeriodID, (int)emp.EmployeeID, LoggedInUser);
            vm.Message = messages;
            return(View(vm));
        }
コード例 #37
0
ファイル: HR_EmployeeProvider.cs プロジェクト: anam/mal
    public bool UpdateHR_EmployeeName(HR_Employee hR_Employee)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("UpdateHR_EmployeeName", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar).Value = hR_Employee.EmployeeID;

            cmd.Parameters.Add("@ExtraField1", SqlDbType.NVarChar).Value = hR_Employee.ExtraField1;
            cmd.Parameters.Add("@ExtraField2", SqlDbType.NVarChar).Value = hR_Employee.ExtraField2;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }