public string PX_PXZT_BMRY_SELECT(string datastring) { string token = AppClass.GetSession("token").ToString(); HR_PX_PXZT_BMRY model_HR_PX_PXZT_BMRY = Newtonsoft.Json.JsonConvert.DeserializeObject <HR_PX_PXZT_BMRY>(datastring); HR_PX_PXZT_BMRY_SELECT rst = hrmodels.PX_PXZT.PXZT_BMRY_SELECT(model_HR_PX_PXZT_BMRY, token); return(Newtonsoft.Json.JsonConvert.SerializeObject(rst)); }
public string EXPOST_PXZT_BMRY(int PXZTID) { MES_RETURN_UI rst = new MES_RETURN_UI(); string token = AppClass.GetSession("token").ToString(); int STAFFID = Convert.ToInt32(AppClass.GetSession("STAFFID")); try { HR_PX_PXZT_BMRY model_HR_PX_PXZT_BMRY = new HR_PX_PXZT_BMRY(); model_HR_PX_PXZT_BMRY.PXZTID = PXZTID; model_HR_PX_PXZT_BMRY.LB = 2; HR_PX_PXZT_BMRY_SELECT rst_HR_PX_PXZT_BMRY_SELECT = hrmodels.PX_PXZT.PXZT_BMRY_SELECT(model_HR_PX_PXZT_BMRY, token); if (rst_HR_PX_PXZT_BMRY_SELECT.MES_RETURN.TYPE == "S") { FileStream file = new FileStream(Server.MapPath("~") + @"/Areas/HR/ExportFile/导出模版.xlsx", FileMode.Open, FileAccess.Read); IWorkbook workbook = new XSSFWorkbook(file); ISheet sheet = workbook.GetSheetAt(0); int rowcount = 0; string tt = "工号,姓名,归属部门,状态"; string[] ttlist = tt.Split(','); IRow rowtt = sheet.CreateRow(rowcount++); int cellIndex = 0; for (int a = 0; a < ttlist.Length; a++) { rowtt.CreateCell(cellIndex++).SetCellValue(ttlist[a]); } DataTable dtlist = rst_HR_PX_PXZT_BMRY_SELECT.DATALIST; for (int i = 0; i < dtlist.Rows.Count; i++) { cellIndex = 0; IRow row = sheet.CreateRow(rowcount++); row.CreateCell(cellIndex++).SetCellValue(dtlist.Rows[i]["GH"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtlist.Rows[i]["YGNAME"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtlist.Rows[i]["GSBMNAME"].ToString()); row.CreateCell(cellIndex++).SetCellValue(dtlist.Rows[i]["ZT"].ToString()); } string now = DateTime.Now.ToString("yyyyMMddHHmmss.fff"); FileStream file1 = new FileStream(string.Format(@"{0}/Areas/HR/ExportFile/{1}.xlsx", Server.MapPath("~"), now), FileMode.Create); workbook.Write(file1); file1.Close(); rst.TYPE = "S"; rst.MESSAGE = now; } else { return(Newtonsoft.Json.JsonConvert.SerializeObject(rst_HR_PX_PXZT_BMRY_SELECT.MES_RETURN)); } } catch { rst.TYPE = "E"; rst.MESSAGE = "生成文件失败!"; } return(Newtonsoft.Json.JsonConvert.SerializeObject(rst)); }