using log4net.Repository.Hierarchy;
using NFine.Application.SRM;
using NFine.Code;
using NFine.Domain._03_Entity.SRM;
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 PriceInquiryController : ControllerBase
{
PriceInquiryApp APP = new PriceInquiryApp();
// GET: SRM/PriceInquiry
public ActionResult Index()
{
return View();
}
///
/// 条件非标物料
///
///
public ActionResult NoProductionMaterialAdd()
{
return View();
}
///
/// 新增询价单
///
///
public ActionResult PriceInquiryAdd()
{
return View();
}
///
/// 分配采购
///
///
public ActionResult PurchaserAllocation()
{
return View();
}
///
/// 供应商分配
///
///
public ActionResult VendorPersAllocation()
{
return View();
}
///
/// 报价管理
///
///
public ActionResult QuotedPriceIndex()
{
return View();
}
///
/// 报价明细
///
///
public ActionResult QuotedPriceDetail()
{
return View();
}
///
/// 审核报价
///
///
public ActionResult ReviewPrice()
{
return View();
}
///
/// 生效报价
///
///
public ActionResult CompPrice()
{
return View();
}
///
/// 报价过程查询
///
///
public ActionResult ComPricelistByPN()
{
return View();
}
///
/// 技术需求单发起
///
///
public ActionResult TechnicalRequirementsForm()
{
return View();
}
///
/// 技术需求单(新增界面)
///
///
public ActionResult TechnicalRequirementsFormAdd()
{
return View();
}
///
/// 需求单详情页
///
///
public ActionResult TechnicalRequirementsFormLook()
{
return View();
}
///
/// 选择需求物料
///
///
public ActionResult VendorPersAddItem()
{
return View();
}
///
/// 获取列表
///
///
///
///
[HttpGet]
public ActionResult GetInvTabByPN(string rfqno, Pagination pagination)
{
DataTable table = APP.GetInvTabByPN(rfqno);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
//初次加载页面数据
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetGridJsonByPN(Pagination pagination, string queryJson)
{
DataTable ListData = APP.GetGridJsonByPN(queryJson, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
///
/// 根据当前登录的采购获取物料行
///
///
///
///
[HttpGet]
public ActionResult GetInvTabByPNForVendor(string rfqno, Pagination pagination)
{
DataTable table = APP.GetInvTabByPNForVendor(rfqno);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
///
/// 新增询价单
///
///
///
[HttpPost]
public ActionResult AddRFQByPN(ICSSORRFQ details)
{
try
{
APP.AddRFQByPN(details);
return Success("询报价创建成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
///
/// 分配采购人员
///
///
///
[HttpPost]
public ActionResult AddRFQByPNPurchasing(ICSSORRFQ details)
{
try
{
APP.AddRFQByPNPurchasing(details);
return Success("询报价创建成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
///
/// 分配供应商
///
///
///
[HttpPost]
public ActionResult AddRFQByPNVendorsing(ICSSORRFQ details)
{
try
{
APP.AddRFQByPNVendorsing(details);
return Success("询报价创建成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
///
/// 获取采购人员
///
///
///
///
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSelectBuiess(string WorkPoint)
{
DataTable dt = APP.GetSelectBuiess(WorkPoint);
return Content(dt.ToJson());
}
///
/// 获取供应商
///
///
///
///
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSelectVendor(string WorkPoint)
{
DataTable dt = APP.GetSelectVendor(WorkPoint);
return Content(dt.ToJson());
}
///
/// 无聊行退回
///
///
///
public ActionResult InvCodeBack(string keyValue,string RFQNO)
{
string msg = APP.InvCodeBack(keyValue, RFQNO);
if (string.IsNullOrEmpty(msg))
{
return Success("退回成功!");
}
else
{
return Error(msg);
}
//return Content(app.DeleteInvTab(json));
}
///
/// 获取物料名称、单位、规格型号
///
///
///
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetTxtInfoByPN(string RFQCODE)
{
DataTable ListData = APP.GetTxtInfoByPN(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 SelectOfferByPN(string RFQCODE, Pagination pagination, string WorkPoint)
{
DataTable ListData = APP.SelectOfferByPN(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 SecondGetTxtInfoByPN(string RFQCODE, string QUOTATIONCODE)
{
DataTable ListData = APP.SecondGetTxtInfoByPN(RFQCODE, QUOTATIONCODE);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult SecondSelectOfferByPN(string RFQCODE, string QUOTATIONCODE, Pagination pagination)
{
DataTable ListData = APP.SecondSelectOfferByPN(RFQCODE, QUOTATIONCODE, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
public ActionResult GetGridJson(Pagination pagination, String JSON)
{
DataTable table = APP.GetGridJson(JSON, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
#region 查询技术部需求单列表
public ActionResult GetGridJsonICSSORRFQRequestFrom(Pagination pagination, String JSON)
{
DataTable table = APP.GetGridJsonICSSORRFQRequestFrom(JSON, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
#endregion
#region 查询技术部需求单列表(子表)
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetSubGridJsonICSSORRFQRequestFrom(string RFQCODE, Pagination pagination, string WorkPoint)
{
DataTable ListData = APP.GetSubGridJsonICSSORRFQRequestFrom(RFQCODE, ref pagination, WorkPoint);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
#endregion
#region 技术部发布申请单
public ActionResult JSPublish(string json)
{
return Content(APP.JSPublish(json));
}
#endregion
#region 删除技术申请单
public ActionResult DELETEICSSORRFQRequestFrom(string json)
{
return Content(APP.DELETEICSSORRFQRequestFrom(json));
}
#endregion
#region 生成申请单号
public ActionResult GetSercodeICSSORRFQRequestFrom(string workpoint)
{
string sercode = APP.GetSercodeICSSORRFQRequestFrom(workpoint);
return Content(sercode);
}
#endregion
#region 查询申请物料信息
public ActionResult GetInvTabICSSORRFQRequestFrom(string rfqno, Pagination pagination)
{
DataTable table = APP.GetInvTabICSSORRFQRequestFrom(rfqno);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
#endregion
#region 查询申请单主表信息,修改
public ActionResult GetICSSORRFQRequestFromrow(string rfqcode)
{
return Content(APP.GetICSSORRFQRequestFromrow(rfqcode).ToJson());
}
#endregion
#region 获取申请单附件信息
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetICSSORRFQRequestFromVenDorFile(string rfqcode)
{
DataTable ListData = APP.GetICSSORRFQRequestFromVenDorFile(rfqcode);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
#endregion
#region 删除申请的物料信息
public ActionResult DeleteInvRowICSSORRFQRequestFrom(string keyValue)
{
string msg = APP.DeleteInvRowICSSORRFQRequestFrom(keyValue);
if (string.IsNullOrEmpty(msg))
{
return Success("删除成功!");
}
else
{
return Error(msg);
}
//return Content(app.DeleteInvTab(json));
}
#endregion
#region 保存技术申请单方法
[HttpPost]
public ActionResult AddICSSORRFQRequestFromByPN(ICSSORRFQ details)
{
try
{
APP.AddICSSORRFQRequestFromByPN(details);
return Success("询报价创建成功!");
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
#endregion
public ActionResult GetInvTab(string rfqno, Pagination pagination)
{
DataTable table = APP.GetInvTable(rfqno);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = table
};
return Content(JsonData.ToJson());
}
///
/// 获取生效价格查询
///
/// 分页
/// 传入过滤参数
///
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetGridPriceByPN(Pagination pagination, string queryJson)
{
DataTable ListData = APP.GetGridPriceByPN(queryJson, ref pagination);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
public ActionResult AgreeByPN(string json)
{
return Content(APP.AgreeByPN(json));
}
[HttpPost]
///
/// 文件上传到本地
///
public ActionResult UploadFile(string ID, string BidCode, string WorkPoint)
{
try
{
// 检查是否有文件上传
if (Request.Files.Count == 0 || Request.Files[0]?.ContentLength == 0)
{
return Json(new { error = "请选择要上传的文件" }, JsonRequestBehavior.AllowGet);
}
var file = Request.Files[0];
var fileExtension = Path.GetExtension(file.FileName)?.ToLower();
// 验证文件类型
if (fileExtension != ".xls" && fileExtension != ".xlsx")
{
return Json(new { error = "只支持上传Excel(.xls, .xlsx)文件" }, JsonRequestBehavior.AllowGet);
}
// 生成唯一文件名并创建保存路径
var fileName = $"{DateTime.Now:yyyyMMddHHmmss}{Guid.NewGuid()}{fileExtension}";
var uploadDirectory = Server.MapPath("~/File/UPLoadFile/");
// 确保上传目录存在
if (!Directory.Exists(uploadDirectory))
{
Directory.CreateDirectory(uploadDirectory);
}
var savePath = Path.Combine(uploadDirectory, fileName);
// 保存文件
using (var stream = new FileStream(savePath, FileMode.Create))
{
file.InputStream.CopyTo(stream);
}
// 处理上传的Excel文件
var listData = APP.SetData_PR(savePath, ID, BidCode, WorkPoint);
return Content(listData.ToJson());
}
catch (Exception ex)
{
return Error(ex.Message);
}
}
public ActionResult GetPurchasing(string VenCode)
{
string msg = APP.GetPurchasing(VenCode);
var JsonData = new
{
mass = msg,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetVenDorFileSSORByPN(string FPRFQCODE)
{
DataTable ListData = APP.GetVenDorFileSSORByPN(FPRFQCODE);
var JsonData = new
{
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult SORRFQCourseHistoryInfoCahrsByPN(string FPRFQCODE, string workpoint, string ITEMCODE)
{
DataTable ListData = APP.SORRFQCourseHistoryInfoCahrsByPN(FPRFQCODE, workpoint, ITEMCODE);
string ss = ListData.ToJson();
return Content(ListData.ToJson());
}
[HttpGet]
[HandlerAjaxOnly]
public ActionResult GetGridMaterialByPN(Pagination pagination, string ITEMCODE, string VenCode, string FPRFQCODE)
{
DataTable ListData = APP.GetGridMaterialByPN(ref pagination, ITEMCODE, VenCode, FPRFQCODE);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
[HttpPost]
[HandlerAjaxOnly]
//[ValidateAntiForgeryToken]
public ActionResult SaveQuotationByPN(string keyValue)
{
string msg = "";
msg = APP.SaveQuotationByPN(keyValue);
if (string.IsNullOrWhiteSpace(msg))
{
return Success("信息保存成功!");
}
else
{
return Error("" + msg + "");
}
}
[HttpGet]
public ActionResult GetPriceInquiryItem(string invcode, Pagination pagination, string workpoint, string InvName,string sfqcode)
{
DataTable ListData = APP.GetPriceInquiryItem(invcode, ref pagination, workpoint, InvName, sfqcode);
var JsonData = new
{
total = pagination.total,
page = pagination.page,
records = pagination.records,
rows = ListData,
};
return Content(JsonData.ToJson());
}
}
}