コード例 #1
0
ファイル: SendController.cs プロジェクト: yaronfeng/HR_System
        public ActionResult SendEmployeeEmail(int id)
        {
            if (id <= 0)
            {
                return(Json(new ResultModel(string.Format("用户薪资不存在"))));
            }

            EmployeeSalaryBLL empsBLL = new EmployeeSalaryBLL();
            EmployeeBLL       empBLL  = new EmployeeBLL();

            ResultModel result = empsBLL.Get(id);

            if (result.ResultStatus != 0)
            {
                return(Json(result));
            }

            EmployeeSalary rtnEmployeeSalary = result.ReturnValue as EmployeeSalary;

            if (rtnEmployeeSalary == null)
            {
                return(Json(new ResultModel(string.Format("用户薪资不存在"))));
            }

            result = empBLL.Get(rtnEmployeeSalary.EmpId);
            if (result.ResultStatus != 0)
            {
                return(Json(result));
            }

            Employee rtnEmployee = result.ReturnValue as Employee;

            if (rtnEmployee == null)
            {
                return(Json(new ResultModel(string.Format("用户不存在"))));
            }



            string[] To      = { "*****@*****.**" };
            string   Subject = "工资" + rtnEmployeeSalary.PayDate.ToString("yyyyMMdd");
            string   Body    = rtnEmployee.EmpName + "您好," + rtnEmployeeSalary.PayDate.ToString("yyyyMMdd") + "工资明细为:";

            Body += "<br>应发工资:" + rtnEmployeeSalary.TotalAmount;
            Body += "<br>养老保险:" + rtnEmployeeSalary.EmpPensionIns;
            Body += "<br>医疗保险:" + rtnEmployeeSalary.EmpMedicalIns;
            Body += "<br>失业保险:" + rtnEmployeeSalary.EmpUnempIns;
            Body += "<br>工伤保险:" + rtnEmployeeSalary.EmpInjuryIns;
            Body += "<br>生育保险:" + rtnEmployeeSalary.EmpBirthIns;
            Body += "<br>残疾人保险:" + rtnEmployeeSalary.EmpDisabledIns;
            Body += "<br>大病保险:" + rtnEmployeeSalary.EmpIllnessIns;
            Body += "<br>取暖费:" + rtnEmployeeSalary.EmpHeatAmount;
            Body += "<br>公积金:" + rtnEmployeeSalary.EmpHouseFund;
            Body += "<br>补充工伤:" + rtnEmployeeSalary.EmpRepInjuryIns;
            Body += "<br>个调税:" + rtnEmployeeSalary.PersonalTax;
            Body += "<br>实发工资:" + rtnEmployeeSalary.FinalAmount;
            SendMail.Send(To, Subject, Body);

            return(Json(result));
        }
コード例 #2
0
        public ActionResult LoadEmployeeSalaryList(int pageIndex, int pageSize, string orderField, string sortOrder, string empName, int corpId)
        {
            switch (orderField)
            {
            case "EmpSalaryId":
                orderField = "EmpSalaryId";
                break;
            }
            string orderStr = string.Format("{0} {1}", orderField, sortOrder);

            EmployeeSalaryBLL empsBLL = new EmployeeSalaryBLL();
            ResultModel       result  = empsBLL.LoadEmployeeSalaryList(pageIndex, pageSize, orderStr, empName, corpId);

            System.Data.DataTable       dt  = result.ReturnValue as System.Data.DataTable;
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("count", result.AffectCount);
            dic.Add("data", dt);
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(dic, new Newtonsoft.Json.Converters.DataTableConverter());

            result.ReturnValue = jsonStr;

            return(Json(result));
        }
