//获取所有工资项 public static List <SalResultItem> GetList(string calRunId, string payGroup) { List <SalResultItem> list = new List <SalResultItem>(); CalRunInfo calRun = CalRunInfo.Get(calRunId); if (calRun == null) { return(list); } OleDbConnection conn = new OleDbConnection(MyHelper.GetPsConnectionString()); using (conn) { OleDbDataReader rs = null; try { conn.Open(); using (OleDbCommand cmd = conn.CreateCommand()) { string condition = ""; if (string.IsNullOrEmpty(payGroup) == false) { condition = " AND gp_paygroup='" + payGroup + "'"; } cmd.CommandText = String.Format("SELECT A.EMPLID, A.cal_run_id,a.gp_paygroup, cal_id, A.PIN_NUM, P.PIN_NM, P.DESCR, A.CALC_RSLT_VAL FROM SYSADM.PS_GP_RSLT_ERN_DED A LEFT JOIN SYSADM.PS_GP_PIN P ON A.PIN_NUM = P.PIN_NUM WHERE A.cal_run_id = '{0}' {1} ORDER BY A.EMPLID", calRunId, condition); rs = cmd.ExecuteReader(); while (rs.Read()) { SalResultItem item = new SalResultItem(); item.年度 = calRun.年度; item.月份 = calRun.月份; item.日历组 = (string)rs["cal_run_id"]; item.日历 = (string)rs["cal_id"]; item.薪资组 = ((string)rs["gp_paygroup"]).Trim(); item.员工编号 = (string)rs["EMPLID"]; item.元素编号 = Convert.ToDecimal(rs["PIN_NUM"]); item.英文名称 = (string)rs["PIN_NM"]; item.中文名称 = (string)rs["DESCR"]; item.金额 = Convert.ToDecimal(rs["CALC_RSLT_VAL"]); list.Add(item); } } } finally { if (rs != null) { rs.Close(); } conn.Close(); } } return(list); }
public static StringBuilder SychSalaryResultItem(string calRunId, string payGroup) { StringBuilder sb = new StringBuilder(); CalRunInfo calRun = CalRunInfo.Get(calRunId); if (calRun == null) { return(sb); } if (DeleteAll(calRunId, payGroup)) { List <SalResultItem> list = SalResultItem.GetList(calRunId, payGroup); foreach (SalResultItem sri in list) { try { SalaryResultItem item = new SalaryResultItem(); item.年度 = calRun.年度; item.月份 = calRun.月份; item.日历组 = sri.日历组; item.日历 = sri.日历; item.薪资组 = sri.薪资组; item.员工编号 = sri.员工编号; item.元素编号 = sri.元素编号; item.英文名称 = sri.英文名称; item.中文名称 = sri.中文名称; item.金额 = sri.金额; item.类别 = item.GetCategory(); item.次同步时间 = DateTime.Now; item.Save(); } catch { sb.Append("同步工资明细失败:" + sri); } } } else { sb.Append("删除上次同步的数据失败"); } return(sb); }