|
|
using NFine.Application; using NFine.Code; using NFine.Domain._03_Entity; 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 QuotedPriceController : ControllerBase { private QuotedPriceApp App = new QuotedPriceApp();
//初次加载页面数据
[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 SelectOffer(string RFQCODE, Pagination pagination, string WorkPoint) { DataTable ListData = App.SelectOffer(RFQCODE, 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 SelectOfferByYL(string RFQCODE, Pagination pagination, string WorkPoint) { DataTable ListData = App.SelectOfferByYL(RFQCODE, 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 SecondSelectOffer(string RFQCODE, string QUOTATIONCODE, Pagination pagination) { DataTable ListData = App.SecondSelectOffer(RFQCODE, QUOTATIONCODE, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult SecondSelectOfferByYL(string RFQCODE, string QUOTATIONCODE, Pagination pagination) { DataTable ListData = App.SecondSelectOfferByYL(RFQCODE, QUOTATIONCODE, ref pagination); var JsonData = new { total = pagination.total, page = pagination.page, records = pagination.records, rows = ListData, }; return Content(JsonData.ToJson()); }
// GET: SRM/QuotedPrice
public ActionResult Index() { return View(); }
//查看报价详情子页面
public ActionResult QuotedPriceDetails() { return View(); }
//提交报价单页面
public ActionResult QuotedPrice() { return View(); }
public ActionResult QuotedPriceLIst() { return View(); }
public ActionResult IndexByYL() { return View(); } public ActionResult QuotedPriceDetailsByYL() { return View(); } public ActionResult LookQuotedPriceDetails() { return View(); }
/// <summary>
/// 获取物料名称、单位、规格型号
/// </summary>
/// <param name="WorkPoint"></param>
/// <returns></returns>
[HttpGet] [HandlerAjaxOnly] public ActionResult GetTxtInfo(string RFQCODE) { DataTable ListData = App.GetTxtInfo(RFQCODE); var JsonData = new { RFQCODE = ListData.Rows[0][0].ToString(), RFQNAME = ListData.Rows[0][1].ToString(), PURCHUGCODE = ListData.Rows[0][2].ToString(), ITEMTYPE = ListData.Rows[0][3].ToString(), PURCHUGNAME = ListData.Rows[0][4].ToString(), PURCHUGCONECT = ListData.Rows[0][5].ToString(), VENDORCODE = ListData.Rows[0][6].ToString(), cVenName = ListData.Rows[0][7].ToString(), VENDORTYPE = ListData.Rows[0][8].ToString(), CURRENCY = ListData.Rows[0][9].ToString(), TAXRATE = ListData.Rows[0][10].ToString(), PAYMENTCONDITION = ListData.Rows[0][11].ToString(), MEMO = ListData.Rows[0][12].ToString(), COMPANYCODE = ListData.Rows[0][13].ToString(), HASCOSTDETAILS = ListData.Rows[0][14].ToString(), FileName = ListData.Rows[0][15].ToString(), //AccountPeriod = ListData.Rows[0][16].ToString(),
}; return Content(JsonData.ToJson()); }
//新增获取报价单号
[HttpGet] [HandlerAjaxOnly] public ActionResult GetQuotationNo(string RFQCODE, string WorkPoint) { string QuotationNo = App.GetQuotationNo(RFQCODE, WorkPoint); var JsonData = new { QuotationNo = QuotationNo,
}; return Content(JsonData.ToJson()); }
[HttpPost] public ActionResult UpLoadFile(string QuotationNo) { try { string MUSER = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; string FileName = ""; string PathName = ""; string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(','); string Name=""; //获取上传的文件集合
HttpFileCollection httpFile = System.Web.HttpContext.Current.Request.Files; 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\\VendorFile\\" + MUSER + "\\" + QuotationNo + ""); if (!Directory.Exists(Paths)) { Directory.CreateDirectory(Paths); } PathName = System.Web.HttpContext.Current.Server.MapPath("~\\File\\VendorFile\\" + MUSER + "\\" + QuotationNo + "\\" + 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 + ";"; } //int count = App.UpLoadFile(Name, QuotationNo);
//if (count > 0)
//{
// return Success("上传成功!");
//}
//else
//{
// return Error("上传失败!");
//}
} catch (Exception ex) {
return Error(ex.Message); } return Success("上传成功!");
}
[HttpGet] [HandlerAjaxOnly] public ActionResult GetVendor(string RFQCODE) { DataTable dt = App.GetVendor(RFQCODE); return Content(dt.ToJson()); }
[HttpGet] [HandlerAjaxOnly] public ActionResult GetcVenName(string VenCode, string RFQCODE) { DataTable dt = App.GetcVenName(VenCode, RFQCODE); return Content(dt.ToJson()); }
[HttpPost] [HandlerAjaxOnly] //[ValidateAntiForgeryToken]
public ActionResult SaveQuotation(string keyValue) { string msg = "";
msg = App.SaveQuotation(keyValue);
if (string.IsNullOrWhiteSpace(msg)) { return Success("信息保存成功!"); } else { return Error("" + msg + ""); } }
[HttpPost] [HandlerAjaxOnly] //[ValidateAntiForgeryToken]
public ActionResult SaveQuotationByYL(string keyValue) { string msg = "";
msg = App.SaveQuotationByYL(keyValue);
if (string.IsNullOrWhiteSpace(msg)) { return Success("信息保存成功!"); } else { return Error("" + msg + ""); } }
[HttpGet] [HandlerAjaxOnly] public ActionResult SecondGetTxtInfo(string RFQCODE, string QUOTATIONCODE) { DataTable ListData = App.SecondGetTxtInfo(RFQCODE, QUOTATIONCODE); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetVenDorFileTB(string QUOTATIONCODE) { DataTable ListData = App.GetVenDorFileTB(QUOTATIONCODE); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetSORRVenDorFile(string QUOTATIONCODE) { DataTable ListData = App.GetSORRVenDorFile(QUOTATIONCODE); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } [HttpGet] [HandlerAjaxOnly] public ActionResult GetVenDorFileSSOR(string rfqno) { DataTable ListData = App.GetVenDorFileSSOR(rfqno); var JsonData = new { rows = ListData, }; return Content(JsonData.ToJson()); } [HttpPost] public void ExportAll(string RFQCODE, string WorkPoint) { DataTable dt = App.GetPOListExport(RFQCODE, WorkPoint); AsposeCell.Export(dt); }
[HttpPost] public ActionResult GetICSImport(string BidCode, string WorkPoint) {
string mess = ""; DataTable dts=null; 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 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;
dts = App.GetICSImport(savePath); if (System.IO.File.Exists(savePath))//删除文件
{
System.IO.File.Delete(savePath); }
} else { mess = "获取文件失败"; } } catch (Exception ex) {
mess = ex.Message; } return Content(dts.ToJson()); } } }
|