Example #1
0
        public ActionResult SetResignedDate(string loginid, int ID, DateTime ResignedDate, int pageIndex)
        {
            if (!string.IsNullOrEmpty(loginid))
            {
                ViewBag.LoginID = loginid;
            }
            else
            {
                ViewBag.LoginID = "";
            }
            CustomerOutsourc custOut = custOutDAL.GetModelByID(Convert.ToInt32(loginid));

            if (custOut != null)
            {
                ViewBag.Type = custOut.Type;
            }

            PersonsEntrySet personEntry = personEntryDAL.GetModelBy(ID);

            if (personEntry != null)
            {
                personEntry.ResignedDate = ResignedDate;
                personEntry.EntryStatus  = 1;
                personEntryDAL.Update(personEntry);

                //离职后更改个人信息中个人状态
                PersonalInfo person = personInfoDAL.GetPersonalInfo(personEntry.PersonalInfoId);
                if (person != null)
                {
                    person.PeopleStatue = 1;
                    personInfoDAL.Update(person);
                }
                //离职后直接结算个人账务
                DateTime d1 = new DateTime(ResignedDate.Year, ResignedDate.Month, 1); //当月第一天
                DateTime d2 = d1.AddMonths(1).AddDays(-1);                            //当月最后一天

                long workDays     = dateDiff(d1, d2);                                 //本月工作日
                long RealworkDays = dateDiff(d1, ResignedDate);                       //本月实际工作日


                //通过参数获取个人结算表中当月是否有记录
                PersonSettlement model = personnelSettDAL.GetModelByParam(personEntry.PersonalInfoId, personEntry.OutsourcingCompanyCompnayId, personEntry.CustomerCompnayCompnayId, ResignedDate);
                if (model == null)//没有就添加
                {
                    model              = new PersonSettlement();
                    model.ID           = Guid.NewGuid().ToString();
                    model.PersonID     = personEntry.PersonalInfoId;
                    model.CustomerID   = personEntry.CustomerCompnayCompnayId;
                    model.OutCompanyID = personEntry.OutsourcingCompanyCompnayId;
                }
                model.WorkDays       = (int)workDays;
                model.SettlementDate = ResignedDate;
                model.Wages          = (double)personEntryDAL.GetModelBy(personEntry.PersonalInfoId, personEntry.CustomerCompnayCompnayId, personEntry.OutsourcingCompanyCompnayId).EntryMoney;

                if (model == null)
                {
                    personnelSettDAL.Insert(model);
                }

                #region 计算考勤工资
                const double HourByDay = 0.125; //8小时按1天算

                //工作日-实际出勤日=请假日或未上班的天数
                double leaveDays = (workDays - RealworkDays) * 8;
                //事假小时与事假被扣总金额;
                double leaveTotalMoney = ((model.Wages / workDays) / 8 * leaveDays) * -1;

                float overTimesPremium = 0f, overTimePremiumTotalMoney = 0f; //加班补助金额和加班时间;
                float LeaveOffDay = 0f, LeaveOffDayTotalMoney = 0f;          //事假(调休)的时长和金额
                float overTimes = 0f, overTimesTotalMoney = 0f;              // 加班时长和加班金额;
                #region 统计考勤中的加班与请假天数
                foreach (var item in leaveDetailDAL.GetModelList(model.ID, model.SettlementDate.Month))
                {
                    switch (item.LeaveType)
                    {
                    case 1:     //事假
                        leaveDays       += (float)item.LeaveHours;
                        leaveTotalMoney += (float)item.LeaveMoney;
                        break;

                    case 2:     //加班补助
                        overTimesPremium          += (float)item.LeaveHours;
                        overTimePremiumTotalMoney += (float)item.LeaveMoney;
                        break;

                    case 3:    //事假调休
                        LeaveOffDay           += (float)item.LeaveHours;
                        LeaveOffDayTotalMoney += (float)item.LeaveMoney;
                        break;

                    case 4:    //加班
                        overTimes           += (float)item.LeaveHours;
                        overTimesTotalMoney += (float)item.LeaveMoney;
                        break;
                    }
                }
                #endregion

                //工资结算中只包含加班补助和事假工资计算;
                // 计算请假天数=请假天数+调休天数
                model.LeaveDays = leaveDays == 0 ? 0 : Math.Round((leaveDays + LeaveOffDay) * HourByDay, 2);
                //计算加班天数
                model.OvertimeDays = overTimes == 0 ? 0 : Math.Round(overTimes * HourByDay, 2);
                //计算实际工作日=本月工作日-(请假时间+调休时间)*时间基数
                model.RealWorkDays = Math.Round(model.WorkDays - (leaveDays + LeaveOffDay) * HourByDay, 2);
                //到手工资=应得工资+加班补助+事假工资
                model.RealWages = Math.Round(model.Wages + overTimePremiumTotalMoney + leaveTotalMoney, 2);//计算请假后的工资;
                personnelSettDAL.Update(model);
                #endregion
            }

            string url = string.Format("loginid={0}&page={1}", loginid, pageIndex);
            return(Content(url));
        }
