You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
245 lines
8.9 KiB
C#
245 lines
8.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.Web.Service;
|
|
using System.Data;
|
|
using System.Collections;
|
|
using NPOI.HSSF.UserModel;
|
|
using System.IO;
|
|
using Estsh.Web.Util;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class XTEDIReportDefineController : Controller
|
|
{
|
|
XTEDIReportDefineService service = new XTEDIReportDefineService();
|
|
//
|
|
// GET: /Menu/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 客户产线集合
|
|
/// </summary>
|
|
/// <returns>数据集</returns>
|
|
public ActionResult GetPdlineName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = service.GetPdlineName();
|
|
resault.Add("list", list);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
public ActionResult GetTerminalName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = service.GetTerminalName();
|
|
resault.Add("list", list);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="PartMasterName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult getEDIRelationshipListByPage(String txtStartTime, Pager pager, String direction, String sort)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
if (String.IsNullOrEmpty(txtStartTime))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Hashtable dataHt = this.service.getEDIRelationshipListByPage(txtStartTime, pager, direction, sort);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存菜单数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult saveModelType()
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
String message = "";
|
|
String flag = "";
|
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
String ruid = Request["ruid"].ToString();
|
|
String edi_model_name = Request["edi_model_name"].ToString();
|
|
int model_id = this.service.GetModelID(Request["model_name"].ToString());
|
|
|
|
if (model_id == 0)
|
|
{
|
|
result.Add("message", "配置名称不存在!");
|
|
result.Add("flag", "Fail");
|
|
return Json(result);
|
|
}
|
|
//传递要更新的数据库字段
|
|
Hashtable htParams = new Hashtable();
|
|
|
|
htParams.Add("@edi_model_name", edi_model_name);
|
|
htParams.Add("@model_id", model_id);
|
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@ruid", ruid);
|
|
this.service.updateModelType(htParams);
|
|
message = "修改成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "修改失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
htParams.Add("@ruid", ruid);
|
|
this.service.saveModelType(htParams);
|
|
message = "添加成功";
|
|
flag = "OK";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
message = "添加失败!";
|
|
flag = "Fail";
|
|
}
|
|
}
|
|
result.Add("message", message);
|
|
result.Add("flag", flag);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除菜单
|
|
/// </summary>
|
|
/// <param name="ids"></param>
|
|
/// <returns></returns>
|
|
public ActionResult deleteModelType(String ids)
|
|
{
|
|
int delCount = 0;
|
|
try
|
|
{
|
|
delCount = this.service.deleteModelType(ids);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
delCount = -1;
|
|
}
|
|
Hashtable result = new Hashtable();
|
|
result.Add("status", delCount);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 导出数据到Excel
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="txtOrderNo"></param>
|
|
/// <param name="sort"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="isPage"></param>
|
|
/// <returns></returns>
|
|
public ActionResult exportData(String txtStartTime, Pager pager, String sort, String direction, String isPage)
|
|
{
|
|
|
|
Boolean paging = false;
|
|
if (isPage == null || "".Equals(isPage))
|
|
{
|
|
paging = false;
|
|
}
|
|
else
|
|
{
|
|
if ("1".Equals(isPage.Trim()))
|
|
{
|
|
paging = true;
|
|
}
|
|
else
|
|
{
|
|
paging = false;
|
|
}
|
|
}
|
|
DataTable dataHt = this.service.getShippingExport(txtStartTime, pager, direction, sort);
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
Stream outputStream = Response.OutputStream;
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("EDI信息查询");
|
|
try
|
|
{
|
|
if (workbook != null)
|
|
{
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
headRow.CreateCell(0).SetCellValue("配置名称");
|
|
headRow.CreateCell(1).SetCellValue("00:00:00-02:00:00");
|
|
headRow.CreateCell(2).SetCellValue("02:00:00-04:00:00");
|
|
headRow.CreateCell(3).SetCellValue("04:00:00-06:00:00");
|
|
headRow.CreateCell(4).SetCellValue("06:00:00-08:00:00");
|
|
headRow.CreateCell(5).SetCellValue("08:00:00-10:00:00");
|
|
headRow.CreateCell(6).SetCellValue("10:00:00-12:00:00");
|
|
headRow.CreateCell(7).SetCellValue("12:00:00-14:00:00");
|
|
headRow.CreateCell(8).SetCellValue("14:00:00-16:00:00");
|
|
headRow.CreateCell(9).SetCellValue("16:00:00-18:00:00");
|
|
headRow.CreateCell(10).SetCellValue("18:00:00-20:00:00");
|
|
headRow.CreateCell(11).SetCellValue("20:00:00-22:00:00");
|
|
headRow.CreateCell(12).SetCellValue("22:00:00-24:00:00");
|
|
}
|
|
|
|
for (int i = 0; i < dataHt.Rows.Count; i++)
|
|
{
|
|
int row = i + 1;
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
dataRow.CreateCell(0).SetCellValue(dataHt.Rows[i]["model_name"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["A"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["B"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["C"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["D"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["E"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["F"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["G"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["H"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["I"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["J"].ToString());
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["K"].ToString());
|
|
dataRow.CreateCell(12).SetCellValue(dataHt.Rows[i]["L"].ToString());
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=EDI信息查询.xls");
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
workbook = null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |