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.
 
 
 
 

290 lines
9.3 KiB

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 CAAddController : ControllerBase
{
private CAManageApp App = new CAManageApp();
[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());
}
/// <summary>
/// 对账单新增明细 二级界面
/// </summary>
/// <param name="queryJson"></param>
/// <param name="pagination"></param>
/// <returns></returns>
//[HttpGet]
//[HandlerAjaxOnly]
//public ActionResult GetSubGridJson(string queryJson, Pagination pagination)
//{
// DataTable ListData = App.GetSubGridJson_Add(queryJson, ref pagination);
// var JsonData = new
// {
// total = pagination.total,
// page = pagination.page,
// records = pagination.records,
// rows = ListData,SaveItemCode
// };
// return Content(JsonData.ToJson());
//}
[HttpGet]
[HandlerAjaxOnly]
//public ActionResult GetSubGridJson(string queryJson, string CartonNo, Pagination pagination)
//{
// DataTable ListData = App.GetSubGridJson(CartonNo, ref pagination);
// var JsonData = new
// {
// total = pagination.total,
// page = pagination.page,
// records = pagination.records,
// rows = ListData,
// };
// return Content(JsonData.ToJson());
//}
public ActionResult Index()
{
return View();
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult SubmitForm(string POCode, string PORow, string keyValue)
{
int i = App.CreateItemLotNo(POCode, PORow, keyValue);
if (i > 0)
{
return Success("发布成功!");
}
else
{
return Error("发布失败!");
}
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSubGridJsonByCreate(string POCode, string PORow)
{
DataTable ListData = App.GetSubGridJsonByCreate(POCode, PORow);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetVendorLotNo(string VenCode, string WorkPoint)
{
DataTable ListData = App.GetVendorLotNo(VenCode, WorkPoint);
var JsonData = new
{
VendorLotNo = ListData.Rows[0][0].ToString(),
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetDocNo(string Tax, string WorkPoint, string Vendor)
{
string cDocNo = App.GetDocNo(Tax, WorkPoint, Vendor);
var JsonData = new
{
DocNo = cDocNo,
VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetDocNoByPerson(string SupplierCode, string Tax, string WorkPoint)
{
string cDocNo = App.GetDocNoByPerson(SupplierCode, Tax, WorkPoint);
var JsonData = new
{
DocNo = cDocNo,
VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode
};
return Content(JsonData.ToJson());
}
/// <summary>
/// 对账单添加,保存到明细表
/// </summary>
/// <param name="queryJson"></param>
/// <param name="DocNo"></param>
/// <param name="WorkPoint"></param>
/// <returns></returns>
[HttpPost]
[HandlerAjaxOnly]
public ActionResult SaveItemCode(string queryJson, string DocNo, string WorkPoint)
{
queryJson = queryJson.Substring(1, queryJson.Length - 2);
string msg = App.CheckSTNO_ItemCode(queryJson, DocNo, WorkPoint);
if (!string.IsNullOrEmpty(msg))
{
return Error(msg);
}
else
{
return Success("添加成功!");
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteInfo(string keyValue, string WorkPoint)
{
keyValue = keyValue.Substring(1, keyValue.Length - 2);
WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2);
string msg = App.DeleteInfo(keyValue, WorkPoint);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteDocNoSuit(string keyValue, string DeleteFlag, string WorkPoint,string Tax, string detail)
{
try
{
if (DeleteFlag == "1")
{
string msg = App.DeleteDocNoSuit(keyValue, WorkPoint);
}
else
{
string msg = App.UpdateSTNO(keyValue, WorkPoint, Tax, detail);
}
return Success("操作成功!");
}
catch (Exception ex)
{
return Error("操作失败!:"+ex.Message);
}
}
public ActionResult DeleteDocNoSuitBYX(string keyValue, string DeleteFlag, string WorkPoint)
{
string msg = App.DeleteDocNoSuit(keyValue, WorkPoint);
return Success("操作成功!");
}
[HttpPost]
[HandlerAjaxOnly]
[ValidateAntiForgeryToken]
public ActionResult DeleteDocNo(string keyValue, string DeleteFlag, string WorkPoint)
{
if (DeleteFlag == "1")
{
string msg = App.DeleteDocNo(keyValue, WorkPoint);
}
return Success("操作成功!");
}
public ActionResult ISCA(string queryJson, string WorkPoint)
{
try
{
App.ISCA(queryJson, WorkPoint);
return Success("修改成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
public ActionResult GetVendorWorkPoint(string WorkPoint)
{
string VenCode = App.GetVendorWorkPoint(WorkPoint);
return Content(VenCode);
}
/// <summary>
/// 上传扣款文件
/// </summary>
/// <param name="DocNo"></param>
/// <returns></returns>
[HttpPost]
public ActionResult UpLoadFileImport(string DocNo)
{
string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode;
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
string FileName = "";
string Name = "";
//获取上传的文件集合
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files;
try
{
for (int i = 0; i < httpFile.Count; i++)
{
FileName = Path.GetFileNameWithoutExtension(httpFile[i].FileName) + Path.GetExtension(httpFile[i].FileName);
string Paths = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CAAddFile\\" + DocNo + "\\");
if (!Directory.Exists(Paths))
{
Directory.CreateDirectory(Paths);
}
string PathName = System.Web.HttpContext.Current.Server.MapPath("~\\File\\CAAddFile\\" + DocNo + "\\" + FileName);
int iLen = httpFile[0].ContentLength;
byte[] bData = new byte[iLen];
httpFile[0].InputStream.Read(bData, 0, iLen);
FileStream fs = new FileStream(PathName, FileMode.OpenOrCreate);
fs.Write(bData, 0, bData.Length);
fs.Flush();
fs.Close();
fs.Dispose();
Name = "" + FileName + ";";
}
}
catch (Exception ex)
{
return Error(ex.Message);
}
return Success("上传成功!");
}
}
}