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; using Estsh.Web.Models; using Aspose.Cells; /*************************************************************************************************** * * 作者:王勇 * * *************************************************************************************************/ namespace Estsh.Core.Web.Controllers { /// /// 目视单打印模块的控制类 /// public partial class VendorOrderPrintController : Controller { private VendorOrderPrintService service = new VendorOrderPrintService(); public ActionResult Index() { return View(); } public ActionResult getStockVendorOrderPrintByPage(Pager pager, string direction, String sort, string type, string StartDeliverTime, string EndDeliverTime, string startDDH, string endDDH) { Hashtable result = new Hashtable(); result.Add("pager.pageNo", pager.pageNo); result.Add("sort", sort); UserInfo user = Session["loginedUser"] as UserInfo; int empType = user.empType; string company = user.company; string str = " 1=1"; if ((string.IsNullOrEmpty(company)) && type == "null") { return null; } str += " and a.LIFNR='" + company + "' "; //str += " AND A.STAFLG='Y'"; str += " AND a.STAFLG=2"; //if (!(string.IsNullOrEmpty(type)) && type != "null") //{ td4gbyb70 10001 // str += " and a.STAFLG in (" + type + ") "; //} //if (!(string.IsNullOrEmpty(Part)) && Part != "null") //{ // str += " and c.part_no LIKE '%" + Part + "%' "; //} //if (!(string.IsNullOrEmpty(startXTM) && string.IsNullOrEmpty(EndXTM)) && startXTM != "null" && EndXTM != "null") //{ // str += " and a.ZTXM BETWEEN '" + startXTM + "' and '" + EndXTM + "' "; //} if (!(string.IsNullOrEmpty(startDDH) && string.IsNullOrEmpty(endDDH)) && startDDH != "null" && endDDH != "null") { str += " and a.EBELN BETWEEN '" + startDDH + "' and '" + endDDH + "' "; } 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.getStockVendorOrderPrintByPage(pager, direction, str); result.Add("pager.totalRows", dataHt["totalCount"]); result.Add("rows", dataHt["dataList"]); result.Add("direction", direction); return Json(result); } public ActionResult getStockOrderDetailByPage(Pager pager, String direction, string EBELN) { 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 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("direction", direction); return Json(result); } /// /// 修改订单状态 /// /// public ActionResult changeOrderStatus(string PoNo_Data, string PartNo_Data, string TIME, string ztxm, string evrtp) { Hashtable result = new Hashtable(); bool boolResult = this.service.changeOrderStatus(PoNo_Data, PartNo_Data, TIME, ztxm, evrtp); result.Add("list", boolResult); return Json(result, JsonRequestBehavior.AllowGet); } /// /// 修改订单状态 /// /// public ActionResult changeOrderStatus(string EBELN) { Hashtable result = new Hashtable(); bool boolResult = this.service.changeOrderStatus(EBELN); result.Add("list", boolResult); return Json(result, JsonRequestBehavior.AllowGet); } /// /// 获取工厂 /// /// 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 exportBarcodeInfo(String expWeekNo) //{ // Hashtable result = new Hashtable(); // string excelTemplate = Server.MapPath("../App_Data/Template/箱条码标签模板.xlsx"); // string saveFolder = Server.MapPath("../App_Data/Temp/"); // result = this.service.exportBarcodeInfo(excelTemplate, saveFolder, expWeekNo); // return Json(result,JsonRequestBehavior.AllowGet); //} public ActionResult exportBarcodeInfo(String expWeekNo,string type ) { try { Hashtable result = new Hashtable(); string excelTemplate = Server.MapPath("../App_Data/Template/箱条码标签模板.xlsx"); string saveFolder = Server.MapPath("../App_Data/Temp/"); result = this.service.exportBarcodeInfo(excelTemplate, saveFolder, expWeekNo); //插件名称 string fileName = result["fileName"].ToString(); //文件路径 string filePath = saveFolder + result["fileName"].ToString(); FileStream fs = new FileStream(filePath, FileMode.Open); byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); Response.Charset = "UTF-8"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); Response.ContentType = "application/octet-stream"; //解决文件名乱码问题 Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(fileName)); Response.BinaryWrite(bytes); Response.Flush(); Response.End(); //修改状态 if (type == "1") { changeOrderStatus(expWeekNo); } return new EmptyResult(); } catch (Exception ex) { return null; } } //#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); //} } }