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.
694 lines
30 KiB
694 lines
30 KiB
using NFine.Application.SRM;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
|
|
namespace NFine.Web.Areas.SRM.Controllers
|
|
{
|
|
public class POSignBacksController : ControllerBase
|
|
{
|
|
POSignBacksApp App = new POSignBacksApp();
|
|
//
|
|
// GET: /SRM/POSignBacks/
|
|
public ActionResult ICSPOSignBacks()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult POSignBackCommint()
|
|
{
|
|
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());
|
|
}
|
|
public ActionResult ChridenList(string keyValue, string WorkPoint)
|
|
{
|
|
string result = App.ChridenList(keyValue, WorkPoint);
|
|
var JsonData = new
|
|
{
|
|
result = result
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetGridJsonCommint(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = App.GetGridJsonCommint(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="ReturnRemark"></param>
|
|
/// <param name="POCode"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
//[ValidateAntiForgeryToken]
|
|
public ActionResult UpdatePOBackRemark(string ReturnRemark, string POCode)
|
|
{
|
|
int result = App.UpdatePOBackRemark(ReturnRemark, POCode);
|
|
if (result > 0)
|
|
{
|
|
return Success("操作成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error("操作失败!");
|
|
}
|
|
}
|
|
[HttpPost]
|
|
//[HandlerAjaxOnly]
|
|
//[ValidateAntiForgeryToken]
|
|
public ActionResult POBackCommit(string keyValue)
|
|
{
|
|
try
|
|
{
|
|
App.POBackCommit(keyValue);
|
|
return Success("确认成功!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Error(ex.Message);
|
|
}
|
|
//int result = App.POBackCommit(keyValue);
|
|
//if (result > 0)
|
|
//{
|
|
// return Success("操作成功!");
|
|
//}
|
|
//else
|
|
//{
|
|
// return Error("操作失败!");
|
|
//}
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult UpLoadFile()
|
|
{
|
|
//获取采购订单号
|
|
string PoCode = Request.Form["CurrentPoCode"].ToString();
|
|
string ReturnRemark = Request.Form["uploadcomment"].ToString();
|
|
string WorkPoint = Request.Form["WorkPoint"].ToString();
|
|
string VenName = Request.Form["VenName"].ToString();
|
|
//string VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
|
|
int UploadFrequency = 0;
|
|
if (!string.IsNullOrEmpty(Request.Form["uploadFrequency"].ToString()))
|
|
{
|
|
UploadFrequency = Convert.ToInt32(Request.Form["uploadFrequency"].ToString())+1;
|
|
}
|
|
else
|
|
{
|
|
UploadFrequency = UploadFrequency + 1;
|
|
}
|
|
//获取上传的文件集合
|
|
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
|
|
//string fileName = PoCode + Path.GetExtension(httpFile[0].FileName);
|
|
string FileAddres = PoCode + "_" + VenName + "_" + UploadFrequency + Path.GetExtension(httpFile[0].FileName);
|
|
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\" + PoCode);
|
|
if (!Directory.Exists(Paths))
|
|
{
|
|
Directory.CreateDirectory(Paths);
|
|
}
|
|
string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\" + PoCode + "\\" + FileAddres);
|
|
int iLen = httpFile[0].ContentLength;
|
|
byte[] bData = new byte[iLen];
|
|
httpFile[0].InputStream.Read(bData, 0, iLen);
|
|
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
|
|
fs.Write(bData, 0, bData.Length);
|
|
fs.Flush();
|
|
fs.Close();
|
|
fs.Dispose();
|
|
string msg = App.UpLoadFile(PoCode, FileAddres, filePath, ReturnRemark,WorkPoint);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("上传成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult UpLoadFileCommint()
|
|
{
|
|
//获取采购订单号
|
|
string PoCode = Request.Form["CurrentPoCode"].ToString();
|
|
string ReturnRemark = Request.Form["uploadcomment"].ToString();
|
|
string WorkPoint = Request.Form["WorkPoint"].ToString();
|
|
int UploadFrequency = Convert.ToInt32( Request.Form["uploadFrequency"].ToString())+1;
|
|
//获取上传的文件集合
|
|
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
|
|
string fileName = PoCode + "_" + UploadFrequency + Path.GetExtension(httpFile[0].FileName);
|
|
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\" + PoCode);
|
|
if (!Directory.Exists(Paths))
|
|
{
|
|
Directory.CreateDirectory(Paths);
|
|
}
|
|
string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\" + PoCode + "\\" + fileName);
|
|
int iLen = httpFile[0].ContentLength;
|
|
byte[] bData = new byte[iLen];
|
|
httpFile[0].InputStream.Read(bData, 0, iLen);
|
|
FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate);
|
|
fs.Write(bData, 0, bData.Length);
|
|
fs.Flush();
|
|
fs.Close();
|
|
fs.Dispose();
|
|
string msg = App.UpLoadFileCommint(PoCode, fileName, filePath, ReturnRemark, WorkPoint);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("上传成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult GetSubGridJson(string queryJson, Pagination pagination)
|
|
{
|
|
DataTable ListData = App.GetSubGridJson(queryJson, ref pagination);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
|
|
};
|
|
//获取当前登录人信息;
|
|
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
#region 打印
|
|
/// <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);
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult PrintItemLot(string keyValue, string WorkPoint)
|
|
{
|
|
string strPrintFileName ="";
|
|
string DBLANK = SqlHelper.GetItemsDetails("ERP001", WorkPoint);
|
|
string CusterJC = ConfigurationManager.ConnectionStrings["CusterJC"].ConnectionString;
|
|
//string U8ConnStr = ConfigurationManager.ConnectionStrings["ERPDB"].ConnectionString;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
|
|
string strSqls = string.Empty;
|
|
if (WorkPoint == "02")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd02.fr3";
|
|
}else if(WorkPoint == "03")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd03.fr3";
|
|
}
|
|
else if(WorkPoint == "01")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd.fr3";
|
|
}
|
|
else
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd.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 = @"select distinct poCode
|
|
,VenName
|
|
,b.VenAddress cVenAddress
|
|
,b.VenPerson cVenPerson
|
|
,CreatePerson as MUSER
|
|
,b.VenPayCond as iPayCreDays
|
|
-- ,e.CsSName as cVenPayCond
|
|
,VenPhone
|
|
,VenAddress
|
|
,c.F_MobilePhone
|
|
,VenBank AS VenBank
|
|
,VenAccount as VenAccount
|
|
,VenRegCode
|
|
,VenEmail
|
|
,a.EATTRIBUTE12
|
|
,a.EATTRIBUTE13
|
|
from dbo.ICSPurchaseOrder a
|
|
left join ICSVendor b on a.VenCode=b.VenCode and a.WorkPoint=b.WorkPoint
|
|
left join Sys_SRM_User c on a.CreatePerson=c.F_RealName and a.WorkPoint=c.F_Location
|
|
--left join {0}.dbo.PayCondition d on b.cVenPayCond=d.cPayCode
|
|
--left join {0}.dbo.settleStyle e on b.Free2=e.cssCode
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
strSql = string.Format(strSql, DBLANK);
|
|
//string strSql = @"Select * From CashLog";
|
|
DataTable dtCashLog = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
if (CusterJC.Contains("佑伦")|| CusterJC.Contains("思米思"))
|
|
{
|
|
strSqls = @" select * from POSignBacks where POCode IN (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "' and (isnull(Status,'')<>'关闭' and isnull(Status,'')<>'弃审')";
|
|
}
|
|
else
|
|
{
|
|
strSqls = @" SELECT a.Sequence,a.InvCode,b.INVNAME,b.INVSTD,b.InvUnit,a.Quantity,a.UnitPrice,
|
|
CONVERT(NVARCHAR(50), a.PlanArriveDate,23) as PreArriveDate,CONVERT(NVARCHAR(50),a.ArriveDate,23) as ArriveDate,
|
|
CONVERT(NVARCHAR(50), a.DeliveryDate,23) as Free5,c.ProjectCode,b.INVDESC,a.CreatePerson as MUSER,CONVERT(NVARCHAR(50), a.MTIME,23) as MTIME,c.BatchCode,a.EATTRIBUTE11 as iSum
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension c ON a.ExtensionID=c.id AND a.WorkPoint=c.WorkPoint
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "' and (isnull(a.Status,'')<>'关闭' and isnull(a.Status,'')<>'弃审')";
|
|
}
|
|
|
|
|
|
|
|
DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSqls, true, null);
|
|
strSql = @" select SUM(CONVERT(INT,isnull(a.Quantity,0))) as SumQuantity,SUM(CONVERT(DECIMAL(18,2),isnull(a.EATTRIBUTE11,0))) as SumiSum,dbo.CNumeric(SUM(CONVERT(DECIMAL(18,2),isnull(a.EATTRIBUTE11,0)))) as ZWSumiSum
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
DataTable dtInMaterials = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
string strPrintTempFile = pJson.ShowReport(dtCashLog, dtInMaterial, dtInMaterials); //产生JSON文件内容
|
|
|
|
//把服务器的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.ICSPurchaseOrder
|
|
SET DownloadFrequency=ISNULL(DownloadFrequency,0)+1
|
|
WHERE POCode IN (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "'";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
public ActionResult MergePrintItemLot(string keyValue, string WorkPoint)
|
|
{
|
|
string strPrintFileName = "";
|
|
string DBLANK = SqlHelper.GetItemsDetails("ERP001", WorkPoint);
|
|
string CusterJC = ConfigurationManager.ConnectionStrings["CusterJC"].ConnectionString;
|
|
//string U8ConnStr = ConfigurationManager.ConnectionStrings["ERPDB"].ConnectionString;
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
|
|
string strSqls = string.Empty;
|
|
if (WorkPoint == "02")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd02.fr3";
|
|
}
|
|
else if (WorkPoint == "03")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd03.fr3";
|
|
}
|
|
else if (WorkPoint == "01")
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd.fr3";
|
|
}
|
|
else
|
|
{
|
|
strPrintFileName = Server.MapPath("/ReportFile/") + "LOEssd.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 = @"select distinct poCode
|
|
,VenName
|
|
,b.VenAddress cVenAddress
|
|
,b.VenPerson cVenPerson
|
|
,CreatePerson as MUSER
|
|
,b.VenPayCond as iPayCreDays
|
|
-- ,e.CsSName as cVenPayCond
|
|
,VenPhone
|
|
,VenAddress
|
|
,c.F_MobilePhone
|
|
,VenBank AS VenBank
|
|
,VenAccount as VenAccount
|
|
,VenRegCode
|
|
,VenEmail
|
|
,a.EATTRIBUTE12
|
|
,a.EATTRIBUTE13
|
|
from dbo.ICSPurchaseOrder a
|
|
left join ICSVendor b on a.VenCode=b.VenCode and a.WorkPoint=b.WorkPoint
|
|
left join Sys_SRM_User c on a.CreatePerson=c.F_RealName and a.WorkPoint=c.F_Location
|
|
--left join {0}.dbo.PayCondition d on b.cVenPayCond=d.cPayCode
|
|
--left join {0}.dbo.settleStyle e on b.Free2=e.cssCode
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
strSql = string.Format(strSql, DBLANK);
|
|
//string strSql = @"Select * From CashLog";
|
|
DataTable dtCashLog = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
if (CusterJC.Contains("佑伦") || CusterJC.Contains("思米思"))
|
|
{
|
|
strSqls = @"select Row_Number() OVER ( ORDER BY cDefine23 desc) AS Sequence,
|
|
cDefine22,cDefine23,InvUnit,sum(Quantity) as Quantity
|
|
,UnitPrice,sum(CAST(iSum as decimal(16,2)) ) as iSum,PreArriveDate,MTIME
|
|
from POSignBacks
|
|
where POCode IN (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "' and (isnull(Status,'')<>'关闭' and isnull(Status,'')<>'弃审') group by cDefine22,cDefine23,InvUnit,PreArriveDate,UnitPrice,MTIME";
|
|
}
|
|
else
|
|
{
|
|
strSqls = @" SELECT a.Sequence,a.InvCode,b.INVNAME,b.INVSTD,b.InvUnit,a.Quantity,a.UnitPrice,
|
|
CONVERT(NVARCHAR(50), a.PlanArriveDate,23) as PreArriveDate,CONVERT(NVARCHAR(50),a.ArriveDate,23) as ArriveDate,
|
|
CONVERT(NVARCHAR(50), a.DeliveryDate,23) as Free5,c.ProjectCode,b.INVDESC,a.CreatePerson as MUSER,CONVERT(NVARCHAR(50), a.MTIME,23) as MTIME,c.BatchCode,a.EATTRIBUTE11 as iSum
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
LEFT JOIN dbo.ICSExtension c ON a.ExtensionID=c.id AND a.WorkPoint=c.WorkPoint
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "' and (isnull(a.Status,'')<>'关闭' and isnull(a.Status,'')<>'弃审')";
|
|
}
|
|
|
|
|
|
|
|
DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSqls, true, null);
|
|
strSql = @" select SUM(CONVERT(INT,isnull(a.Quantity,0))) as SumQuantity,SUM(CONVERT(DECIMAL(18,2),isnull(a.EATTRIBUTE11,0))) as SumiSum,dbo.CNumeric(SUM(CONVERT(DECIMAL(18,2),isnull(a.EATTRIBUTE11,0)))) as ZWSumiSum
|
|
FROM dbo.ICSPurchaseOrder a
|
|
LEFT JOIN dbo.ICSINVENTORY b ON a.InvCode=b.INVCODE AND a.WorkPoint=b.WorkPoint
|
|
where a.POCode IN (" + keyValue.TrimEnd(',') + ") and a.WorkPoint='" + WorkPoint + "'";
|
|
DataTable dtInMaterials = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
|
|
string strPrintTempFile = pJson.ShowReport(dtCashLog, dtInMaterial, dtInMaterials); //产生JSON文件内容
|
|
|
|
//把服务器的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.ICSPurchaseOrder
|
|
SET DownloadFrequency=ISNULL(DownloadFrequency,0)+1
|
|
WHERE POCode IN (" + keyValue.TrimEnd(',') + ") and WorkPoint='" + WorkPoint + "'";
|
|
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;
|
|
}
|
|
|
|
#endregion
|
|
public ActionResult BackCommit(string keyValue)
|
|
{
|
|
try
|
|
{
|
|
App.BackCommit(keyValue);
|
|
return Success("保存成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Error(ex.Message);
|
|
}
|
|
}
|
|
[HttpGet]
|
|
public ActionResult Download(string filePath) {
|
|
filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["AttachmentPath"] + filePath);
|
|
string fileName = Path.GetFileName(filePath);
|
|
|
|
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();
|
|
return new EmptyResult();
|
|
}
|
|
|
|
}
|
|
}
|