using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Estsh.Web.Util;
using System.Collections;
using Estsh.Web.Service;
using System.Data;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
/***************************************************************************************************
*
* 作者:王勇
*
* *************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public partial class OrderListController : Controller
{
private OrderListService service = new OrderListService();
public ActionResult Index()
{
return View();
}
public ActionResult getStockOrderListByPage(Pager pager, string direction, String sort, string type, string cbFactory, string cbVendor, string VendorNo, string Part, string StartDeliverTime, string EndDeliverTime)
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
string str = " 1=1";
if (!(string.IsNullOrEmpty(type)) && type != "null")
{
str += " and a.STAFLG in (" + type + ") ";
}
if (!(string.IsNullOrEmpty(cbFactory)) && cbFactory != "null")
{
str += " and a.werks='" + cbFactory + "' ";
}
if (!(string.IsNullOrEmpty(cbVendor)) && cbVendor != "null")
{
str += " and a.LIFNR='" + cbVendor + "' ";
}
if (!(string.IsNullOrEmpty(VendorNo)) && VendorNo != "null")
{
str += " and a.LIFNR='" + VendorNo + "' ";
}
if (!(string.IsNullOrEmpty(Part)) && Part != "null")
{
str += " and b.part_no LIKE '%" + Part + "%' ";
}
if (!(string.IsNullOrEmpty(StartDeliverTime) && string.IsNullOrEmpty(EndDeliverTime)) && StartDeliverTime != "null" && EndDeliverTime != "null")
{
str += " and (SELECT [dbo].[sap2wms_ymd](zdate))+' '+(SELECT [dbo].[sap2wms_hms](zcjsj)) BETWEEN '" + StartDeliverTime + "' and '" + EndDeliverTime + "' ";
}
Hashtable dataHt = this.service.getStockOrderListByPage(pager, direction, str);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
return Json(result);
}
public ActionResult getStockOrderDetailByPage(Pager pager, String direction, String sort, string EBELN, string TIME)
{
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
string str = " 1=1 ";
if (string.IsNullOrEmpty(EBELN) && string.IsNullOrEmpty(TIME))
{
EBELN = "-1";
TIME = " ";
}
str += " AND a.ebeln='" + EBELN + "' ";
str += " AND (SELECT [dbo].[sap2wms_ymd](zdate))+' '+(SELECT [dbo].[sap2wms_hms](zcjsj))='" + TIME + "' ";
Hashtable dataHt = this.service.getStockOrderDetailByPage(pager, direction, str);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
return Json(result);
}
///
/// 获取工厂
///
///
public ActionResult GetFactory()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetFactory();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 获取供应商
///
///
public ActionResult GetVendor()
{
Hashtable result = new Hashtable();
ArrayList list = this.service.GetVendor();
result.Add("list", list);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 订单确认
///
///
public ActionResult dingDanQueRen(string EBELN)
{
string str = "";
EBELN = EBELN.Substring(0, EBELN.Length - 1);
//string[] str = ebeln.Split(',');
Hashtable result = new Hashtable();
bool bool_1 = this.service.dingDanQueRen(EBELN);
if (bool_1 == true)
{
str = "订单确认成功!";
}
else
{ str = "订单确认失败!"; }
result.Add("list", str);
return Json(result, JsonRequestBehavior.AllowGet);
}
///
/// 发运确认
///
///
public ActionResult shipQueRen(string EBELN)
{
string str = "";
EBELN = EBELN.Substring(0, EBELN.Length - 1);
//string[] str = ebeln.Split(',');
Hashtable result = new Hashtable();
bool bool_1 = this.service.shipQueRen(EBELN);
if (bool_1 == true)
{
str = "发运确认成功!";
}
else
{ str = "发运确认失败!"; }
result.Add("list", str);
return Json(result, JsonRequestBehavior.AllowGet);
}
public ActionResult deleteOrder(string EBELN)
{
bool state = false;
Hashtable result = new Hashtable();
EBELN = EBELN.Substring(0, EBELN.Length - 1);
try
{
state = this.service.deleteOrder(EBELN);
if (state ==true)
{
result.Add("message", "删除成功!");
}
else
{
result.Add("message", "删除失败!");
}
}
catch (Exception e)
{
state = false;
result.Add("message", "删除失败!");
}
return Json(result);
}
//#region
//public ActionResult printTest(string ebeln)
//{
// if (string.IsNullOrEmpty(ebeln))
// {
// return Json("请选择打印数据!");
// }
// ebeln = ebeln.Substring(0, ebeln.Length - 1);
// DataTable dt = new DataTable();
// //string[] str = order_id.Split(',');
// #region 定义变量
// #region 打印页面数值变量
// //页头数据
// string YeMa = "";//页码
// string SongHuoDanHao = "";//送货单号
// string GongYingShangBianHao = "";//供应商编号
// string SongHuoRiQi = "";//送货日期
// string GongYingShangJiFaHuoRen = "";//供应商及发货人
// string DingDanHao = "";//订单号
// string ChengYunDanWei = "";//承运单位
// string ZhuangHuoDiDan = ""; //装货地点
// string XieHuoDiDian = "";//卸货地点
// string BeiZhu = "";//备注
// string DaYingShiJian = "";//打印时间
// //明细数据
// string XuHao = "";//序号
// string LingJianHao = "";//零件号
// string LiuShuiHao = "";//流水号
// string LingJianMingCheng = "";//零件名称
// string ShuLiang = "";//数量
// string BeiZhu_2 = "";//备注
// #endregion
// #endregion
// StringBuilder SqlStringBuilder = new StringBuilder(1024);
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append("
");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// //存储条码信息
// DataTable _barcode = new DataTable();
// _barcode.Columns.Add("name_1", Type.GetType("System.String"));
// _barcode.Columns.Add("name_2", Type.GetType("System.String"));
// _barcode.Columns.Add("name_3", Type.GetType("System.String"));
// dt = this.service.updatePrintData(ebeln);
// //string sum = this.service.getShipNo("ShipNumber");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// SqlStringBuilder.Append(" ");
// //int count = this.service.UpdateCount(order_id);
// Hashtable result = new Hashtable();
// result.Add("data", SqlStringBuilder.ToString());
// return Json(result);
//}
//#endregion
//public ActionResult printTest(string ebeln)
//{
// string tmpmethod = "";
// try
// {
// tmpmethod = "try\n"
// + "{\n"
// + " xlApp = new ActiveXObject(\"Excel.Application\");\n"
// + " xlBook = xlApp.workbooks.add(\"D:/项目/武汉项目/代码库/02Source/trunk/Estsh/Estsh.Web/Template/pullsheet.xls" + "\");\n"
// + " xlSheet1 = xlBook.Worksheets(1);\n";
// tmpmethod = tmpmethod + "xlSheet1.Cells(3,9).value = \"*" + 1 + "*\";\n";//订单号
// tmpmethod = tmpmethod + "xlSheet1.Cells(4,10).value = \"*" + 2 + "*\";\n";//订单号
// tmpmethod = tmpmethod + "xlSheet1.Cells(5,10).value = \"" + 3 + " " + 4 + ":" + 5 + "\";\n";//发单时间
// tmpmethod = tmpmethod + "xlSheet1.Cells(7,4).value = \"" + 6 + "\";\n";//供应商代码
// tmpmethod = tmpmethod + "xlSheet1.Cells(8,4).value = \"" + 6 + "\";\n";//供应商名称
// tmpmethod = tmpmethod + "xlSheet1.Cells(9,4).value = \"" + 6 + "\";\n";//供应商地址
// tmpmethod = tmpmethod + "xlSheet1.Cells(10,4).value = \"" + 7 + "\";\n";//联系人
// tmpmethod = tmpmethod + "xlSheet1.Cells(11,4).value = \"" + 7 + "\";\n";//联系电话
// tmpmethod = tmpmethod + "xlSheet1.Cells(12,4).value = \"" + 8 + "\";\n";//传真
// tmpmethod = tmpmethod + "xlSheet1.Cells(7,9).value = \"" + 1 + "\";\n";//窗口日期
// tmpmethod = tmpmethod + "xlSheet1.Cells(8,9).value = \"" + 2 + "\";\n";//窗口时间
// tmpmethod = tmpmethod + "xlSheet1.Cells(9,9).value = \"" + 3 + "\";\n";//交货道口
// tmpmethod = tmpmethod + "xlSheet1.Cells(11,9).value = \"" + 4 + "\";\n";//电话
// tmpmethod = tmpmethod + "xlSheet1.Cells(12,9).value = \"" + 5 + "\";\n";//传真
// //tmpmethod = tmpmethod + "xlSheet1.Cells(50,4).value = \"该窗口时间订单序号:" + om.GettheNumOfOrerByWindowTime(od.WindowTime.ToString("yyyy-MM-dd")) + "\";\n";//订单序号
// tmpmethod = tmpmethod + "xlSheet1.Cells(4,6).value = \"√\";\n";
// tmpmethod = tmpmethod + "xlSheet1.Cells(52,11).value = \"第" + 1 + "页/共" + 2 + "页\";\n";
// tmpmethod = tmpmethod + " xlBook.Saved = true;\n";
// //if (!isPrint)
// //{
// // tmpmethod = tmpmethod + " xlSheet1.Application.Visible = true;\n }catch(error) {} finally {}"; //为了给用户自行调整格式而增
// //}
// //else
// //{
// tmpmethod = tmpmethod + " xlSheet1.printout();\n";
// //}
// tmpmethod = tmpmethod + " xlBook.Close;\n"
// + " xlApp.Close;\n"
// + " }\n"
// + " catch(error) \n"
// + " {\n"
// + " alert(\"错误发生,其名称:\" + error.name + \",信息为:\" + error.message)\n"
// + " } \n"
// + " finally \n"
// + " {\n"
// + " DistoryObject();\n"
// + " }";
// }
// catch
// {
// tmpmethod = "";
// }
// Hashtable result = new Hashtable();
// result.Add("data", tmpmethod.ToString());
// return Json(result);
//}
}
}