Example #2
0
        public ActionResult PersonEntry(string loginid, int comid, int pid, int outcid, int rid, DateTime time, int money, string PersonLevel)
        {
            if (!string.IsNullOrEmpty(loginid))
            {
                ViewBag.LoginID = loginid;
            }
            else
            {
                ViewBag.LoginID = "";
            }
            List <CustomerOutsourc> custOut = custOutDAL.GetlList("CustomerOutID=" + loginid);

            if (custOut.Count > 0)
            {
                string types = custOut[0].Type.ToString();
                ViewBag.Type = types;
            }

            #region 添加人员入职信息
            PersonsEntrySet model = new PersonsEntrySet();
            model.EntryDate                   = time;
            model.EntryStatus                 = 0; //0在职,1离职
            model.PersonalInfoId              = pid;
            model.CustomerCompnayCompnayId    = comid;
            model.OutsourcingCompanyCompnayId = outcid;
            model.EntryMoney                  = money;
            personEntryDAL.Insert(model);


            // 更新人员表中的个人状态
            PersonalInfo person = personalDAL.GetPersonalInfo(pid);
            if (person != null)
            {
                person.PeopleStatue = 0;
                personalDAL.Update(person);
            }
            #endregion

            #region 人员派遣单指定
            EmployeeExpatriation employeeModel = employeeDAL.GetModelByParam(comid, outcid, model.EntryDate.Value);
            if (employeeModel == null)
            {
                employeeModel = new EmployeeExpatriation();
                #region 如果不存在当前人员派遣单,则添加新的
                employeeModel.ID            = Guid.NewGuid().ToString();
                employeeModel.FirstPartyID  = comid;
                employeeModel.SecondPartyID = outcid;
                employeeModel.EntryDate     = model.EntryDate;
                employeeModel.FirstContent  = ContractOpration.GetEmployeeExpatriationTop();
                employeeModel.SecondContent = ContractOpration.GetEmployeeExpatriationBottom();
                employeeModel.PersonList    = ContractOpration.GetEmployeeExpatriationCenter(
                    person.PersonName,
                    person.Publications,
                    PersonLevel,                                         //人员评定级别
                    model.EntryDate.Value.ToString("yyyy-MM-dd"),
                    model.EntryMoney.ToString());
                //是否同意 0:同意 1:审阅中
                employeeModel.FirstPartyStatus  = 1;
                employeeModel.SecondPartyStatus = 1;
                //合同是否生效 0 未生效;1生效
                employeeModel.FirstPartEffectiveStatus   = 0;
                employeeModel.SecondPartyEffectiveStatus = 0;
                //派遣协议状态合同状态 0:未生效 1:已生效
                employeeModel.ContractStatus = 0;

                employeeDAL.Insert(employeeModel);
                #endregion
            }
            else
            {
                //如果存在则更新到内容中
                string str = ContractOpration.GetEmployeeExpatriationCenter(
                    person.PersonName,
                    person.Publications,
                    "初级",
                    model.EntryDate.Value.ToString("yyyy-MM-dd"),
                    model.EntryMoney.ToString());
                employeeModel.PersonList += str;
                employeeDAL.Update(employeeModel);
            }
            #endregion

            #region 添加合作合同
            if (!cooperativeContractDAL.IsExist(comid, outcid))//判断当前合作合同是否存在;
            {
                DateTime            dt          = DateTime.Now;
                CooperativeContract cooperModel = new CooperativeContract();
                cooperModel.ID                         = Guid.NewGuid().ToString();
                cooperModel.ContractCode               = string.Format("YJY-{0}-{1}-{2}", dt.Year, dt.Month, cooperativeContractDAL.GetContractNumberByDate());
                cooperModel.ContractFirstParty         = comid;
                cooperModel.ContractSecondParty        = outcid;
                cooperModel.ContractStatus             = 0;//合同状态 0:未生效 1:已生效
                cooperModel.FirstPartEffectiveStatus   = 0;
                cooperModel.SecondPartyEffectiveStatus = 0;

                cooperModel.SigningTime       = dt; //签约时间
                cooperModel.FirstPartyStatus  = 1;  // 0:同意 1:审阅中
                cooperModel.SecondPartyStatus = 1;  // 0:同意 1:审阅中

                //获取派遣协议模板
                cooperModel.ContractContent = ContractOpration.GetDispatchingAgreement();
                cooperativeContractDAL.Insert(cooperModel);
            }
            #endregion

            //暂时未找到跳转不到指定Action原因,据说是因为域的问题
            string url = string.Format("loginid={0}&rid={1}&pid={2}", loginid, rid, pid);
            return(Content(url));
        }