public ActionResult Calculate(string area, string company, string message) { area = HttpUtility.UrlDecode(area); company = HttpUtility.UrlDecode(company); message = HttpUtility.UrlDecode(message); DAL.z_parameter dal_z_parameter = new DAL.z_parameter(); List<Models.z_parameter> area_list = dal_z_parameter.GetModelList("地区"); List<Models.z_parameter> company_list = dal_z_parameter.GetModelList("分公司"); ViewBag.area_list = area_list; ViewBag.company_list = company_list; if (area == null || area == "") { area = area_list[0].ID.ToString(); } if (company == null || company == "") { company = company_list[0].ID.ToString(); } ViewBag.area = area; ViewBag.company = company; Models.z_user session_model_z_user = (Models.z_user)ViewBag.model_z_user; DAL.m_worker dal_m_worker = new DAL.m_worker(); DataTable dtReturnFee = dal_m_worker.GetReturnFee(area, new Guid(company)); ViewBag.ReportChart = dtReturnFee; ViewBag.message = message; return View(); }
public ActionResult ExportCalculate(string area, string company) { area = HttpUtility.UrlDecode(area); company = HttpUtility.UrlDecode(company); try { Models.z_user session_model_z_user = (Models.z_user)ViewBag.model_z_user; DAL.m_worker dal_m_worker = new DAL.m_worker(); DataTable dtReturnFee = dal_m_worker.GetReturnFee(area, new Guid(company)); MemoryStream ms = DAL.NpoiExcel.RenderWorkerTableToExcelFee(dtReturnFee) as MemoryStream; Response.Clear(); Response.Buffer = true; Response.AddHeader("Content-Disposition", string.Format("attachment; filename=返费导出" + DateTime.Now.ToString("yyyy_MM_dd HH_mm") + ".xls")); Response.BinaryWrite(ms.ToArray()); Response.End(); ms.Close(); ms.Dispose(); return RedirectToAction("Calculate", new { message = HttpUtility.UrlEncode("导出成功"), area = HttpUtility.UrlEncode(area) }); } catch { return RedirectToAction("Calculate", new { message = HttpUtility.UrlEncode("导出失败"), area = HttpUtility.UrlEncode(area) }); } }