using NFine.Application;
using NFine.Application.ProductManage;
using NFine.Code;
using NFine.Domain.Entity.ProductManage;
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.SRM.Controllers
{
public class POMaintenanceController : ControllerBase
{
private POMaintenanceApp App = new POMaintenanceApp();
[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());
}
///
/// 多交期查询
///
///
///
///
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetGridJsonByMore(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetGridJsonByMore(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 GetGridJsonWeiWai(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetGridJsonWeiWai(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 GetGridJsonWeiWaiByMore(Pagination pagination, string queryJson)
{
DataTable ListData = App.GetGridJsonWeiWaiByMore(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 GetSubGridJson(string queryJson,Pagination pagination,string WorkPoint)
{
DataTable ListData = App.GetSubGridJson(queryJson, ref pagination, WorkPoint);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSubGridJsonByYL(string queryJson, Pagination pagination, string WorkPoint)
{
DataTable ListData = App.GetSubGridJsonByYL(queryJson, ref pagination, WorkPoint);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSubGridJsonWeiWai(string queryJson, Pagination pagination, string WorkPoint )
{
DataTable ListData = App.GetSubGridJsonWeiWai(queryJson, ref pagination, WorkPoint);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
public ActionResult Index()
{
return View();
}
public ActionResult BatchForm()
{
return View();
}
public ActionResult IndexByDH()
{
return View();
}
public ActionResult IndexMore()
{
return View();
}
public ActionResult DeleteFileInfo()
{
return View();
}
//[HttpGet]
//[HandlerAjaxOnly]
//public ActionResult GetFormJson(string keyValue)
//{
// //var data = maintainAppApp.GetForm(keyValue);
// //return Content(data.ToJson());
//}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitForm(string keyValue)
{
string msg = App.SubmitPoMaintenance(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("维护成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult MoreSubmitForm(string keyValue)
{
string msg = App.MoreSubmitPoMaintenance(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("维护成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitFormByYL(string keyValue)
{
int i = App.SubmitPoMaintenanceByYL(keyValue);
if (i > 0)
{
return Success("维护成功!");
}
else
{
return Error("维护失败!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitFormByBatch(string POCodeRow,string ArriveDate)
{
int i = App.SubmitFormByBatch( POCodeRow, ArriveDate);
if (i > 0)
{
return Success("维护成功!");
}
else
{
return Error("维护失败!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitFormWeiWai(string keyValue)
{
string msg = App.SubmitFormWeiWai(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("维护成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult MoreSubmitFormWeiWai(string keyValue)
{
string msg = App.MoreSubmitFormWeiWai(keyValue);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("维护成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitFormByBatchWeiWai(string POCodeRow, string ArriveDate)
{
int i = App.SubmitFormByBatchWeiWai(POCodeRow, ArriveDate);
if (i > 0)
{
return Success("维护成功!");
}
else
{
return Error("维护失败!");
}
}
///
/// 上传质检报告
///
/// 采购订单号
/// 采购订单行号
///
[HttpPost]
public ActionResult UpLoadFileImport(string pocode, string sequence)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string FileName = "";
string PathName = "";
//获取上传的文件集合
try
{
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
for (int i = 0; i < httpFile.Count; i++)
{
//获取送货单号
//string STNO = Request.Form["STNO"].ToString();
string fileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName)
+ pocode + sequence + Path.GetExtension(httpFile[i].FileName);
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + pocode + "\\");
if (!Directory.Exists(Paths))
{
Directory.CreateDirectory(Paths);
}
string filePath = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + 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();
FileName += "" + fileName + ";";
PathName += "" + filePath + ";";
}
App.UpLoadFile(pocode, sequence, FileName);
return Success("上传成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
///
/// 获取质检报告文件列表
///
/// 采购订单号
/// 采购订单行号
/// 类型
/// 分页
///
[HttpGet]
public ActionResult GetFileInfo(string POCode, string Sequence, string Type, Pagination pagination)
{
DataTable ListData = new DataTable();
ListData = App.GetFileInfo(POCode, Sequence, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
///
/// 删除质检报告文件
///
///
/// 采购订单号
/// 采购订单行号
/// 类型
///
public ActionResult DeleteFileByCode(string keyValue, string POCode, string Sequence, string Type)
{
string msg = string.Empty;
keyValue = keyValue.Substring(1, keyValue.Length - 3);
string path = string.Empty;
path = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CSFile\\" + POCode + "");
msg = App.DeleteFileByCode(keyValue, POCode, Sequence, path);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("删除成功!");
}
}
//[HttpPost]
//[HandlerAjaxOnly]
//[HandlerAuthorize]
//[ValidateAntiForgeryToken]
//public ActionResult DeleteForm(string keyValue)
//{
// maintainAppApp.DeleteForm(keyValue);
// return Success("Delete success.");
//}
}
}