You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
848 lines
33 KiB
848 lines
33 KiB
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using NFine.Application.SRM;
|
|
|
|
namespace NFine.Web.Areas.SRM.Controllers
|
|
{
|
|
public class DXCreateItemLotController : ControllerBase
|
|
{
|
|
DXCreateItemLotApp App = new DXCreateItemLotApp();
|
|
// GET: SRM/DXCreateItemLot
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetGridJson(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = App.GetGridJson(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetGridJsonWeiWai(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = App.GetGridJsonWeiWai(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJson(string POCode, string PORow, string WorkPoint, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetSubGridJson(POCode, PORow, WorkPoint, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
|
|
public ActionResult Form2()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult Form3()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
public ActionResult Form4()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
//[HttpGet]
|
|
//[HandlerAjaxOnly]
|
|
//public ActionResult GetFormJson(string keyValue)
|
|
//{
|
|
// //var data = maintainAppApp.GetForm(keyValue);
|
|
// //return Content(data.ToJson());
|
|
//}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult SubmitForm(string POCode, string PORow, string keyValue, string WorkPoint, string IsEable)
|
|
{
|
|
int i = App.CreateItemLotNo(POCode, PORow, keyValue, WorkPoint, IsEable);
|
|
if (i > 0)
|
|
{
|
|
return Success("生成成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("生成失败!");
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult SubmitFormWeiWai(string OOCode, string Sequence, string keyValue, string WorkPoint, string IsEable)
|
|
{
|
|
int i = App.SubmitFormWeiWai(OOCode, Sequence, keyValue, WorkPoint, IsEable);
|
|
if (i > 0)
|
|
{
|
|
return Success("生成成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("生成失败!");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击生成条码查询
|
|
/// </summary>
|
|
/// <param name="POCode">采购订单</param>
|
|
/// <param name="PORow">采购行</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonByCreate(string POCode, string PORow, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonByCreate(POCode, PORow, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
/// <summary>
|
|
/// 点击生成条码查询
|
|
/// </summary>
|
|
/// <param name="POCode">采购订单</param>
|
|
/// <param name="PORow">采购行</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonByCreateBYMore(string POCode, string PORow, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonByCreateBYMore(POCode, PORow, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击生成条码查询
|
|
/// </summary>
|
|
/// <param name="POCode">采购订单</param>
|
|
/// <param name="PORow">采购行</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonByCreateWeiWai(string OOCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonByCreateWeiWai(OOCode, Sequence, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonByCreateWeiWaiByMore(string OOCode, string Sequence, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonByCreateWeiWaiByMore(OOCode, Sequence, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetVendorLotNo(string InvCode, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetVendorLotNo(InvCode, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
VendorLotNo = ListData.Rows[0][0].ToString(),
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteItemLot(string keyValue, string WorkPoint)
|
|
{
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string msg = App.DeleteItemLot(keyValue, WorkPoint);
|
|
if (string.IsNullOrWhiteSpace(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 打印数据参数:服务器的URL+打印的文件名,转化为Base64编码
|
|
/// </summary>
|
|
protected string strPrintData;
|
|
/// <summary>
|
|
/// 标识是否安装了控件
|
|
/// </summary>
|
|
protected bool bIsInstallPrintControl = true;
|
|
/// <summary>
|
|
/// 打印控件的Cookie值
|
|
/// </summary>
|
|
protected string strPrintControlCookie = "";
|
|
|
|
|
|
/// <summary>
|
|
/// 获取Url中去掉文件名的路径
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetUrlPath()
|
|
{
|
|
string strUrl = Request.Url.ToString();
|
|
int iEnd = strUrl.LastIndexOf("/");
|
|
strUrl = strUrl.Substring(0, iEnd + 1);
|
|
|
|
return strUrl;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置控件调用的Cookie值,判断是否安装了打印控件
|
|
/// </summary>
|
|
/// <param name="pJson"></param>
|
|
private void SetCookieAndURL(PrintJson pJson)
|
|
{
|
|
bIsInstallPrintControl = false;
|
|
strPrintControlCookie = "";
|
|
HttpCookie pCookieInstall = Request.Cookies["InstallPrintControl"];
|
|
if (pCookieInstall != null)
|
|
{ //Cookie存在
|
|
strPrintControlCookie = pCookieInstall.Value.ToString();
|
|
|
|
//以Cookie值查找在数据表中是否存在
|
|
string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strPrintControlCookie) };
|
|
using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
|
|
{
|
|
if (drCookie.Read())
|
|
{ //标识为已经安装
|
|
bIsInstallPrintControl = true;
|
|
}
|
|
drCookie.Close();
|
|
}
|
|
//更新Cookie的保存时间
|
|
pCookieInstall.Expires = DateTime.Now.AddYears(10);
|
|
Response.SetCookie(pCookieInstall);
|
|
}
|
|
else
|
|
{//Cookie不存在,则新建Cookie
|
|
strPrintControlCookie = System.Guid.NewGuid().ToString();
|
|
pCookieInstall = new HttpCookie("InstallPrintControl", strPrintControlCookie);
|
|
pCookieInstall.Expires = DateTime.Now.AddYears(10);
|
|
Response.Cookies.Add(pCookieInstall);
|
|
}
|
|
|
|
string strUrl = Server.MapPath("/PrintTemp/") + "IsCheckInstall";
|
|
|
|
pJson.SetCookieAndURL(strPrintControlCookie, strUrl);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 生成条码打印
|
|
/// </summary>
|
|
/// <param name="keyValue">ID</param>
|
|
/// <param name="WorkPoint">多站点</param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult PrintItemLot(string keyValue, string WorkPoint, string Type)
|
|
{
|
|
string strPrintTempFile = "";
|
|
// string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string strPrintFileName = "";
|
|
if (Type == "3" || Type == "4")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "lot1.fr3";
|
|
}
|
|
else
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "lot.fr3";
|
|
}
|
|
|
|
PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
|
|
pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
|
|
//pJson.CheckRegister("注册姓名", "8ECCCD6A1302DFEE1A6456A5D"); //注册信息
|
|
//pJson.AddPrintParam("ShopName", "测试酒楼");
|
|
//pJson.AddPrintParam("PrintDepositAdd", "说明:本单据为贵客押金收取凭证,盖章有效。退房时请出示,遗失者自负,请妥善保存。退房时间为12:00时,延时退房18:00时以前按半天房费收取,18:00时以后算全天房价。押金单有效期为一个月,过期作废。 贵重物品请交前台寄存,未寄存丢失自负。 谢谢!");
|
|
SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
|
|
string strSql = "";
|
|
if (Type == "1")
|
|
{
|
|
|
|
strSql = @"SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
|
|
c.InvStd,
|
|
c.ClassName,c.InvDesc,
|
|
b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
|
|
a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
|
|
,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
|
|
,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
|
|
,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4
|
|
FROM dbo.ICSInventoryLot a
|
|
left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSPurchaseOrder b ON b.POCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
|
|
left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint AND d.BatchEnable=1
|
|
left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
|
|
left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
|
|
LEFT JOIN icsasndetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
|
|
where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
|
|
}
|
|
if (Type == "2")
|
|
{
|
|
|
|
strSql = @"SELECT distinct b.ExtensionID,a.InvCode,a.LotNo AS QRLotNo,b.OOCode as POCode,CONVERT(varchar(100),b.CreateDateTime, 23) PODate,g.BatchCode,a.Quantity,c.InvName,
|
|
c.InvStd,
|
|
c.ClassName,c.InvDesc,
|
|
b.VenCode,h.VenName,c.InvUnit,f.WarehouseName,
|
|
a.LotNO AS QRLotNo,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,CONVERT(varchar(100), b.PlanArriveDate, 23) as PreArriveDate
|
|
,CAST(b.VenCode+'_'+a.InvCode+'_'+CAST(a.Quantity AS NVARCHAR(20))+'_'+c.InvUnit+g.BatchCode+'_'+CONVERT(varchar(100), a.ProductDate, 23)+'_' +a.LotNo AS NVARCHAR(100)) AS erweima
|
|
,a.EATTRIBUTE3,CONVERT(varchar(100),dateadd(day,c.EffectiveDays,a.ProductDate), 23) AS exprdate,i.OASNCode as asnCode,b.EATTRIBUTE3 as DXEATTRIBUTE3
|
|
,a.EATTRIBUTE4 as DXEATTRIBUTE4,b.EATTRIBUTE4 as PODXEATTRIBUTE4
|
|
FROM dbo.ICSInventoryLot a
|
|
left join ICSExtension g on a.ExtensionID=g.ID and a.WorkPoint=g.WorkPoint
|
|
left join ICSInventoryLotDetail e on a.lotNo=e.LotNo and a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSOutsourcingOrder b ON b.OOCode=e.TransCode AND b.Sequence=e.TransSequence AND a.WorkPoint=e.WorkPoint
|
|
LEFT JOIN dbo.ICSInventory c ON a.InvCode=c.InvCode AND a.WorkPoint=c.WorkPoint
|
|
left join dbo.ICSInventoryBatchEnable d on c.InvCode=d.InvCode and c.WorkPoint=d.WorkPoint
|
|
left join ICSWarehouse f on d.WHCode=f.WarehouseCode and d.WorkPoint=f.WorkPoint
|
|
left join ICSVendor h on b.VenCode=h.VenCode and b.WorkPoint=h.WorkPoint
|
|
LEFT JOIN ICSOASNDetail i ON a.lotNO=i.LotNO AND a.workPoint=i.workPoint
|
|
where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
|
|
}
|
|
if (Type == "3")
|
|
{
|
|
|
|
strSql = @"SELECT a.InvCode,b.InvName,LotNo AS QRLotNo,b.InvStd,a.TransCode,a.EATTRIBUTE10 AS EATTRIBUTE3,CONVERT(DECIMAL(16,2), a.Quantity) AS Quantity,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,c.VenCode
|
|
FROM ICSFinishedProductShipment a
|
|
LEFT JOIN ICSInventory b ON a.InvCode=b.InvCode AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN ICSPurchaseOrder c ON a.TransCode=c.PoCode AND a.TransSequence=c.Sequence AND a.WorkPoint=c.WorkPoint
|
|
where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
|
|
}
|
|
if (Type == "4")
|
|
{
|
|
strSql = @" SELECT a.InvCode,b.InvName,LotNo AS QRLotNo,b.InvStd,a.TransCode,a.EATTRIBUTE10 AS EATTRIBUTE3,CONVERT(DECIMAL(16,2), a.Quantity) AS Quantity,CONVERT(varchar(100), a.ProductDate, 23) as PRODUCTDATE,c.VenCode
|
|
FROM ICSFinishedProductShipment a
|
|
LEFT JOIN ICSInventory b ON a.InvCode = b.InvCode AND a.WorkPoint = b.WorkPoint
|
|
LEFT JOIN ICSOutsourcingOrder c ON a.TransCode = c.OOCode AND a.TransSequence = c.Sequence AND a.WorkPoint = c.WorkPoint
|
|
where a.ID IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint in ('" + WorkPoint.Trim(',') + "')";
|
|
|
|
}
|
|
//string strSql = @"Select * From CashLog";
|
|
DataTable dtCashLog = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
if (Type == "3" || Type == "4")
|
|
{
|
|
DataTable jieguo = new DataTable();
|
|
int dtCashLogCount = dtCashLog.Columns.Count * 2;
|
|
|
|
for (int s = 1; s < 3; s++)
|
|
{
|
|
int Count = 0;
|
|
foreach (DataColumn column in dtCashLog.Columns)
|
|
{
|
|
if (Count == dtCashLog.Columns.Count)
|
|
{
|
|
break;
|
|
}
|
|
jieguo.Columns.Add(column.ColumnName + s);
|
|
Count++;
|
|
}
|
|
}
|
|
//int dtCashLogCount = dtCashLog.Columns.Count * 2;
|
|
|
|
//for (int s = 1; s < 3; s++)
|
|
//{
|
|
// int Count = 0;
|
|
// foreach (DataColumn column in dtCashLog.Columns)
|
|
// {
|
|
// if (Count == dtCashLog.Columns.Count)
|
|
// {
|
|
// break;
|
|
// }
|
|
// Console.WriteLine(column.ColumnName);
|
|
// jieguo.Columns.Add(column.ColumnName + s);
|
|
// Count++;
|
|
// }
|
|
//}
|
|
|
|
//// 遍历DataTable的每一行
|
|
//for (int i = 0; i < dtCashLog.Rows.Count; i++)
|
|
//{
|
|
// var param = dtCashLog.Rows[i].ItemArray.ToList();
|
|
// i++;
|
|
// if (i < dtCashLog.Rows.Count)
|
|
// {
|
|
// param.AddRange(dtCashLog.Rows[i].ItemArray.ToList());
|
|
// }
|
|
// jieguo.Rows.Add(param.ToArray());
|
|
//}
|
|
|
|
string[] array2D = new string[dtCashLog.Rows[0].ItemArray.ToList().Count]; // 假设这是一个3x3的二维数组
|
|
int rows = array2D.GetLength(0); // 获取行数
|
|
|
|
// 添加新行,所有元素设置为"N/A"
|
|
for (int i = 0; i < rows; i++)
|
|
{
|
|
array2D[i] = " ";
|
|
}
|
|
// 遍历DataTable的每一行
|
|
for (int i = 0; i < dtCashLog.Rows.Count; i++)
|
|
{
|
|
var param = dtCashLog.Rows[i].ItemArray.ToList();
|
|
i++;
|
|
if (i < dtCashLog.Rows.Count)
|
|
{
|
|
param.AddRange(dtCashLog.Rows[i].ItemArray.ToList());
|
|
}
|
|
else
|
|
{
|
|
param.AddRange(array2D);
|
|
}
|
|
jieguo.Rows.Add(param.ToArray());
|
|
}
|
|
strPrintTempFile = pJson.ShowReport(jieguo);
|
|
|
|
}
|
|
else
|
|
{
|
|
strPrintTempFile = pJson.ShowReport(dtCashLog); //产生JSON文件内容
|
|
}
|
|
|
|
|
|
//string strPrintTempFile = pJson.ExportReportPdf(dtCashLog, null, null, null, null, null, "D:/基础版/NFine.Framework/NFine.Web/File/PDF"); //导出PDF文件
|
|
|
|
//把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
|
|
string strServerURL = GetUrlPath() + "PrintTemp/";
|
|
string strData = strServerURL + strPrintTempFile;
|
|
strPrintData = PrintFunction.EnBase64(strData);
|
|
var JsonData = new
|
|
{
|
|
strPrintData_1 = strPrintData,
|
|
bIsInstallPrintControl_1 = bIsInstallPrintControl,
|
|
strPrintControlCookie_1 = strPrintControlCookie
|
|
};
|
|
|
|
|
|
//多站点
|
|
string sql = @"UPDATE dbo.ICSInventoryLot
|
|
SET PrintTimes=ISNULL(PrintTimes,0)+1,
|
|
LastPrintUser='',
|
|
LastPrintTime=GETDATE()
|
|
WHERE ID IN (" + keyValue.TrimEnd(',') + ") and WorkPoint in ('" + WorkPoint.TrimEnd(',') + "')";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 写日志(用于跟踪)
|
|
/// </summary>
|
|
private void WriteLog(string strMessage)
|
|
{
|
|
string strLogFile = Server.MapPath("./Cookie_Log.txt");
|
|
StreamWriter swLogFile = null;
|
|
try
|
|
{
|
|
if (!System.IO.File.Exists(strLogFile))
|
|
{
|
|
swLogFile = System.IO.File.CreateText(strLogFile);
|
|
}
|
|
else
|
|
{
|
|
swLogFile = System.IO.File.AppendText(strLogFile);
|
|
}
|
|
swLogFile.WriteLine(strMessage);
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
if (swLogFile != null)
|
|
swLogFile.Close();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
///判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
/// </summary>
|
|
/// <param name="strCookie"></param>
|
|
private void UpdateCheckInstall(string strCookie)
|
|
{
|
|
bool bIsExist = false;
|
|
//判断记录是否存在
|
|
GetLastAccessTime(strCookie, ref bIsExist);
|
|
|
|
string strSql = "";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
|
|
if (bIsExist)
|
|
{ //存在则更新最后访问的时间
|
|
strSql = @"Update sys_SRM_CheckInstall
|
|
Set LastAccessTime = getDate()
|
|
Where Cookie = @Cookie";
|
|
}
|
|
else
|
|
{ //不存在则新建一条记录
|
|
strSql = @"Insert into sys_SRM_CheckInstall(Cookie, LastAccessTime)
|
|
Values( @Cookie, getDate() )";
|
|
}
|
|
DbHelper.ExecuteNonQuery(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie);
|
|
}
|
|
|
|
public DateTime ToDateTime(object SrcValue)
|
|
{
|
|
if (Convert.IsDBNull(SrcValue) == true)
|
|
return DateTime.MinValue;
|
|
else
|
|
{
|
|
try
|
|
{
|
|
return Convert.ToDateTime(SrcValue);
|
|
}
|
|
catch
|
|
{
|
|
return DateTime.MinValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取此Cookie的最后访问时间
|
|
/// </summary>
|
|
/// <param name="strCookie"></param>
|
|
/// <returns></returns>
|
|
private DateTime GetLastAccessTime(string strCookie, ref bool bIsExist)
|
|
{
|
|
DateTime dtLastAccessTime = DateTime.MinValue;
|
|
bIsExist = false;
|
|
|
|
string strSql = @"Select * From sys_SRM_CheckInstall Where Cookie = @Cookie";
|
|
SqlParameter[] pmcCookie = { new SqlParameter("Cookie", strCookie) };
|
|
using (SqlDataReader drCookie = DbHelper.ExecuteReader(DbHelper.ConnectionString, CommandType.Text, strSql, pmcCookie))
|
|
{
|
|
if (drCookie.Read())
|
|
{
|
|
dtLastAccessTime = ToDateTime(drCookie["LastAccessTime"]);
|
|
bIsExist = true;
|
|
}
|
|
drCookie.Close();
|
|
}
|
|
|
|
return dtLastAccessTime;
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult IsCheckInstall(string checkInstall)
|
|
{
|
|
string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
|
|
if (Request.QueryString["cookie"] != null)
|
|
{ //有控件上传的Cookie值
|
|
string strCookie = Request.QueryString["cookie"].ToString();
|
|
|
|
//判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
UpdateCheckInstall(strCookie);
|
|
|
|
strValue = strValue + "上传的cookie:" + strCookie;
|
|
}
|
|
else if (checkInstall != null)
|
|
{//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
|
|
string strCookie = checkInstall;
|
|
//读取最后访问的时间
|
|
string strResult = "PrintControlInstall";
|
|
bool bIsExist = false;
|
|
DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
|
|
if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
|
|
{
|
|
strResult = "NOT";
|
|
}
|
|
Response.Clear();
|
|
Response.Write(strResult);
|
|
|
|
strValue = strValue + "检测安装的值:" + strCookie;
|
|
}
|
|
|
|
WriteLog(strValue);
|
|
return null;
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult IsCheckInstall()
|
|
{
|
|
string strValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss 访问,");
|
|
if (Request.QueryString["cookie"] != null)
|
|
{ //有控件上传的Cookie值
|
|
string strCookie = Request.QueryString["cookie"].ToString();
|
|
|
|
//判断数据表中是否存在,若不存在则新建一条记录,若存在则更新最后访问的时间
|
|
UpdateCheckInstall(strCookie);
|
|
|
|
strValue = strValue + "上传的cookie:" + strCookie;
|
|
}
|
|
else if (Request.QueryString["checkInstall"] != null)
|
|
{//Ajax检查控件是否安装了,防止那种客户把打印控件卸装了,打印时无法检测到的情况
|
|
string strCookie = Request.QueryString["checkInstall"];
|
|
//读取最后访问的时间
|
|
string strResult = "PrintControlInstall";
|
|
bool bIsExist = false;
|
|
DateTime dtLastAccessTime = GetLastAccessTime(strCookie, ref bIsExist);
|
|
if (!bIsExist || dtLastAccessTime.AddSeconds(30) < DateTime.Now)
|
|
{
|
|
strResult = "NOT";
|
|
}
|
|
Response.Clear();
|
|
Response.Write(strResult);
|
|
|
|
strValue = strValue + "检测安装的值:" + strCookie;
|
|
}
|
|
|
|
WriteLog(strValue);
|
|
return null;
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult SelectICSExtensionEnable(string BeginTime, string EndTime)
|
|
{
|
|
var data = App.SelectICSExtensionEnable(BeginTime, EndTime);
|
|
return Content(data.ToJson());
|
|
}
|
|
[HttpGet]
|
|
public ActionResult SelectICSInventoryEnable(string BeginTime)
|
|
{
|
|
var data = App.SelectICSInventoryEnable(BeginTime);
|
|
return Content(data.ToJson());
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult SelectICSColumnEnableForLotEnable(string WorkPoint)
|
|
{
|
|
var data = App.SelectICSColumnEnableForLotEnable(WorkPoint);
|
|
return Content(data.ToJson());
|
|
}
|
|
public ActionResult GetQiSetNum(string keyValue)
|
|
{
|
|
var rows = App.GetQiSetNum(keyValue);
|
|
|
|
return Content(rows.ToJson());
|
|
}
|
|
/// <summary>
|
|
/// 查询是否启用序列号
|
|
/// </summary>
|
|
/// <param name="InvCode"></param>
|
|
/// <param name="WorkPoint"></param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetInventoryIsEnable(string InvCode, string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetInventoryIsEnable(InvCode, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
EATTERIBUTE10 = ListData.Rows[0][0].ToString(),
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
public ActionResult GetInvBatchEnable(string InvCode)
|
|
{
|
|
var data = App.GetInvBatchEnable(InvCode);
|
|
return Content(data.ToJson());
|
|
}
|
|
public ActionResult GetWWComplete(string BeginTime, string EndTime)
|
|
{
|
|
var data = App.GetWWComplete(BeginTime, EndTime);
|
|
return Content(data.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetLoadShowForColumn(string WorkPoint)
|
|
{
|
|
DataTable ListData = App.GetLoadShowForColumn(WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetVendorBatchBYInvCodeZZ(string InvCode, string WorkPoint)
|
|
{
|
|
ActionResult result;
|
|
try
|
|
{
|
|
DataTable vendorBatchBYInvCodeZZ = this.App.GetVendorBatchBYInvCodeZZ(InvCode, WorkPoint);
|
|
var obj = new
|
|
{
|
|
VendorLotNo = vendorBatchBYInvCodeZZ.Rows[0][0].ToString()
|
|
};
|
|
result = base.Content(obj.ToJson());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result = this.Error(ex.Message);
|
|
}
|
|
return result;
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetGridJsonNOGK(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = App.GetGridJsonNOGK(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonNOGK(string POCode, string PORow, string WorkPoint, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonNOGK(POCode, PORow, WorkPoint, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult SubmitFormNOGK(string POCode, string PORow, string keyValue, string WorkPoint, string IsEable)
|
|
{
|
|
int i = App.SubmitFormNOGK(POCode, PORow, keyValue, WorkPoint, IsEable);
|
|
if (i > 0)
|
|
{
|
|
return Success("生成成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("生成失败!");
|
|
}
|
|
}
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteItemLotNOGK(string keyValue, string WorkPoint)
|
|
{
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
|
|
string msg = App.DeleteItemLotNOGK(keyValue, WorkPoint);
|
|
if (string.IsNullOrWhiteSpace(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetGridJsonWeiWaiNOGK(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = App.GetGridJsonWeiWaiNOGK(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJsonWeiWaiNOGK(string POCode, string PORow, string WorkPoint, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetSubGridJsonWeiWaiNOGK(POCode, PORow, WorkPoint, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult SubmitFormWeiWaiNOGK(string OOCode, string Sequence, string keyValue, string WorkPoint, string IsEable)
|
|
{
|
|
int i = App.SubmitFormWeiWaiNOGK(OOCode, Sequence, keyValue, WorkPoint, IsEable);
|
|
if (i > 0)
|
|
{
|
|
return Success("生成成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("生成失败!");
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|