|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Web;
|
|
|
using System.Web.Mvc;
|
|
|
using Estsh.Web.Util;
|
|
|
using Estsh.Web.Service;
|
|
|
using System.Collections;
|
|
|
using Estsh.Web.Models;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using System.IO;
|
|
|
using System.Data;
|
|
|
|
|
|
/***************************************************************************************************
|
|
|
*
|
|
|
* 作者:王勇
|
|
|
* 创建时间:2013.04.15
|
|
|
* 描述:客户订单维护
|
|
|
*
|
|
|
* *************************************************************************************************/
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 客户订单维护
|
|
|
/// </summary>
|
|
|
public class FGSerchController : Controller
|
|
|
{
|
|
|
private FGSerchService service = new FGSerchService();
|
|
|
|
|
|
//
|
|
|
// GET: /FGSerch/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="FGSerchName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getFGSerchListByPage(String order_no, String shift_name,String car_no,String type_id,String Date, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
Hashtable dataHt = this.service.getFGSerchListByPage(order_no, shift_name, car_no, type_id, Date, 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);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
return Json(e.Message.ToString());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectFGSerch()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList FGSerchList = this.service.getSelectFGSerch();
|
|
|
result.Add("list", FGSerchList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult getSelectFGSerch_model_name()
|
|
|
{
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList FGSerchList = this.service.getSelectFGSerch_model_name();
|
|
|
result.Add("list", FGSerchList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveFGSerch()
|
|
|
{
|
|
|
String editType = Request["editType"].ToString();
|
|
|
|
|
|
String part_id = Request["part_id"].ToString();
|
|
|
String cust_order = Request["cust_order"].ToString();
|
|
|
String ship_unit = Request["ship_unit"].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
Hashtable htParams = new Hashtable();
|
|
|
htParams.Add("@part_id", part_id);
|
|
|
htParams.Add("@cust_order", cust_order);
|
|
|
htParams.Add("@ship_unit", ship_unit);
|
|
|
|
|
|
|
|
|
String message = "";
|
|
|
if (editType != null && editType.Trim().Equals("edit"))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
|
|
|
this.service.updateFGSerch(htParams);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.service.saveFGSerch(htParams);
|
|
|
message = "添加成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "添加失败!";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("message", message);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getFGSerch(String FGSerch_id)
|
|
|
{
|
|
|
ArrayList FGSerchInfo = this.service.getFGSerch(FGSerch_id);
|
|
|
Hashtable htFGSerchInfo = (Hashtable)FGSerchInfo[0];
|
|
|
ViewData.Add("part_id", htFGSerchInfo["part_id"]);
|
|
|
ViewData.Add("cust_order", htFGSerchInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htFGSerchInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/FGSerchManage/viewFGSerch.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editFGSerch(String part_id)
|
|
|
{
|
|
|
ArrayList FGSerchInfo = this.service.getFGSerch(part_id);
|
|
|
Hashtable htFGSerchInfo = (Hashtable)FGSerchInfo[0];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("part_id", part_id);
|
|
|
ViewData.Add("cust_order", htFGSerchInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htFGSerchInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/FGSerch/EditFGSerch.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteFGSerch(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteFGSerch(ids);
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
delCount = -1;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("status", delCount);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 导出
|
|
|
/// </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 ExportFGSerch(String part_no, String cust_order, Pager pager, String sort, String direction, String isPage)
|
|
|
{
|
|
|
|
|
|
Boolean paging = false;
|
|
|
if (isPage == null || "".Equals(isPage))
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if ("1".Equals(isPage))
|
|
|
{
|
|
|
paging = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
paging = false;
|
|
|
}
|
|
|
}
|
|
|
DataTable dataHt = this.service.getTableListByPage(part_no, cust_order, pager, direction, sort, paging);
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("客户订单号明细");
|
|
|
try
|
|
|
{
|
|
|
if (workbook != null)
|
|
|
{
|
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
|
headRow.CreateCell(0).SetCellValue("总成零件号");
|
|
|
headRow.CreateCell(1).SetCellValue("零件描述");
|
|
|
headRow.CreateCell(2).SetCellValue("客户单号");
|
|
|
headRow.CreateCell(3).SetCellValue("出货单位");
|
|
|
}
|
|
|
|
|
|
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]["part_no"].ToString());
|
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["part_spec"].ToString());
|
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["cust_order"].ToString());
|
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["ship_unit"].ToString());
|
|
|
}
|
|
|
|
|
|
Response.Clear();
|
|
|
workbook.Write(outputStream);
|
|
|
|
|
|
Response.Buffer = true;
|
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=客户订单号明细.xls");
|
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
|
Response.Flush();
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
workbook = null;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
}
|