コード例 #3
0
        public ActionResult InsertEmployeeSalary(EmployeeSalary[] details)
        {
            string            empId        = string.Empty;
            EmployeeBLL       empBLL       = new EmployeeBLL();
            EmployeeSalaryBLL empSalaryBLL = new EmployeeSalaryBLL();

            List <SocialBase> socialBaseList = BaseProvider.SocialBases;
            ResultModel       result         = new ResultModel();

            foreach (var emp in details)
            {
                ResultModel <Employee> resultEmployee = empBLL.Get <Employee>(emp.EmpId);
                if (resultEmployee.ResultStatus != 0)
                {
                    return(Json(resultEmployee));
                }

                Employee rtnEmployee = resultEmployee.ReturnValue;
                if (rtnEmployee == null)
                {
                    return(Json(new ResultModel(string.Format("{0}不存在", this.ModelName))));
                }

                SocialBase socialBase = socialBaseList.FirstOrDefault(temp => temp.CityId == rtnEmployee.PayCity);
                if (socialBase == null)
                {
                    return(Json(new ResultModel("社保信息不存在")));
                }

                decimal corpPensionIns   = rtnEmployee.RISINum * socialBase.CorpPensionInsPoint / 100 + socialBase.PensionInsFix;
                decimal corpMedicalIns   = rtnEmployee.MISINum * socialBase.CorpMedicalInsPoint / 100 + socialBase.MedicalInsFix;
                decimal corpUnempIns     = rtnEmployee.UISINum * socialBase.CorpUnempInsPoint / 100 + socialBase.UnempInsFix;
                decimal corpInjuryIns    = rtnEmployee.IISINum * socialBase.CorpInjuryInsPoint / 100 + socialBase.InjuryInsFix;
                decimal corpBirthIns     = rtnEmployee.BISINum * socialBase.CorpBirthInsPoint / 100 + socialBase.BirthInsFix;
                decimal corpDisabledIns  = rtnEmployee.DISINum * socialBase.CorpDisabledInsPoint / 100 + socialBase.DisabledInsFix;
                decimal corpIllnessIns   = rtnEmployee.LISINum * socialBase.CorpIllnessInsPoint / 100 + socialBase.IllnessInsFix;
                decimal corpHeatAmount   = rtnEmployee.HASINum * socialBase.CorpHeatAmountPoint / 100 + socialBase.HeatAmountFix;
                decimal corpHouseFund    = rtnEmployee.HFSINum * socialBase.CorpHouseFundPoint / 100 + socialBase.HouseFundFix;
                decimal corpRepInjuryIns = rtnEmployee.RISINum * socialBase.CorpRepInjuryInsPoint / 100 + socialBase.RepInjuryInsFix;
                decimal corpTotal        = corpPensionIns + corpMedicalIns + corpUnempIns + corpInjuryIns + corpBirthIns + corpDisabledIns + corpIllnessIns + corpHeatAmount + corpHouseFund + corpRepInjuryIns;

                decimal empPensionIns   = rtnEmployee.RISINum * socialBase.EmpPensionInsPoint / 100 + socialBase.PensionInsFix;
                decimal empMedicalIns   = rtnEmployee.MISINum * socialBase.EmpMedicalInsPoint / 100 + socialBase.MedicalInsFix;
                decimal empUnempIns     = rtnEmployee.UISINum * socialBase.EmpUnempInsPoint / 100 + socialBase.UnempInsFix;
                decimal empInjuryIns    = rtnEmployee.IISINum * socialBase.EmpInjuryInsPoint / 100 + socialBase.InjuryInsFix;
                decimal empBirthIns     = rtnEmployee.BISINum * socialBase.EmpBirthInsPoint / 100 + socialBase.BirthInsFix;
                decimal empDisabledIns  = rtnEmployee.DISINum * socialBase.EmpDisabledInsPoint / 100 + socialBase.DisabledInsFix;
                decimal empIllnessIns   = rtnEmployee.LISINum * socialBase.EmpIllnessInsPoint / 100 + socialBase.IllnessInsFix;
                decimal empHeatAmount   = rtnEmployee.HASINum * socialBase.EmpHeatAmountPoint / 100 + socialBase.HeatAmountFix;
                decimal empHouseFund    = rtnEmployee.HFSINum * socialBase.EmpHouseFundPoint / 100 + socialBase.HouseFundFix;
                decimal empRepInjuryIns = rtnEmployee.RISINum * socialBase.EmpRepInjuryInsPoint / 100 + socialBase.RepInjuryInsFix;
                decimal empTotal        = empPensionIns + empMedicalIns + empUnempIns + empInjuryIns + empBirthIns + empDisabledIns + empIllnessIns + empHeatAmount + empHouseFund + empRepInjuryIns;


                EmployeeSalary empSalary = new EmployeeSalary();
                empSalary.EmpId            = rtnEmployee.EmpId;
                empSalary.PayCity          = rtnEmployee.PayCity;
                empSalary.CorpId           = rtnEmployee.CorpId;
                empSalary.SupId            = rtnEmployee.SupId;
                empSalary.CorpPensionIns   = corpPensionIns;
                empSalary.CorpMedicalIns   = corpMedicalIns;
                empSalary.CorpUnempIns     = corpUnempIns;
                empSalary.CorpInjuryIns    = corpInjuryIns;
                empSalary.CorpBirthIns     = corpBirthIns;
                empSalary.CorpDisabledIns  = corpDisabledIns;
                empSalary.CorpIllnessIns   = corpIllnessIns;
                empSalary.CorpHeatAmount   = corpHeatAmount;
                empSalary.CorpHouseFund    = corpHouseFund;
                empSalary.CorpRepInjuryIns = corpRepInjuryIns;
                empSalary.CorpTotal        = corpTotal;

                empSalary.EmpPensionIns   = empPensionIns;
                empSalary.EmpMedicalIns   = empMedicalIns;
                empSalary.EmpUnempIns     = empUnempIns;
                empSalary.EmpInjuryIns    = empInjuryIns;
                empSalary.EmpBirthIns     = empBirthIns;
                empSalary.EmpDisabledIns  = empDisabledIns;
                empSalary.EmpIllnessIns   = empIllnessIns;
                empSalary.EmpHeatAmount   = empHeatAmount;
                empSalary.EmpHouseFund    = empHouseFund;
                empSalary.EmpRepInjuryIns = empRepInjuryIns;
                empSalary.EmpTotal        = empTotal;

                empSalary.TotalAmount  = emp.TotalAmount;
                empSalary.RepairAmount = emp.RepairAmount;   //补充社保
                decimal grossAmount = emp.TotalAmount - empTotal;
                empSalary.GrossAmount = grossAmount;         //税前
                decimal personalTax = Calculator.PersonalTax(grossAmount);
                empSalary.PersonalTax = personalTax;         //个调税
                decimal finalAmount = grossAmount - personalTax;
                empSalary.FinalAmount   = finalAmount;       //实发
                empSalary.ServiceAmount = emp.ServiceAmount; //服务费
                empSalary.RefundAmount  = emp.RefundAmount;  //补收/退款

                empSalary.PayDate         = DateTime.Now;
                empSalary.EmpSalaryStatus = (int)StatusEnum.已完成;
                result = empSalaryBLL.Insert(empSalary);

                if (result.ResultStatus != 0)
                {
                    return(Json(result));
                }
            }


            result.Message      = "员工薪资发放成功";
            result.ReturnValue  = "";
            result.ResultStatus = 0;
            return(Json(result));
        }
