/// <summary> /// 得到所有关账日信息信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> public ActionResult GetAccountDateList() { List <AccountDateResultDTO> result = null; result = BaseInfoProvider.GetAccountDateList(); return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 导出关账日信息 /// </summary> /// <param name="dto"></param> /// <returns></returns> public ActionResult ExportAccountDate() { string result = null; List <AccountDateResultDTO> pp = null; pp = BaseInfoProvider.GetAccountDateList(); string strTemplateFile = Server.MapPath(@"~/TempLate/AccountDateTemplate.xlsx"); string strGenarateDir = Server.MapPath(@"~/TempFile"); string strGenarateFile = Guid.NewGuid().ToString("N") + ".xlsx"; string strExportFile = strGenarateDir + "\\" + strGenarateFile; List <object> ratelist = new List <object>(); pp.ForEach(g => { Models.Model.Excel.ExcelAccountDate er = new Models.Model.Excel.ExcelAccountDate(); er.关帐日名称 = g.AccountDateName; er.年份 = g.AccountDateYear; er.送货地址 = g.AccountDatePlace; er.一月 = g.MonthDate == null ? string.Empty : g.MonthDate.Value.ToString("yyyy-MM-dd"); er.二月 = g.FebDate == null ? string.Empty : g.FebDate.Value.ToString("yyyy-MM-dd"); er.月 = g.MarchDate == null ? string.Empty : g.MarchDate.Value.ToString("yyyy-MM-dd"); er.四月 = g.AprilDate == null ? string.Empty : g.AprilDate.Value.ToString("yyyy-MM-dd"); er.五月 = g.MayDate == null ? string.Empty : g.MayDate.Value.ToString("yyyy-MM-dd"); er.六月 = g.JuneDate == null ? string.Empty : g.JuneDate.Value.ToString("yyyy-MM-dd"); er.七月 = g.JulyDate == null ? string.Empty : g.JulyDate.Value.ToString("yyyy-MM-dd"); er.八月 = g.AugustDate == null ? string.Empty : g.AugustDate.Value.ToString("yyyy-MM-dd"); er.九月 = g.SepDate == null ? string.Empty : g.SepDate.Value.ToString("yyyy-MM-dd"); er.十月 = g.OctDate == null ? string.Empty : g.OctDate.Value.ToString("yyyy-MM-dd"); er.十一月 = g.NovDate == null ? string.Empty : g.NovDate.Value.ToString("yyyy-MM-dd"); er.十二月 = g.DecDate == null ? string.Empty : g.DecDate.Value.ToString("yyyy-MM-dd"); er.所属模块 = g.AccountDateBelongModel; ratelist.Add(er); }); if (Common.ExcelHelper.Export(strTemplateFile, strGenarateDir, strGenarateFile, ratelist, "Sheet1")) { result = strGenarateFile; } return(Json(result)); }