public ActionResult PersonsResignedList(string loginid, string type, int page = 1) { if (!string.IsNullOrEmpty(loginid)) { ViewBag.LoginID = loginid; } else { ViewBag.LoginID = ""; } CustomerOutsourc custOut = custOutDAL.GetModelByID(Convert.ToInt32(loginid)); int?types = null; if (custOut != null) { types = custOut.Type; ViewBag.Type = types; } List <PersonsEntrySet> list = null; if (types != null) { switch (types) { case 1: #region 外包公司 OutsourcingCompany outsourcing = outCompanyDAL.GetOutsourcingCompany(custOut.CompanyUserName); if (outsourcing != null) { list = personEntryDAL.GetModelList(outsourcing.CompnayId); } else { list = new List <PersonsEntrySet>(); } #endregion break; case 2: #region 客户公司 Outsourcing.EF.CustomerCompnay customer = customerCompnayDAL.GetModel(custOut.CompanyUserName); if (customer != null) { list = personEntryDAL.GetModelList(customer.CompnayId, 2); } else { list = new List <PersonsEntrySet>(); } #endregion break; } } Models.PersonsResignedViewModel viewModel = new Models.PersonsResignedViewModel(); //判断离职日期不为空的人员 viewModel.PersonsEntrySets = list.Where(m => m.ResignedDate != null).ToPagedList(page, 8); return(View(viewModel)); }
public ActionResult PersonSettl(string loginid, int PersonID, int CustomerID, int OutCompanyID, int page = 1) { if (!string.IsNullOrEmpty(loginid)) { ViewBag.LoginID = loginid; } else { ViewBag.LoginID = ""; } CustomerOutsourc custOut = custOutDAL.GetModelByID(Convert.ToInt32(loginid)); if (custOut != null) { ViewBag.Type = custOut.Type; } ViewBag.PersonID = PersonID; ViewBag.CustomerID = CustomerID; ViewBag.OutCompanyID = OutCompanyID; Models.PersonSettlViewModel viewModel = new Models.PersonSettlViewModel(); DateTime now = DateTime.Now; DateTime d1 = new DateTime(now.Year, now.Month, 1); //当月第一天 DateTime d2 = d1.AddMonths(1).AddDays(-1); //当月最后一天 long workDays = dateDiff(d1, d2); //获取当前月工作天数 viewModel.StartDate = d1.ToString("yyyy-MM-dd"); viewModel.EndDate = d2.ToString("yyyy-MM-dd"); viewModel.workDays = workDays; PersonSettlement model = personnelSettDAL.GetModelByParam(PersonID, OutCompanyID, CustomerID, d1); if (model == null) { model = new PersonSettlement(); model.ID = Guid.NewGuid().ToString(); model.PersonID = PersonID; model.CustomerID = CustomerID; model.OutCompanyID = OutCompanyID; model.WorkDays = (int)workDays; model.SettlementDate = DateTime.Now; model.Wages = (double)personEntryDAL.GetModelBy(PersonID, CustomerID, OutCompanyID).EntryMoney; personnelSettDAL.Insert(model); } //else //{ //} viewModel.LeaveDetail = model.LeaveDetail.OrderBy(m => m.LeaveStartDate).ToPagedList <LeaveDetail>(page, 8); viewModel.Money = model.Wages; ViewBag.PersonSettlementID = model.ID; return(View(viewModel)); }
//登录 public ActionResult Login(CustomerOutsourc custOutsourc, string CompanyUserName, string Pwd) { string msg = "该账号不存在"; Hashtable result = new Hashtable(); List <CustomerOutsourc> custOut = custOutDAL.GetCountlList(CompanyUserName); if (custOut.Count > 0) { int types = Convert.ToInt32(custOut[0].Type); result["LoginID"] = custOut[0].CustomerOutID; Session["LoginID"] = custOut[0].CustomerOutID; Session["TemporaryID"] = custOut[0].CustomerOutID; Session["types"] = types; if (types == 1) { List <OutsourcingCompany> outCompany = outCompnayDAL.GetCountlList(CompanyUserName); int statue = Convert.ToInt32(outCompany[0].AuditingStatue); int IsDelete = Convert.ToInt32(outCompany[0].IsDelete); int id = Convert.ToInt32(outCompany[0].CompnayId); string pwd = custOut[0].Pwd; if (IsDelete == 1) { if (pwd == Pwd) { msg = "登录成功"; Session["ID"] = id; //result["LoginID"] = msg; Session["CompanyUserName"] = CompanyUserName; Session["pws"] = pwd; Session["type"] = types; result["msg"] = msg; } else { msg = "密码错误"; result["msg"] = msg; } } else { result["msg"] = msg; } } else { List <CustomerCompnay> custCompany = custCompnayDAL.GetCountlList(CompanyUserName); int IsDelete = Convert.ToInt32(custCompany[0].IsDelete); int statue = Convert.ToInt32(custCompany[0].AuditingStatue); int id = Convert.ToInt32(custCompany[0].CompnayId); string pwd = custOut[0].Pwd; if (IsDelete == 1) { if (pwd == Pwd) { msg = "登录成功"; Session["ID"] = id; //result["LoginID"] = msg; Session["CompanyUserName"] = CompanyUserName; Session["pws"] = pwd; Session["type"] = types; result["msg"] = msg; } else { msg = "密码错误"; result["msg"] = msg; } } else { result["msg"] = msg; } } } else { result["msg"] = msg; } return(Json(result)); }
public ActionResult AddPersonLeaveDetail(string loginid) { if (!string.IsNullOrEmpty(loginid)) { ViewBag.LoginID = loginid; } else { ViewBag.LoginID = ""; } CustomerOutsourc custOut = custOutDAL.GetModelByID(Convert.ToInt32(loginid)); if (custOut != null) { ViewBag.Type = custOut.Type; } ViewBag.PersonID = Request["PersonID"]; ViewBag.CustomerID = Request["CustomerID"]; ViewBag.OutCompanyID = Request["OutCompanyID"]; #region 初始化数据 LeaveDetail leaveDetail = new LeaveDetail(); leaveDetail.ID = Guid.NewGuid().ToString(); leaveDetail.PersonSettlementID = Request["ID"].ToString(); leaveDetail.LeaveStartDate = Convert.ToDateTime(Request["stime"]); leaveDetail.LeaveEndDate = Convert.ToDateTime(Request["etime"]); leaveDetail.LeaveHours = (decimal)(leaveDetail.LeaveEndDate - leaveDetail.LeaveStartDate).TotalHours; leaveDetail.LeaveReason = Request["LeaveReason"].ToString(); DateTime now = DateTime.Now; DateTime d1 = new DateTime(now.Year, now.Month, 1); //当月第一天 DateTime d2 = d1.AddMonths(1).AddDays(-1); //当月最后一天 long workDays = dateDiff(d1, d2); //获取当前月工作天数 decimal money = Convert.ToDecimal(Request["Moneys"]); switch (Convert.ToInt32(Request["leaveType"])) { case 1: //请假 leaveDetail.LeaveType = 1; //(工资÷工作日总数)÷工作8小时×请假时间 leaveDetail.LeaveMoney = ((money / workDays) / 8 * leaveDetail.LeaveHours) * -1; break; case 2: //加班补助 //加班补助直接录入 leaveDetail.LeaveMoney = money; leaveDetail.LeaveType = 2; break; case 3: //事假调休 //事假调休不计入工资计算 leaveDetail.LeaveMoney = 0; leaveDetail.LeaveType = 3; break; case 4: //加班 //加班不计算加班费算法 leaveDetail.LeaveMoney = 0; leaveDetail.LeaveType = 4; break; } leaveDetailDAL.Insert(leaveDetail); #endregion string url = string.Format("loginid={0}&&PersonID={1}&&CustomerID={2}&&OutCompanyID={3}&&page ={4}", loginid, ViewBag.PersonID, ViewBag.CustomerID, ViewBag.OutCompanyID, 1); return(Content(url)); //return RedirectToAction("PersonSettl", new { loginid=loginid, PersonID= ViewBag.PersonID, CustomerID= ViewBag.CustomerID, OutCompanyID= ViewBag.OutCompanyID, page = 1 }); }
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)); }
public ActionResult GetPasswordData(CustomerOutsourc custOutsourc, CustomerCompnay custCompnay, OutsourcingCompany outCompany, string password) { string msg = "保存成功"; string pws = Session["pws"].ToString(); string CompanyUserName = Session["CompanyUserName"].ToString(); int type = Convert.ToInt32(Session["type"]); if (type == 1) { List <CustomerOutsourc> Cusout = custOutDAL.GetCountlList(CompanyUserName); List <OutsourcingCompany> Company = outCompnayDAL.GetCountlList(CompanyUserName); if (pws == password) { if (outCompany != null && custOutsourc != null) { //修改中间表 custOutsourc.CustomerOutID = Cusout[0].CustomerOutID; custOutsourc.CompanyUserName = CompanyUserName; custOutsourc.Type = Cusout[0].Type; custOutsourc.CreateTime = Cusout[0].CreateTime; //修改外包表 outCompany.CompnayId = Company[0].CompnayId; outCompany.CompanyUserName = CompanyUserName; outCompany.Email = Company[0].Email; outCompany.CompnayName = Company[0].CompnayName; outCompany.EnglishName = Company[0].EnglishName; outCompany.LegalRepresentative = Company[0].LegalRepresentative; outCompany.LegalTelephone = Company[0].LegalTelephone; outCompany.UnitResponsible = Company[0].UnitResponsible; outCompany.ResponsibleTelephone = Company[0].ResponsibleTelephone; outCompany.Address = Company[0].Address; outCompany.EnterpriseNum2 = Company[0].EnterpriseNum2; outCompany.RegistrationAuthority = Company[0].RegistrationAuthority; outCompany.BusinessScope = Company[0].BusinessScope; outCompany.IsDelete = Company[0].IsDelete; outCompany.AuditingStatue = Company[0].AuditingStatue; outCompany.CreateTime = Company[0].CreateTime; outCompany.UpdateTime = DateTime.Now; int result = custOutDAL.Update(custOutsourc); int results = outCompnayDAL.Update(outCompany); if (result > 0 && results > 0) { return(Content(msg)); } } else { msg = "保存失败"; return(Content(msg)); } } else { msg = "原密码错误"; return(Content(msg)); } return(Content(msg)); } else { List <CustomerOutsourc> Cusout = custOutDAL.GetCountlList(CompanyUserName); List <CustomerCompnay> Company = custCompnayDAL.GetCountlList(CompanyUserName); if (pws == password) { if (custCompnay != null && custOutsourc != null) { //修改中间表 custOutsourc.CustomerOutID = Cusout[0].CustomerOutID; custOutsourc.CompanyUserName = CompanyUserName; custOutsourc.Type = Cusout[0].Type; custOutsourc.CreateTime = Cusout[0].CreateTime; //修改客户表 custCompnay.CompnayId = Company[0].CompnayId; custCompnay.CompanyUserName = CompanyUserName; custCompnay.Email = Company[0].Email; custCompnay.CompnayName = Company[0].CompnayName; custCompnay.EnglishName = Company[0].EnglishName; custCompnay.LegalRepresentative = Company[0].LegalRepresentative; custCompnay.LegalTelephone = Company[0].LegalTelephone; custCompnay.UnitResponsible = Company[0].UnitResponsible; custCompnay.ResponsibleTelephone = Company[0].ResponsibleTelephone; custCompnay.Address = Company[0].Address; custCompnay.EnterpriseNum2 = Company[0].EnterpriseNum2; custCompnay.RegistrationAuthority = Company[0].RegistrationAuthority; custCompnay.BusinessScope = Company[0].BusinessScope; custCompnay.IsDelete = Company[0].IsDelete; custCompnay.AuditingStatue = Company[0].AuditingStatue; custCompnay.CreateTime = Company[0].CreateTime; custCompnay.UpdateTime = DateTime.Now; int result = custOutDAL.Update(custOutsourc); int results = custCompnayDAL.Update(custCompnay); if (result > 0 && results > 0) { return(Content(msg)); } } else { msg = "保存失败"; return(Content(msg)); } } else { msg = "原密码错误"; return(Content(msg)); } return(Content(msg)); } }
public ActionResult Add(CustomerOutsourc custOutsourc, CustomerCompnay custCompnay, OutsourcingCompany outCompany, string CompanyUserName, string Email, string password, int num) { string msg = "注册失败"; try { if (num == 1) { //添加帐户 using (var ct = new DB()) { //将新注册用户添加到CustomerCompnay和OutsourcingCompany的中间表 custOutsourc.CompanyUserName = CompanyUserName; custOutsourc.Pwd = password; custOutsourc.Type = num; custOutsourc.CreateTime = DateTime.Now; ct.CustomerOutsourc.Add(custOutsourc); //将新注册用户添加到外包公司表OutsourcingCompany outCompany.CompanyUserName = CompanyUserName; outCompany.Pwd = password; outCompany.Email = Email; outCompany.AuditingStatue = 0; outCompany.IsDelete = 1; outCompany.CreateTime = DateTime.Now; ct.OutsourcingCompany.Add(outCompany); if (custOutsourc.CustomerOutID <= 0) { msg = "注册成功"; } ct.SaveChanges(); return(Content(msg)); } } else if (num == 2) { //添加帐户 using (var ct = new DB()) { //将新注册用户添加到CustomerCompnay和OutsourcingCompany的中间表 custOutsourc.CompanyUserName = CompanyUserName; custOutsourc.Pwd = password; custOutsourc.Type = num; custOutsourc.CreateTime = DateTime.Now; ct.CustomerOutsourc.Add(custOutsourc); //将新注册用户添加到客户公司表CustomerCompnay custCompnay.CompanyUserName = CompanyUserName; custCompnay.Pwd = password; custCompnay.Email = Email; custCompnay.AuditingStatue = 0; custCompnay.IsDelete = 1; custCompnay.CreateTime = DateTime.Now; ct.CustomerCompnay.Add(custCompnay); if (custOutsourc.CustomerOutID <= 0) { msg = "注册成功"; } ct.SaveChanges(); return(Content(msg)); } } return(Content(msg)); } catch (Exception e) { return(Content(msg)); } }