using NFine.Application.DHAY;
using NFine.Application.WMS;
using NFine.Code;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.Mvc;
namespace NFine.Web.Areas.WMS.Controllers
{
public class WMSCreateMOApplyController : ControllerBase
{
WMSCreateMOApplyApp App = new WMSCreateMOApplyApp();
// GET: DHAY/ICSCustomerSuppliedReturn
public ActionResult Index()
{
return View();
}
public ActionResult Create()
{
return View();
}
public ActionResult GetInvCode()
{
return View();
}
public ActionResult Update()
{
return View();
}
public ActionResult GetWHCode()
{
return View();
}
public ActionResult InitialImportUpLoad()
{
return View();
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteICSMOApply(string keyValue)
{
string msg = App.DeleteICSMOApply(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult SaveICSMOApply(string ICSASN)
{
string msg = App.SaveICSMOApply(ICSASN);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
[HttpGet]
public ActionResult GetICSMOApply(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetICSMOApply(ref pagination, queryJson);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
public ActionResult GetICSMOApplyByApplyCode(string ApplyCode)
{
DataTable ListData = App.GetICSMOApplyByApplyCode(ApplyCode);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetICSMOApplyDetail(string ApplyCode, string queryJson, Pagination pagination)
{
DataTable ListData = App.GetICSMOApplyDetail(ApplyCode, queryJson, 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 DeleteICSMOApplyByCode(string keyValue)
{
string msg = App.DeleteICSMOApplyByCode(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult ApproveICSMOApplyByCode(string keyValue)
{
string msg = App.ApproveICSMOApplyByCode(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("审核成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult AbandonICSMOApplyByCode(string keyValue)
{
string msg = App.AbandonICSMOApplyByCode(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("操作成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult ICSMOApplyByCodeFL(Pagination pagination, string ID, string Type, string flag, string Mechanism, string InvCode)
{
string msg = App.ICSMOApplyByCodeFL(ID, Type, Mechanism, InvCode);
if (string.IsNullOrEmpty(msg))
{
return Success("操作成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult CloseICSMOApplyByCode(string keyValue)
{
string msg = App.CloseICSMOApplyByCode(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("关闭成功!");
}
else
{
return Error(msg);
}
}
public ActionResult GetBidCode(string WorkPoint)
{
try
{
string Code = App.GetBidCode(WorkPoint);
var JsonData = new
{
Code = Code,
};
return Content(JsonData.ToJson());
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult UpdateICSMOApply(string ICSASN)
{
string msg = App.UpdateICSMOApply(ICSASN);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("修改成功!");
}
}
public ActionResult GetICSReturnTemporary(string rfqno, Pagination pagination)
{
DataTable table = App.GetICSReturnTemporary(rfqno);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetU9CodeType(string type)
{
string dt = App.GetU9CodeType(type);
return Content(dt);
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetItemList(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetItemList(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 GetItemListCount(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetItemListCount(queryJson,ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
///
/// 获取物料的可用库存量
///
/// 物料编码
/// 仓库
/// 批次
///
[HttpGet]
[HandlerAjaxOnly]
public decimal GetInvCodeCount(string invCode, string whCode = "", string batchCode = "")
{
return App.GetInvCodeCount(invCode, whCode, batchCode);
}
[HttpGet]
public ActionResult GetLYDep()
{
DataTable dt = App.GetLYDep();
return Content(dt.ToJson());
}
[HttpPost]
///
/// 文件上传到本地
///
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 = App.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();
}
}
}
}