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.
205 lines
6.8 KiB
205 lines
6.8 KiB
using NFine.Application.WMS;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using NFine.Code;
|
|
using System.Data.SqlClient;
|
|
using NFine.Data.Extensions;
|
|
using System.Data.OleDb;
|
|
using System.Configuration;
|
|
using ICS.Application.Entity;
|
|
|
|
namespace NFine.Web.Areas.WMS.Controllers
|
|
{
|
|
public class HomeWorkController : ControllerBase
|
|
{
|
|
|
|
HomeWorkApp INVApp = new HomeWorkApp();
|
|
// GET: WMS/HomeWork
|
|
public ActionResult InitialImport()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult InitialImportUpLoad()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult InitialWarehouse()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
[HttpPost]
|
|
/// <summary>
|
|
/// 文件上传到本地
|
|
/// </summary>
|
|
public string UploadFile()
|
|
{
|
|
try
|
|
{
|
|
string str_Year = Request.Form["txt_Year"];
|
|
String UPLoadType = Request.Form["UPLoadType"];
|
|
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") + UPLoadType + 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 = INVApp.SetData_PR(savePath, str_Year);
|
|
if (System.IO.File.Exists(savePath))//删除文件
|
|
{
|
|
|
|
System.IO.File.Delete(savePath);
|
|
}
|
|
return mess;
|
|
|
|
}
|
|
else
|
|
{
|
|
return "获取文件失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
return ex.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取仓库信息
|
|
/// </summary>
|
|
/// <param name="pagination"></param>
|
|
/// <param name="queryJson"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetICSWarehouse(Pagination pagination, string queryJson)
|
|
{
|
|
DataTable ListData = INVApp.GetICSWarehouse(ref pagination, queryJson);
|
|
var JsonData = new
|
|
{
|
|
total = pagination.total,
|
|
page = pagination.page,
|
|
records = pagination.records,
|
|
rows = ListData,
|
|
};
|
|
return Content(JsonData.ToJson());
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult ICSWarehouseExportAll(string keyvalue)
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = INVApp.ICSWarehouseExportAll(keyvalue);
|
|
AsposeCell.ExportbackColor(dt);
|
|
return Success("导出成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return Error(ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[HandlerAjaxOnly]
|
|
[ValidateAntiForgeryToken]
|
|
public ActionResult DeleteInitialImport(string keyValue)
|
|
{
|
|
string msg = INVApp.DeleteInitialImport(keyValue);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
return Success("删除成功!");
|
|
}
|
|
else
|
|
{
|
|
return Error(msg);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public string LotNoUploadFile()
|
|
{
|
|
try
|
|
{
|
|
string str_Year = Request.Form["txt_Year"];
|
|
String UPLoadType = Request.Form["UPLoadType"];
|
|
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") + UPLoadType + 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 = INVApp.LotNoSetData_PR(savePath, str_Year);
|
|
if (System.IO.File.Exists(savePath))//删除文件
|
|
{
|
|
|
|
System.IO.File.Delete(savePath);
|
|
}
|
|
return mess;
|
|
|
|
}
|
|
else
|
|
{
|
|
return "获取文件失败";
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
return ex.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|