Exemplo n.º 1
0
        public HrmResultEntity <PayrollEntity> SavePayroll(PayrollEntity payroll, BasicParamType param)
        {
            var par = new DynamicParameters();

            par.Add("@Id", payroll.Id);
            par.Add("@SalaryTypeId", payroll.SalaryTypeId);
            par.Add("@Name", payroll.Name);
            par.Add("@Description", payroll.Description);
            par.Add("@MonthYear", payroll.MonthYear);
            par.Add("@Status", payroll.Status);
            par.Add("@PaymentDate", payroll.PaymentDate);
            par.Add("@BaseParam", param.ToUserDefinedDataTable(), DbType.Object);
            var result = ListProcedure <PayrollEntity>("Payroll_Update_SavePayroll", par, useCache: false);

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 审核状态
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">当前状态</param>
 /// <returns></returns>
 public void UpdateStatus(string keyValue, int status)
 {
     try
     {
         PayrollEntity entity = new PayrollEntity();
         if (status == 0)
         {
             entity.status = 1;
         }
         service.SaveForm(keyValue, entity);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemplo n.º 3
0
        public string SavePayroll(PayrollEntity payroll, BasicParamType param)
        {
            var response = this._payrollRepository.SavePayroll(payroll, param);

            return(JsonConvert.SerializeObject(response));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存表单(新增、修改)
        /// </summary>
        /// <param name="keyValue">主键值</param>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public void SaveForm(string keyValue, string inport, PayrollEntity entity)
        {
            try
            {
                string searchColumnName = "员工编号";
                string totalColumnName  = "总计";

                if (inport != "")
                {
                    // 1.导入功能
                    DataTable dt = ExcelHelper.ExcelImport(Utils.GetMapPath(inport));

                    // 2.取出所有得薪资项
                    PayitemService payservice = new PayitemService();
                    IEnumerable <PayitemEntity> payitemlist = payservice.GetList(w => w.disable == "1");

                    #region 3.取出所有的人员信息

                    List <string> employIds = new List <string>();
                    foreach (DataRow row in dt.Rows)
                    {
                        if (dt.Columns.Contains(searchColumnName))
                        {
                            employIds.Add(row[searchColumnName].ToString());
                        }
                    }

                    EmployinfoService employservice           = new EmployinfoService();
                    IEnumerable <EmployinfoEntity> employlist = employservice.GetAllList(employIds);

                    #endregion

                    #region 4.获取excel中需要遍历的薪资项

                    List <string> payitems = new List <string>();
                    foreach (PayitemEntity item in payitemlist)
                    {
                        if (dt.Columns.Contains(item.dispName))
                        {
                            payitems.Add(item.dispName);
                        }
                    }

                    #endregion

                    PayrollService payrollService = new PayrollService();
                    int            PayrollId      = payrollService.FindMaxID() + 1;

                    int     employCount = 0; // 本次导入人数
                    decimal TotalAmount = 0; // 本次应发总金额

                    #region 5.新增子表

                    List <PaydetailEntity> detailList   = new List <PaydetailEntity>();
                    PaydetailEntity        detailEntity = null;
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        PaydetailService detailService = new PaydetailService();
                        foreach (DataRow row in dt.Rows)
                        {
                            int?empid = 0;  // 员工编号

                            #region 获取员工信息
                            if (row[searchColumnName] != null && row[searchColumnName].ToString().Length != 0)
                            {
                                EmployinfoEntity employEntity = employlist.Where(w => w.empid == Convert.ToInt32(row[searchColumnName])).FirstOrDefault();
                                if (employEntity != null)
                                {
                                    empid = employEntity.empid;
                                    employCount++;
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            #endregion

                            #region 总计列不存在,或者 总计 非数字类型,不记入数据库
                            if (row[totalColumnName] == null || row[totalColumnName].ToString().Length == 0)
                            {
                                continue;
                            }
                            else
                            {
                                try
                                {
                                    TotalAmount += decimal.Round(Convert.ToDecimal(row[totalColumnName]), 2, MidpointRounding.AwayFromZero);
                                }
                                catch (Exception)
                                {
                                    continue;
                                }
                            }
                            #endregion

                            #region 遍历行中的项,一项存一条数据
                            foreach (string item in payitems)
                            {
                                detailEntity       = new PaydetailEntity();
                                detailEntity.empid = empid;

                                PayitemEntity itemEntity = payitemlist.Where(w => w.dispName == item).FirstOrDefault();
                                if (itemEntity != null)
                                {
                                    detailEntity.itemcode = itemEntity.itemcode;
                                    detailEntity.amount   = Convert.ToDecimal(row[itemEntity.dispName]);
                                }

                                detailEntity.payrollid = PayrollId;

                                detailEntity.CreatorName = Code.OperatorProvider.Provider.Current().UserName;;
                                detailEntity.CreateDate  = DateTime.Now;

                                detailList.Add(detailEntity);
                            }
                            #endregion
                        }
                    }

                    #endregion

                    #region 6.新增主表

                    // 组合主表字段
                    PayrollEntity parollEntity = new PayrollEntity();
                    parollEntity.PayrollId   = PayrollId;
                    parollEntity.period      = entity.period;
                    parollEntity.status      = 0;
                    parollEntity.employnum   = employCount;
                    parollEntity.Totalamount = decimal.Round(TotalAmount, 2, MidpointRounding.AwayFromZero);

                    parollEntity.CreatorId   = 0;
                    parollEntity.CreatorName = Code.OperatorProvider.Provider.Current().UserName;
                    parollEntity.CreateDate  = DateTime.Now;

                    #endregion

                    payrollService.SaveUploadData(parollEntity, detailList);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 5
0
 public ActionResult SaveForm(string keyValue, string inport, PayrollEntity entity)
 {
     payrollbll.SaveForm(keyValue, inport, entity);
     return(Success("操作成功。"));
 }