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.
235 lines
8.0 KiB
C#
235 lines
8.0 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 EDIRelationshipDefineController : Controller
|
|
{
|
|
EDIRelationshipDefineService service = new EDIRelationshipDefineService();
|
|
//
|
|
// GET: /Menu/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 客户产线集合
|
|
/// </summary>
|
|
/// <returns>数据集</returns>
|
|
public ActionResult GetModelName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = service.GetModelName();
|
|
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 model_name, String edi_model_name, Pager pager, String direction, String sort)
|
|
{
|
|
Hashtable result = new Hashtable();
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
Hashtable dataHt = this.service.getEDIRelationshipListByPage(model_name, edi_model_name, pager, direction, sort);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
result.Add("sort", sort);
|
|
result.Add("direction", direction);
|
|
string startTime = Convert.ToDateTime(Request["txtStartTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
string endTime = Convert.ToDateTime(Request["txtEndTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
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);
|
|
}
|
|
|
|
public ActionResult getModelTypeDetail(String ruid)
|
|
{
|
|
Hashtable ht = this.service.getModelTypeDetail(ruid);
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
ViewData.Add("model_name", ht["model_name"]);
|
|
ViewData.Add("edi_model_name", ht["edi_model_name"]);
|
|
return View("~/Views/EDIRelationshipDefine/ViewEditEDIRelationship.aspx");
|
|
}
|
|
|
|
public ActionResult editEDImodel(String ruid)
|
|
{
|
|
Hashtable ht = this.service.getModelTypeDetail(ruid);
|
|
ViewData.Add("editType", "edit");
|
|
|
|
ViewData.Add("ruid", ht["ruid"]);
|
|
ViewData.Add("model_name", ht["model_name"]);
|
|
ViewData.Add("edi_model_name", ht["edi_model_name"]);
|
|
return View("~/Views/EDIRelationshipDefine/EditEDIRelationshipDefine.aspx");
|
|
}
|
|
|
|
/// <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 model_name, String edi_model_name, 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(model_name, edi_model_name, 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("配置名称");
|
|
headRow.CreateCell(2).SetCellValue("EDI配置名称");
|
|
}
|
|
|
|
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]["ruid"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["model_name"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["edi_model_name"].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;
|
|
}
|
|
}
|
|
} |