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.
 
 
 
 

152 lines
4.5 KiB

using NFine.Application.KBSSRM;
using NFine.Code;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace NFine.Web.Areas.KBSSRM.Controllers
{
public class InvMaintenanceController : ControllerBase
{
private InvMaintenanceApp App = new InvMaintenanceApp();
// GET: KBSSRM/InvMaintenance
public ActionResult InvMaintenance()
{
return View();
}
public ActionResult InvMaintenanceUpdate()
{
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());
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult GetICSInventoryInfo(string InvCode, string WorkPoint)
{
DataTable ListData = App.GetICSInventoryInfo(InvCode, WorkPoint);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateICSInventory(string keyValue)
{
string msg = App.UpdateICSInventory(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("维护成功!");
}
}
/// <summary>
/// 文件上传到本地
/// </summary>
public ActionResult UploadFile()
{
string mess = "";
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")
{
mess = "只可以选择Excel(.xls .xlsx)文件";//当选择的不是Excel文件时,返回
}
string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + Guid.NewGuid() + IsXls; //获取Execle文件名 DateTime日期函数
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile");
if (!Directory.Exists(Paths))
{
Directory.CreateDirectory(Paths);
}
string savePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\UPLoadFile\\" + filename);//Server.MapPath 获得虚拟服务器相对路径
int iLen = hpFiles[0].ContentLength;
if (Directory.Exists(savePath)) mess = "文件已存在";
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;
mess = App.SetData_PR(savePath);
if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath);
}
}
}
catch (Exception ex)
{
mess = ex.Message;
//return Error(ex.Message);
}
var JsonData = new
{
mass = mess,
};
return Content(JsonData.ToJson());
}
[HttpPost]
public void ExportAll(string keyValue, string InvCode, string InvName, string VenCode, string VenName)
{
DataTable dt = App.GetInvInfo(InvCode, InvName, VenCode, VenName);
AsposeCell.Export(dt);
}
}
}