コード例 #4
0
        public ActionResult EmpUpLoadFile()
        {
            HttpFileCollectionBase files = Request.Files;
            var file = files[0];

            //上传文件并指定上传目录的路径
            String fileSave = Server.MapPath("~/uploads/") + file.FileName;//在服务器的路径,上传Excel的路径

            file.SaveAs(fileSave);
            //解析Excel
            DataSet ds = new DataSet();

            ds = ExcelToDS(fileSave); //调用ExcelToDS方法解析Excel
            ResultModel result = new ResultModel();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DateTime payDate     = Convert.ToDateTime(ds.Tables[0].Rows[i][0]);
                string   empName     = ds.Tables[0].Rows[i][1].ToString();         //姓名
                string   cardNo      = ds.Tables[0].Rows[i][2].ToString();         //身份证
                decimal  totalAmount = Convert.ToDecimal(ds.Tables[0].Rows[i][3]); //应发工资

                EmployeeBLL            empBLL         = new EmployeeBLL();
                ResultModel <Employee> resultEmployee = empBLL.GetEmployeeByCardNo(cardNo);

                if (resultEmployee.ResultStatus != 0 || resultEmployee == null)
                {
                    return(Json(resultEmployee));
                }

                List <Employee> employeeList = resultEmployee.ReturnValues;
                if (employeeList == null)
                {
                    return(Json(employeeList));
                }
                Employee rtnEmployee = employeeList.FirstOrDefault();

                CorporationBLL            corpBLL    = new CorporationBLL();
                ResultModel <Corporation> resultCorp = corpBLL.Get <Corporation>(rtnEmployee.CorpId);
                if (resultCorp.ResultStatus != 0)
                {
                    return(Json(new ResultModel("企业不存在")));
                }

                Corporation rtnCorp = resultCorp.ReturnValue;
                if (rtnCorp == null || rtnCorp.CorpId < 0)
                {
                    return(Json(new ResultModel("企业不存在")));
                }

                EmployeeSalaryBLL empSalaryBLL   = new EmployeeSalaryBLL();
                List <SocialBase> socialBaseList = BaseProvider.SocialBases;

                SocialBase socialBase = socialBaseList.FirstOrDefault(temp => temp.CityId == rtnEmployee.PayCity);
                if (socialBase == null)
                {
                    return(Json(new ResultModel("社保信息不存在")));
                }

                ResultModel <EmployeeSalary> resultEmps = empSalaryBLL.LoadEmployeeSalaryCheckOne(rtnEmployee.EmpId, payDate);
                if (resultEmps.ResultStatus != 0 || resultEmps == null)
                {
                    return(Json(resultEmps));
                }
                List <EmployeeSalary> empsList = resultEmps.ReturnValues;
                if (empsList == null || empsList.Count > 0)
                {
                    continue;
                }

                decimal corpPensionIns   = rtnEmployee.RISINum * socialBase.CorpPensionInsPoint / 100 + socialBase.PensionInsFix;
                decimal corpMedicalIns   = rtnEmployee.MISINum * socialBase.CorpMedicalInsPoint / 100 + socialBase.MedicalInsFix;
                decimal corpUnempIns     = rtnEmployee.UISINum * socialBase.CorpUnempInsPoint / 100 + socialBase.UnempInsFix;
                decimal corpInjuryIns    = rtnEmployee.IISINum * socialBase.CorpInjuryInsPoint / 100 + socialBase.InjuryInsFix;
                decimal corpBirthIns     = rtnEmployee.BISINum * socialBase.CorpBirthInsPoint / 100 + socialBase.BirthInsFix;
                decimal corpDisabledIns  = rtnEmployee.DISINum * socialBase.CorpDisabledInsPoint / 100 + socialBase.DisabledInsFix;
                decimal corpIllnessIns   = rtnEmployee.LISINum * socialBase.CorpIllnessInsPoint / 100 + socialBase.IllnessInsFix;
                decimal corpHeatAmount   = rtnEmployee.HASINum * socialBase.CorpHeatAmountPoint / 100 + socialBase.HeatAmountFix;
                decimal corpHouseFund    = rtnEmployee.HFSINum * socialBase.CorpHouseFundPoint / 100 + socialBase.HouseFundFix;
                decimal corpRepInjuryIns = rtnEmployee.RISINum * socialBase.CorpRepInjuryInsPoint / 100 + socialBase.RepInjuryInsFix;
                decimal corpTotal        = corpPensionIns + corpMedicalIns + corpUnempIns + corpInjuryIns + corpBirthIns + corpDisabledIns + corpIllnessIns + corpHeatAmount + corpHouseFund + corpRepInjuryIns;

                decimal empPensionIns   = rtnEmployee.RISINum * socialBase.EmpPensionInsPoint / 100 + socialBase.PensionInsFix;
                decimal empMedicalIns   = rtnEmployee.MISINum * socialBase.EmpMedicalInsPoint / 100 + socialBase.MedicalInsFix;
                decimal empUnempIns     = rtnEmployee.UISINum * socialBase.EmpUnempInsPoint / 100 + socialBase.UnempInsFix;
                decimal empInjuryIns    = rtnEmployee.IISINum * socialBase.EmpInjuryInsPoint / 100 + socialBase.InjuryInsFix;
                decimal empBirthIns     = rtnEmployee.BISINum * socialBase.EmpBirthInsPoint / 100 + socialBase.BirthInsFix;
                decimal empDisabledIns  = rtnEmployee.DISINum * socialBase.EmpDisabledInsPoint / 100 + socialBase.DisabledInsFix;
                decimal empIllnessIns   = rtnEmployee.LISINum * socialBase.EmpIllnessInsPoint / 100 + socialBase.IllnessInsFix;
                decimal empHeatAmount   = rtnEmployee.HASINum * socialBase.EmpHeatAmountPoint / 100 + socialBase.HeatAmountFix;
                decimal empHouseFund    = rtnEmployee.HFSINum * socialBase.EmpHouseFundPoint / 100 + socialBase.HouseFundFix;
                decimal empRepInjuryIns = rtnEmployee.RISINum * socialBase.EmpRepInjuryInsPoint / 100 + socialBase.RepInjuryInsFix;
                decimal empTotal        = empPensionIns + empMedicalIns + empUnempIns + empInjuryIns + empBirthIns + empDisabledIns + empIllnessIns + empHeatAmount + empHouseFund + empRepInjuryIns;

                EmployeeSalary empSalary = new EmployeeSalary();
                empSalary.EmpId            = rtnEmployee.EmpId;
                empSalary.PayCity          = rtnEmployee.PayCity;
                empSalary.CorpId           = rtnEmployee.CorpId;
                empSalary.SupId            = rtnEmployee.SupId;
                empSalary.CorpPensionIns   = corpPensionIns;
                empSalary.CorpMedicalIns   = corpMedicalIns;
                empSalary.CorpUnempIns     = corpUnempIns;
                empSalary.CorpInjuryIns    = corpInjuryIns;
                empSalary.CorpBirthIns     = corpBirthIns;
                empSalary.CorpDisabledIns  = corpDisabledIns;
                empSalary.CorpIllnessIns   = corpIllnessIns;
                empSalary.CorpHeatAmount   = corpHeatAmount;
                empSalary.CorpHouseFund    = corpHouseFund;
                empSalary.CorpRepInjuryIns = corpRepInjuryIns;
                empSalary.CorpTotal        = corpTotal;

                empSalary.EmpPensionIns   = empPensionIns;
                empSalary.EmpMedicalIns   = empMedicalIns;
                empSalary.EmpUnempIns     = empUnempIns;
                empSalary.EmpInjuryIns    = empInjuryIns;
                empSalary.EmpBirthIns     = empBirthIns;
                empSalary.EmpDisabledIns  = empDisabledIns;
                empSalary.EmpIllnessIns   = empIllnessIns;
                empSalary.EmpHeatAmount   = empHeatAmount;
                empSalary.EmpHouseFund    = empHouseFund;
                empSalary.EmpRepInjuryIns = empRepInjuryIns;
                empSalary.EmpTotal        = empTotal;

                empSalary.TotalAmount  = totalAmount;
                empSalary.RepairAmount = 0;                      //补充社保
                decimal grossAmount = totalAmount - empTotal;
                empSalary.GrossAmount = grossAmount;             //税前
                decimal personalTax = Calculator.PersonalTax(grossAmount);
                empSalary.PersonalTax = personalTax;             //个调税
                decimal finalAmount = grossAmount - personalTax;
                empSalary.FinalAmount   = finalAmount;           //实发
                empSalary.ServiceAmount = rtnCorp.ServiceAmount; //服务费
                empSalary.RefundAmount  = 0;                     //补收/退款

                empSalary.PayDate         = payDate;
                empSalary.EmpSalaryStatus = (int)StatusEnum.已完成;
                result = empSalaryBLL.Insert(empSalary);

                if (result.ResultStatus != 0)
                {
                    return(Json(result));
                }
            }

            //result.Message = "员工薪资发放成功";
            //result.ReturnValue = "";
            //result.ResultStatus = 0;
            return(RedirectToAction("EmployeeSalaryList"));
        }