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 InvoiceAddController : ControllerBase { private InvoiceManageApp App = new InvoiceManageApp(); [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 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, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetSubGridJson(string queryJson, string CartonNo, Pagination pagination, string WorkPoint) { DataTable ListData = App.GetSubGridJson(CartonNo, 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(); } [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 GetVendor() { DataTable dt = App.GetVendor(); return Content(dt.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetDocNo(string InvoiceType, string WorkPoint, string Vendor) { string cDocNo = App.GetDocNo(InvoiceType, 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 InvoiceType, string WorkPoint) { string cDocNo = App.GetDocNoByPerson(SupplierCode, InvoiceType, WorkPoint); var JsonData = new { DocNo = cDocNo, VenCode = NFine.Code.OperatorProvider.Provider.GetCurrent().VenCode }; return Content(JsonData.ToJson()); } [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, string objInvCode) { keyValue = keyValue.Substring(1, keyValue.Length - 2); WorkPoint = WorkPoint.Substring(1, WorkPoint.Length - 2); objInvCode = objInvCode.Substring(1, objInvCode.Length - 2); string msg = App.DeleteInfo(keyValue, WorkPoint, objInvCode); if (string.IsNullOrEmpty(msg)) { return Success("删除成功!"); } else { return Error(msg); } } [HttpPost] [HandlerAjaxOnly] [ValidateAntiForgeryToken] public ActionResult DeleteDocNo(string keyValue, string DeleteFlag, string PaperNo, string WorkPoint, string dVouDate) { if (DeleteFlag == "1") { string msg = App.DeleteDocNo(keyValue, WorkPoint); } else { string msg = App.UpdatePaperNo(keyValue, PaperNo, WorkPoint, dVouDate); } return Success("操作成功!"); } public ActionResult DeleteDocNoBYX(string keyValue, string DeleteFlag, string PaperNo, string WorkPoint) { string msg = App.DeleteDocNo(keyValue, WorkPoint); return Success("操作成功!"); } //public ActionResult ISInvoice(string queryJson, string WorkPoint) //{ // try // { // App.ISInvoice(queryJson, WorkPoint); // return Success("修改成功!"); // } // catch (Exception ex) // { // return Error(ex.Message); // } //} public ActionResult ISPaperNo(string PaperNo) { bool MSg; try { DataTable ListData = App.ISPaperNo(PaperNo); if (ListData.Rows.Count > 0) { MSg = true; } else { MSg = false; } var JsonData = new { MSg = MSg, }; return Content(JsonData.ToJson()); } catch (Exception ex) { return Error(ex.Message); } } public ActionResult GetVendorWorkPoint(string WorkPoint) { string VenCode = App.GetVendorWorkPoint(WorkPoint); return Content(VenCode); } [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\\InvoiceFile\\" + DocNo + "\\"); if (!Directory.Exists(Paths)) { Directory.CreateDirectory(Paths); } string PathName = System.Web.HttpContext.Current.Server.MapPath("~\\File\\InvoiceFile\\" + 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("上传成功!"); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetInvoiceFile(string DocNo) { DataTable ListData = App.GetInvoiceFile(DocNo); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } } }