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.
 
 
 
 
 

1539 lines
51 KiB

using NFine.Application.WMS;
using System;
using System.Data;
using System.IO;
using System.Web;
using System.Web.Mvc;
using NFine.Code;
using System.Data.SqlClient;
using NFine.Data.Extensions;
using ICS.Application.Entity;
using System.Linq;
namespace NFine.Web.Areas.Boxes.Controllers
{
public class BasicSettingsController : ControllerBase
{
BasicSettingsApp App = new BasicSettingsApp();
/// <summary>
/// 加载周转箱
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxes()
{
return View();
}
/// <summary>
/// 周转箱台账
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxAccount()
{
return View();
}
/// <summary>
/// 加载模具
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMould()
{
return View();
}
/// <summary>
/// 加载模具台账
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldAccountAdd()
{
return View();
}
/// <summary>
/// 新增周转箱信息
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxesAdd()
{
return View();
}
/// <summary>
/// 周转箱使用记录
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxesRecord()
{
return View();
}
/// <summary>
/// 周转箱台账信息
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxesAccountRecord()
{
return View();
}
/// <summary>
/// 模具使用记录
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldRecord()
{
return View();
}
/// <summary>
/// 模具台账信息
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldAccountRecord()
{
return View();
}
/// <summary>
/// 新增模具信息
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldAdd()
{
return View();
}
/// <summary>
/// 新增模具维修报废
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldMaintain()
{
return View();
}
/// <summary>
/// 新增模具维修报废
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldMaintainAdd()
{
return View();
}
//周转箱使用记录
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetBoxesRecord(string queryJson, Pagination pagination)
{
DataTable ListData = App.GetBoxesRecord(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 GetBoxesAccountRecord(string queryJson, Pagination pagination)
{
DataTable ListData = App.GetBoxesAccountRecord(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 GetMouldRecord(string queryJson, Pagination pagination)
{
DataTable ListData = App.GetMouldRecord(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 GetMouldAccountRecord(string queryJson, Pagination pagination)
{
DataTable ListData = App.GetMouldAccountRecord(queryJson, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
/// <summary>
/// 新增周转箱台账
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSBoxAccountAdd()
{
return View();
}
/// <summary>
/// 新增模具台账
/// </summary>
/// <returns></returns>
[HttpGet]
public ActionResult ICSMouldAccount()
{
return View();
}
/// <summary>
/// 删除周转箱
/// </summary>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteBoxes(string keyValue)
{
string msg = App.DeleteBoxes(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
//throw new Exception(msg);
}
}
/// <summary>
/// 新增周转箱信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult InsertBoxes(string keyValue)
{
string msg = App.InsertBoxes(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
/// <summary>
/// 修改周转箱信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateBoxes(string keyValue)
{
string msg = App.UpdateBoxes(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
/// <summary>
/// 获周转箱类型信息
/// </summary>
/// <param name="tableName">表名</param>
/// <returns></returns>
public ActionResult GetType(string tableName)
{
DataTable dt = App.GetType(tableName);
return Content(dt.ToJson());
}
/// <summary>
/// 新增模具信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult InsertMould(string keyValue)
{
string msg = App.InsertMould(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
/// <summary>
/// 修改模具信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateMould(string keyValue)
{
string msg = App.UpdateMould(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
/// <summary>
/// 修改模具状态信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateMouldStatus(string keyValue)
{
string msg = App.UpdateMouldStatus(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
/// <summary>
/// 删除模具档案
/// </summary>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteMould(string keyValue)
{
string msg = App.DeleteMould(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
//throw new Exception(msg);
}
}
/// <summary>
/// 删除模具台账
/// </summary>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteMouldAccount(string keyValue)
{
string msg = App.DeleteMouldAccount(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
//throw new Exception(msg);
}
}
/// <summary>
/// 获周转箱编码信息
/// </summary>
/// <returns></returns>
public ActionResult GetBoxNumber()
{
DataTable dt = App.GetBoxNumber();
return Content(dt.ToJson());
}
/// <summary>
/// 获取模具编码信息
/// </summary>
/// <returns></returns>
public ActionResult GetMouldNumber()
{
DataTable dt = App.GetMouldNumber();
return Content(dt.ToJson());
}
/// <summary>
/// 获取模具代码信息
/// </summary>
/// <returns></returns>
public ActionResult GetMouldCode()
{
DataTable dt = App.GetMouldCode();
return Content(dt.ToJson());
}
/// <summary>
/// 新增周转箱台账信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult InsertBoxAccount(string keyValue)
{
string msg = App.InsertBoxAccount(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
/// <summary>
/// 修改周转箱台账
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateBoxAccount(string keyValue)
{
string msg = App.UpdateBoxAccount(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
/// <summary>
/// 删除周转箱台账
/// </summary>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteBoxAccount(string keyValue)
{
string msg = App.DeleteBoxAccount(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
/// <summary>
/// 新增模具台账信息
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult InsertMouldAccount(string keyValue)
{
string msg = App.InsertMouldAccount(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
/// <summary>
/// 修改模具台账
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateMouldAccount(string keyValue)
{
string msg = App.UpdateMouldAccount(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
#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 PrintStack(string keyValue)
{
keyValue = keyValue.Substring(1, keyValue.Length - 2);
string strPrintFileName = Server.MapPath("/ReportFile/") + "Stack.fr3";
PrintJson pJson = new PrintJson(Server.MapPath("./PrintTemp"), strPrintFileName);
pJson.CheckRegister("苏州智合诚信息科技有限公司", "56DD3B4C172D0D140841CAC98A58A819F4E28EDA5D6E45711DDD64F6A439F68B6A7870CD7DAFD69A919CB870207FE4BB206F92BE3D53C221B019E0797E739EBA4"); //注册信息
pJson.MasterOptions(1, "STNO", false); //主从关系
SetCookieAndURL(pJson);// 设置控件调用的Cookie值,判断是否安装了打印控件
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string strSql = @"select a.LocationCode,
a.ID,
a.LocationName,
b.WarehouseCode,
b.WarehouseName,
a.Musername as 'MUSER',
a.MTIME
from ICSLocation a WITH (NOLOCK)
inner join ICSWarehouse b WITH (NOLOCK) on a.WHID=b.ID
where 1=1
and a.ID IN (" + keyValue.TrimEnd(',') + ")";
DataTable dtInInfo = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
// strSql = @"SELECT Row_Number() OVER (partition BY a.STNO ORDER BY a.CREATETIME DESC) AS rowno,c.STNO,
// c.PLANQTY,c.LotnoQTY,c.CartonNOQTY,c.ITEMCODE,b.INVNAME,b.INVSTD,b.INVPARSETYPE,d.StorageName,
// CONVERT(VARCHAR,CAST(ISNULL(c.Qty,0) AS money),1) AS Qty,
// CONVERT(VARCHAR,CAST(ISNULL(c.Meters,0) AS money),1) AS Meters,
// c.STNO AS QRSTNO,c.TransNO,c.TransLine,c.MEMO,c.VenderLotNO,CONVERT(varchar(10), c.PRODUCTDATE, 23) as PRODUCTDATE,a.remark
// FROM
// (SELECT aa.STNO,aa.ITEMCODE,aa.WorkPoint,SUM(aa.PLANQTY) PLANQTY,SUM(cc.LOTQTY) Qty,
// SUM(ISNULL(cc.Meters,0)) Meters,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE,
// COUNT(aa.LOTNO) LotnoQTY,COUNT(bb.CartonNO) CartonNOQTY
// FROM ICSASNDETAIL aa
// LEFT JOIN ICSITEMLot2Carton bb ON aa.LOTNO = bb.LotNO AND aa.WorkPoint = bb.WorkPoint
// LEFT JOIN ICSITEMLot cc ON aa.LOTNO = cc.LotNO AND aa.WorkPoint = cc.WorkPoint
// LEFT JOIN ICSPO_PoMain dd on dd.POCode=cc.TransNO and dd.PORow=cc.TransLine
// GROUP BY aa.stno,aa.itemcode,aa.WorkPoint,cc.TransNO,cc.TransLine,dd.MEMO,cc.VenderLotNO,cc.PRODUCTDATE) c
// LEFT JOIN ICSASN a on c.stno=a.stno AND c.WorkPoint=a.WorkPoint
// LEFT JOIN dbo.ICSINVENTORY b ON c.ITEMCODE=b.INVCODE AND b.WorkPoint=c.WorkPoint
// LEFT JOIN dbo.icsstorage d ON b.INVMACHINETYPE=d.StorageCode
// WHERE c.STNO IN (" + keyValue.TrimEnd(',') + ") and c.WorkPoint='" + WorkPoint + "'";
// DataTable dtInMaterial = DbHelper.ExecuteTable(DbHelper.ConnectionString, CommandType.Text, strSql, true, null);
string strPrintTempFile = pJson.ShowReport(dtInInfo, null); //产生JSON文件内容
//把服务器的URL + 此文件名 传递给控件,由控件下载还原数据进行打印
string strServerURL = Server.MapPath("/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.ICSASN
// SET ADDITION1=ISNULL(ADDITION1,0)+1,
// ADDITION2=CONVERT(varchar(100), GETDATE(), 21)
// WHERE STNO 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
/// <summary>
/// 导入Excel
/// </summary>
/// <param name="fileURL"></param>
/// <returns></returns>
[HttpPost]
public ActionResult Import(string fileURL)
{
var fileName = "";
var filePath = fileURL;
string path = Path.Combine(filePath, fileName);
//file.SaveAs(path);
DataTable excelTable = new DataTable();
//excelTable =SqlHelper.GetExcelDataTable(path);
DataTable dbdata = new DataTable();
dbdata.Columns.Add("LocationCode");
dbdata.Columns.Add("LocationName");
dbdata.Columns.Add("Musername");
dbdata.Columns.Add("MUSER");
dbdata.Columns.Add("EATTRIBUTE1");
for (int i = 0; i < excelTable.Rows.Count; i++)
{
string LocationCode = "";
string LocationName = "";
DataRow dr = excelTable.Rows[i];
DataRow dr_ = dbdata.NewRow();
if (!string.IsNullOrWhiteSpace(dr["区"].ToString().ToUpper()))
{
LocationCode += "-" + dr["区"].ToString().ToUpper();
LocationName += dr["区"].ToString().ToUpper() + "区";
}
if (!string.IsNullOrWhiteSpace(dr["排"].ToString().ToUpper()))
{
LocationCode += "-" + dr["排"].ToString().ToUpper();
LocationName += dr["排"].ToString().ToUpper() + "排";
}
if (!string.IsNullOrWhiteSpace(dr["货架"].ToString().ToUpper()))
{
LocationCode += "-" + dr["货架"].ToString().ToUpper();
LocationName += dr["货架"].ToString().ToUpper() + "货架";
}
if (!string.IsNullOrWhiteSpace(dr["层"].ToString().ToUpper()))
{
LocationCode += "-" + dr["层"].ToString().ToUpper();
LocationName += dr["层"].ToString().ToUpper() + "层";
}
if (!string.IsNullOrWhiteSpace(dr["格"].ToString().ToUpper()))
{
LocationCode += "-" + dr["格"].ToString().ToUpper();
LocationName += dr["格"].ToString().ToUpper() + "格";
}
dr_["LocationCode"] = LocationCode;
dr_["LocationName"] = LocationName;
dr_["Musername"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserName;
dr_["MUSER"] = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
dr_["Musername"] = "";
dbdata.Rows.Add(dr_);
}
SqlHelper.RemoveEmpty(dbdata);
SqlHelper.SqlBulkCopyByDatatable( "ICSLocation", dbdata);
return View();
}
//周转箱导入
[HttpPost]
/// <summary>
/// 文件上传到本地
/// </summary>
public string UploadFile()
{
try
{
HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
if (hpFiles != null && hpFiles.Count > 0)
{
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx")
{
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) return "文件已存在";
byte[] bData = new byte[iLen];
hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
newFile.Write(bData, 0, bData.Length);
newFile.Flush();
int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close();
newFile.Dispose();
//bool del = false;
string mess = "";
mess = App.SetDataBoxes(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
return mess;
}
else
{
return "获取文件失败";
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
//周转箱台账导入
[HttpPost]
/// <summary>
/// 文件上传到本地
/// </summary>
public string UploadBoxAccountFile()
{
try
{
HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
if (hpFiles != null && hpFiles.Count > 0)
{
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx")
{
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) return "文件已存在";
byte[] bData = new byte[iLen];
hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
newFile.Write(bData, 0, bData.Length);
newFile.Flush();
int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close();
newFile.Dispose();
//bool del = false;
string mess = "";
mess = App.SetDataBoxAccount(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
return mess;
}
else
{
return "获取文件失败";
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
//模具档案导入
[HttpPost]
/// <summary>
/// 文件上传到本地
/// </summary>
public string UploadMouldFile()
{
try
{
HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
if (hpFiles != null && hpFiles.Count > 0)
{
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx")
{
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) return "文件已存在";
byte[] bData = new byte[iLen];
hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
newFile.Write(bData, 0, bData.Length);
newFile.Flush();
int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close();
newFile.Dispose();
//bool del = false;
string mess = "";
mess = App.SetDataMould(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
return mess;
}
else
{
return "获取文件失败";
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
//模具台账导入
[HttpPost]
/// <summary>
/// 文件上传到本地
/// </summary>
public string UploadMouldAccountFile()
{
try
{
HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
if (hpFiles != null && hpFiles.Count > 0)
{
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx")
{
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) return "文件已存在";
byte[] bData = new byte[iLen];
hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
newFile.Write(bData, 0, bData.Length);
newFile.Flush();
int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close();
newFile.Dispose();
//bool del = false;
string mess = "";
mess = App.SetDataMouldAccount(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
return mess;
}
else
{
return "获取文件失败";
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
[HttpPost]
public ActionResult UpLoadFileImport()
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string fileName = "";
//获取上传的文件集合
try
{
//上传图片格式数组声明
string[] fileter = new string[] { ".jpg", ".png", ".jpeg" };
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
for (int i = 0; i < httpFile.Count; i++)
{
//上传文件后缀
string fileSuffix = httpFile[i].FileName.Substring(httpFile[i].FileName.LastIndexOf(".")).ToLower();
//保存图片名称以时间格式
fileName = DateTime.Now.ToString("yyyyMMddhhmmssms") + fileSuffix;
//string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName)
// + Path.GetExtension(httpFile[i].FileName);
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\Picture\\");
if (!fileter.Contains(fileSuffix))
{
return Error("上传失败,请上传后缀名为.jpg、.png、.jpeg的图片");
}
if (httpFile[i].ContentLength > 2097152)
{
return Error("上传失败,上传图片过大");
}
if (!Directory.Exists(Paths))
{
Directory.CreateDirectory(Paths);
}
var filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\Picture\\" + 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();
}
return Success("上传成功!", fileName);
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
//新增标签数据源
[HttpPost]
[HandlerAjaxOnly]
public ActionResult CreateLableDataSource( string Sys_LableDataSource)
{
string msg = App.CreateLableDataSource(Sys_LableDataSource);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetTXT(string ID)
{
DataTable ListData = App.GetTXT(ID);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
//修改标签数据源
[HttpPost]
[HandlerAjaxOnly]
public ActionResult updateLableDataSource(string Sys_LableDataSource)
{
string msg = App.updateLableDataSource(Sys_LableDataSource);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteLableDataSource(string keyValue)
{
string msg = App.DeleteLableDataSource(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetLableType()
{
DataTable dt = App.GetLableType();
return Content(dt.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSys_LablesID()
{
DataTable dt = App.GetSys_LablesID();
return Content(dt.ToJson());
}
//新增标签数据源
[HttpPost]
[HandlerAjaxOnly]
public ActionResult CreateLables(string txtLableName,string sel_LableType, string sel_LableSourceID )
{
string msg = App.CreateLables(txtLableName, sel_LableType, sel_LableSourceID);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetLabelTXT(string ID)
{
DataTable ListData = App.GetLabelTXT(ID);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult updateLables(string ID,string txtLableName, string sel_LableType, string sel_LableSourceID)
{
string msg = App.updateLables(ID,txtLableName, sel_LableType, sel_LableSourceID);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteICSLabelTemplate(string keyValue)
{
string msg = App.DeleteICSLabelTemplate(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
//获取父容器
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetContainerID()
{
DataTable dt = App.GetContainerID();
return Content(dt.ToJson());
}
//获取父容器
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetContainerType()
{
DataTable dt = App.GetContainerType();
return Content(dt.ToJson());
}
[HttpPost]
public ActionResult UpLoadLabelFile()
{
//获取上传的文件集合
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
//获取送货单号
string ID = Request.Form["ID"].ToString();
string LableName = Request.Form["LableName"].ToString();
string fileName = Path.GetFileNameWithoutExtension(httpFile[0].FileName)
+ "_" + LableName + Path.GetExtension(httpFile[0].FileName);
string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\LablesFile\\" + 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();
int count = App.UpLoadLabelFile(ID, fileName);
if (count > 0)
{
return Success("上传成功!");
}
else
{
return Error("上传失败");
}
}
[HttpPost]
public ActionResult UpLoadFileTxT()
{
//获取上传的文件集合
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
//获取送货单号
string LotNo = Request.Form["LotNo"].ToString();
string fileName = Path.GetFileNameWithoutExtension(httpFile[0].FileName)
+ Path.GetExtension(httpFile[0].FileName);
string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + 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();
int count = App.UpLoadFiles(LotNo, fileName);
if (count > 0)
{
return Success("上传成功!");
}
else
{
return Error("上传失败");
}
}
//料品不良组导入
[HttpPost]
/// <summary>
/// 文件上传到本地
/// </summary>
public string UploadFileInvBadGroup()
{
try
{
HttpFileCollection hpFiles = System.Web.HttpContext.Current.Request.Files;
if (hpFiles != null && hpFiles.Count > 0)
{
string IsXls = System.IO.Path.GetExtension(hpFiles[0].FileName).ToString().ToLower();//System.IO.Path.GetExtension获得文件的扩展名
if (IsXls != ".xls" && IsXls != ".xlsx")
{
return "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) return "文件已存在";
byte[] bData = new byte[iLen];
hpFiles[0].InputStream.Read(bData, 0, iLen);
FileStream newFile = new FileStream(savePath, FileMode.OpenOrCreate);
newFile.Write(bData, 0, bData.Length);
newFile.Flush();
int _FileSizeTemp = hpFiles[0].ContentLength;
newFile.Close();
newFile.Dispose();
//bool del = false;
string mess = "";
mess = App.UploadFileInvBadGroup(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
return mess;
}
else
{
return "获取文件失败";
}
}
catch (Exception ex)
{
return ex.ToString();
}
}
//根据ID获取其他站点
public ActionResult GetWorkPointNotInID(string WorkPointCode)
{
DataTable dt = App.GetWorkPointNotInID(WorkPointCode);
return Content(dt.ToJson());
}
//克隆站点
[HttpPost]
[HandlerAjaxOnly]
public ActionResult CloneWorkPointByCode(string WorkPoint, string WorkPointCode)
{
string msg = App.CloneWorkPointByCode(WorkPoint, WorkPointCode);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult DeleteTableByCode(string TableCode)
{
string msg = App.DeleteTableByCode(TableCode);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
}
}