纽威
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.
 
 
 
 
 

250 lines
12 KiB

using NFine.Code;
using NFine.Data.Extensions;
using NFine.Domain._03_Entity.SRM;
using NFine.Domain.Entity.ProductManage;
using NFine.Domain.IRepository.ProductManage;
using NFine.Repository;
using NFine.Repository.ProductManage;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
namespace NFine.Application.SRM
{
public class ComparisonApp : RepositoryFactory<ICSVendor>
{
/// <summary>
/// 获取比价单
/// </summary>
/// <param name="queryJson">传入参数</param>
/// <param name="jqgridparam">分页</param>
/// <returns></returns>
public DataTable GetGridJson(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select a.COMPARECODE,a.CREATEDATE,b.INVCODE,b.INVNAME,b.INVSTD, a.WorkPoint,e.PURCHUGCODE,e.PURCHUGNAME,e.PURCHUGCONECT,a.ppStatus
from dbo.ICSSORQUODETAILNORMAL a
left join dbo.ICSSORQUOTATION c on a.QUOTATIONCODE=c.QUOTATIONCODE
left join icsSORRFQ d on c.RFQCODE=d.RFQCODE
left join dbo.ICSINVENTORY b on a.ITEMCODE=b.INVCODE
left join dbo.ICSPURCHUG e on d.PURCHUGCODE=e.PURCHUGCODE where a.PPstatus in(0) or a.PPstatus is null and a.COMPARECODE is not null";
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["PURCHUG"].ToString()))
{
sql += " and e.PURCHUGCONECT like '%" + queryParam["PURCHUG"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["PURCHUGCODE"].ToString()))
{
sql += " and e.PURCHUGCODE like '%" + queryParam["PURCHUGCODE"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["PURCHUGNAME"].ToString()))
{
sql += " and e.PURCHUGNAME like '%" + queryParam["PURCHUGNAME"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["ITEMCODE"].ToString()))
{
sql += " and b.INVCODE like '%" + queryParam["ITEMCODE"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["ITEMName"].ToString()))
{
sql += " and b.INVNAME like '%" + queryParam["ITEMName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["TimeFrom"].ToString()))
{
sql += " and b.CREATEDATE >= '" + queryParam["TimeFrom"].ToString() + "' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["TimeTo"].ToString()))
{
sql += " and b.CREATEDATE <= '" + queryParam["TimeTo"].ToString() + "' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["INVSTD"].ToString()))
{
sql += " and b.INVSTD like '%" + queryParam["INVSTD"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["Stuts"].ToString()))
{
sql += " and a.ppStatus in( '" + queryParam["Stuts"].ToString().TrimEnd(',') + "') ";
}
}
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
//{
// sql += " and a.WorkPoint=" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location .TrimEnd(',')+ "";
//}
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
///
/// </summary>
/// <param name="queryJson"></param>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetGridPrice(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @"select c.PURCHUGCODE, d.ITEMCODE,d.ITEMNAME,a.VENDORCODE,e.QUOPRICE,e.UNIT,e.CURRENCY,f.invSTD,j.cVenName,j.cVenCode,e.QUOSTATUS,e.COMPARECODE
from dbo.ICSSORQUOTATION a
left join dbo.ICSSORRFQ2NORMALITEM d on a.RFQCODE=d.RFQCODE
left join [dbo].[ICSINVENTORY] f on d.ITEMCODE=f.INVCODE
left join [dbo].[ICSVendor] j on a.VENDORCODE=j.cvenCode
left join icsSORQUODETAILNORMAL e on a.QUOTATIONCODE=e.QUOTATIONCODE
left join dbo.ICSSORRFQ b on a.RFQCODE=b.RFQCODE and a.COMPANYCODE=b.COMPANYCODE
left join dbo.ICSPURCHUG c on b.PURCHUGCODE=c.PURCHUGCODE where 1=1 and e.QUOSTATUS='PricingApprove'";
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["PURCHUG"].ToString()))
{
sql += " and c.PURCHUGCODE like '%" + queryParam["PURCHUG"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["ITEMCODE"].ToString()))
{
sql += " and d.ITEMCODE like '%" + queryParam["ITEMCODE"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["ITEMName"].ToString()))
{
sql += " and d.ITEMNAME like '%" + queryParam["ITEMName"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["INVSTD"].ToString()))
{
sql += " and f.INVSTD like '%" + queryParam["INVSTD"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["Vencode"].ToString()))
{
sql += " and j.cVenCode in( '" + queryParam["Vencode"].ToString() + "') ";
}
if (!string.IsNullOrWhiteSpace(queryParam["VenName"].ToString()))
{
sql += " and j.cVenName in( '" + queryParam["VenName"].ToString() + "') ";
}
}
if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode != "admin")
{
sql += " and a.WorkPoint=" + NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',') + "";
}
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
//{
// sql += " and VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
//}
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 获取报价信息报价价格
/// </summary>
/// <param name="queryJson"></param>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetGridMaterial(string queryJson, ref Pagination jqgridparam)
{
DataTable dt = new DataTable();
var queryParam = queryJson.ToJObject();
List<DbParameter> parameter = new List<DbParameter>();
string sql = @" select d.ITEMCODE,d.ITEMNAME,a.VENDORCODE,e.QUOPRICE,e.UNIT,e.CURRENCY ,b.PURCHUGCODE,j.cVenName,
dd.TAXRATECODE,cc.paymentClause,e.COMPARECODE,'比价' as bijia,e.COSTDETAILSREFERCODE
from dbo.ICSSORQUOTATION a
left join dbo.ICSSORRFQ2NORMALITEM d on a.RFQCODE=d.RFQCODE
left join icsSORQUODETAILNORMAL e on a.QUOTATIONCODE=e.QUOTATIONCODE
left join icsSORRFQ2VENDOR f on e.COMPANYCODE=f.COMPANYCODE and e.RFQCODE=f.RFQCODE
left join ICSVendor j on a.VENDORCODE=j.cVenCode
left join dbo.ICSSORRFQ b on a.RFQCODE=b.RFQCODE and a.COMPANYCODE=b.COMPANYCODE
left join dbo.ICSPURCHUG c on b.PURCHUGCODE=c.PURCHUGCODE
left join icsSORQUOTATION cc on e.COMPANYCODE=cc.COMPANYCODE and e.QUOTATIONCODE=cc.QUOTATIONCODE
left join icsVENDORTAXRATE dd on cc.VENDORCODE=dd.VENDORCODE where 1=1 ";
if (!string.IsNullOrWhiteSpace(queryJson))
{
if (!string.IsNullOrWhiteSpace(queryParam["PURCHUG"].ToString()))
{
sql += " and b.PURCHUGCODE like '%" + queryParam["PURCHUG"].ToString() + "%' ";
}
if (!string.IsNullOrWhiteSpace(queryParam["InvCode"].ToString()))
{
sql += " and d.ITEMCODE like '%" + queryParam["InvCode"].ToString() + "%' ";
}
//if (!string.IsNullOrWhiteSpace(queryParam["INVSID"].ToString()))
//{
// sql += " and j.INVSTD like '%" + queryParam["INVSID"].ToString() + "%' ";
//}
//if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
//{
// sql += " and VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
//}
}
return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
}
/// <summary>
/// 税率
/// </summary>
/// <param name="queryJson"></param>
/// <param name="jqgridparam"></param>
/// <returns></returns>
// public DataTable GetGridVendorTaxrate(string queryJson, ref Pagination jqgridparam)
// {
// DataTable dt = new DataTable();
// var queryParam = queryJson.ToJObject();
// List<DbParameter> parameter = new List<DbParameter>();
// string sql = @"select c.TAXRATECODE,a.paymentClause,b.COMPARECODE,'比价' as bijia,b.COSTDETAILSREFERCODE from icsSORQUOTATION a
// left join icsSORQUODETAILNORMAL b on a.COMPANYCODE=b.COMPANYCODE and a.QUOTATIONCODE=b.QUOTATIONCODE
// inner join icsSORQUOTATION d on b.QUOTATIONCODE=d.QUOTATIONCODE
// left join icsVENDORTAXRATE c on d.VENDORCODE=c.VENDORCODE where 1=1";
// if (!string.IsNullOrWhiteSpace(queryJson))
// {
// //if (!string.IsNullOrWhiteSpace(queryParam["PURCHUG"].ToString()))
// //{
// // sql += " and b.PURCHUGCODE like '%" + queryParam["PURCHUG"].ToString() + "%' ";
// //}
// if (!string.IsNullOrWhiteSpace(queryParam["COMPARECODE"].ToString()))
// {
// sql += " and b.COMPARECODE like '%" + queryParam["COMPARECODE"].ToString() + "%' ";
// }
// //if (!string.IsNullOrWhiteSpace(queryParam["VenCode"].ToString()))
// //{
// // sql += " and b.VENDORCODE like '%" + queryParam["VenCode"].ToString() + "%' ";
// //}
// //if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
// //{
// // sql += " and VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
// //}
// }
// //if (NFine.Code.OperatorProvider.Provider.GetCurrent().RoleEnCode == "Vendor")
// //{
// // sql += " and VENDORCODE='" + NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode + "'";
// //}
// return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam);
// }
/// <summary>
/// 送签
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
public string UpdateCompareCode(string keyValue)
{
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
string msg = "";
keyValue = keyValue.Substring(1, keyValue.Length - 2);
// string[] keyValues = keyValue.Split(',');
string sql = string.Empty;
sql = "UPDATE icsSORQUODETAILNORMAL SET PPstatus = {1},QUOSTATUS='PricingApprove' WHERE CompareCode = {0} ";
sql = string.Format(sql, keyValue.TrimEnd(','), 1);
SqlHelper.ExecuteNonQuery(sql);
return msg;
}
}
}