|
|
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 UnLockQueryController : Controller
|
|
|
{
|
|
|
private UnLockQueryService service = new UnLockQueryService();
|
|
|
|
|
|
//
|
|
|
// GET: /UnLockQuery/
|
|
|
public ActionResult Index()
|
|
|
{
|
|
|
return View();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取列表数据
|
|
|
/// </summary>
|
|
|
/// <param name="UnLockQueryName">菜单名称</param>
|
|
|
/// <param name="pager">分页</param>
|
|
|
/// <param name="direction">排序方式</param>
|
|
|
/// <param name="sort">排序列</param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult getUnLockQueryListByPage(String locationDate, String terminal_name, String Date, String Date2, Pager pager, String direction, String sort)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(Date))
|
|
|
{
|
|
|
return null;
|
|
|
}
|
|
|
Hashtable result = new Hashtable();
|
|
|
result.Add("pager.pageNo", pager.pageNo);
|
|
|
//int totalCount = 0;
|
|
|
DataTable dataHt = this.service.getUnLockQueryListByPage(locationDate, terminal_name, Date, Date2,ref pager, direction, sort);
|
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dataHt));
|
|
|
result.Add("pager.totalRows", pager.totalRows);
|
|
|
result.Add("sort", sort);
|
|
|
result.Add("direction", direction);
|
|
|
return Json(result);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取下拉列表数据
|
|
|
/// </summary>
|
|
|
/// <rehuoturns></returns>
|
|
|
public ActionResult GetTerminalName()
|
|
|
{
|
|
|
string a = "";
|
|
|
Hashtable result = new Hashtable();
|
|
|
ArrayList UnLockQueryList = this.service.GetTerminalName();
|
|
|
result.Add("list", UnLockQueryList);
|
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存数据
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult saveUnLockQuery()
|
|
|
{
|
|
|
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.updateUnLockQuery(htParams);
|
|
|
message = "修改成功";
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
message = "修改失败!";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
this.service.saveUnLockQuery(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 getUnLockQuery(String UnLockQuery_id)
|
|
|
{
|
|
|
ArrayList UnLockQueryInfo = this.service.getUnLockQuery(UnLockQuery_id);
|
|
|
Hashtable htUnLockQueryInfo = (Hashtable)UnLockQueryInfo[0];
|
|
|
ViewData.Add("part_id", htUnLockQueryInfo["part_id"]);
|
|
|
ViewData.Add("cust_order", htUnLockQueryInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htUnLockQueryInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/UnLockQueryManage/viewUnLockQuery.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 编辑
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult editUnLockQuery(String part_id)
|
|
|
{
|
|
|
ArrayList UnLockQueryInfo = this.service.getUnLockQuery(part_id);
|
|
|
Hashtable htUnLockQueryInfo = (Hashtable)UnLockQueryInfo[0];
|
|
|
ViewData.Add("editType", "edit");
|
|
|
ViewData.Add("part_id", part_id);
|
|
|
ViewData.Add("cust_order", htUnLockQueryInfo["cust_order"]);
|
|
|
ViewData.Add("ship_unit", htUnLockQueryInfo["ship_unit"]);
|
|
|
|
|
|
return View("~/Views/UnLockQuery/EditUnLockQuery.aspx");
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public ActionResult deleteUnLockQuery(String ids)
|
|
|
{
|
|
|
int delCount = 0;
|
|
|
try
|
|
|
{
|
|
|
delCount = this.service.deleteUnLockQuery(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 ExportUnLockQuery(String locationDate, String terminal_name, String Date, String Date2, int rowCount, String direction, String sort)
|
|
|
{
|
|
|
Pager pager =new Pager();
|
|
|
pager.pageSize=rowCount;
|
|
|
pager.pageNo=1;
|
|
|
//int totalCount = 0;
|
|
|
DataTable data = service.getUnLockQueryListByPage(locationDate, terminal_name, Date, Date2,ref pager, direction, sort);
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
|
|
|
string AbsolutePath = Request.UrlReferrer.AbsolutePath;
|
|
|
string url = AbsolutePath.Remove(0, Request.ApplicationPath.Length);
|
|
|
GridColumnService colService = new GridColumnService();
|
|
|
Models.SysWebGridColumn[] gridItems = colService.GetColumnByUrl(url);
|
|
|
HSSFWorkbook workbook = NPOIExcelTools.DataTableToWorkbook(gridItems, data, "解锁记录明细");
|
|
|
|
|
|
//ArrayList arr = data["dataList"] as ArrayList;
|
|
|
|
|
|
//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("站点名称");
|
|
|
// headRow.CreateCell(4).SetCellValue("解锁人");
|
|
|
// headRow.CreateCell(5).SetCellValue("解锁日期");
|
|
|
// headRow.CreateCell(6).SetCellValue("解锁时间");
|
|
|
// }
|
|
|
|
|
|
// for (int i = 0; i < arr.Count; i++)
|
|
|
// {
|
|
|
// Hashtable ht = arr[i] as Hashtable;
|
|
|
// int row = i + 1;
|
|
|
// HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
// if (ht["unlock_pwd"] != null && ht["unlock_pwd"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(0).SetCellValue(ht["unlock_pwd"].ToString());
|
|
|
// if (ht["serial_number"] != null && ht["serial_number"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(1).SetCellValue(ht["serial_number"].ToString());
|
|
|
// if (ht["car_no"] != null && ht["car_no"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(2).SetCellValue(ht["car_no"].ToString());
|
|
|
// if (ht["terminal_name"] != null && ht["terminal_name"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(3).SetCellValue(ht["terminal_name"].ToString());
|
|
|
// if (ht["emp_name"] != null && ht["emp_name"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(4).SetCellValue(ht["emp_name"].ToString());
|
|
|
// if (ht["create_ymd"] != null && ht["create_ymd"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(5).SetCellValue(ht["create_ymd"].ToString());
|
|
|
// if (ht["create_hms"] != null && ht["create_hms"] != DBNull.Value)
|
|
|
// dataRow.CreateCell(6).SetCellValue(ht["create_hms"].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;
|
|
|
}
|
|
|
}
|
|
|
}
|