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.
183 lines
6.4 KiB
183 lines
6.4 KiB
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json;
|
|
using NFine.Code;
|
|
using NFine.Data.Extensions;
|
|
using NFine.Domain._03_Entity.SRM;
|
|
using NFine.Repository;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data.Common;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace NFine.Application.WMS
|
|
{
|
|
|
|
/// <summary>
|
|
/// 供应商
|
|
/// </summary>
|
|
public class ICSVendorApp : RepositoryFactory<ICSVendor>
|
|
{
|
|
|
|
public static DataTable Invmes = new DataTable();
|
|
|
|
/// <summary>
|
|
/// 供应商删除
|
|
/// </summary>
|
|
/// <param name="keyValue"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public string DeleteVendorApplyNeg(string keyValue)
|
|
{
|
|
//站点信息
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location;
|
|
string msg = "";
|
|
keyValue = keyValue.Substring(1, keyValue.Length - 2);
|
|
string sql = string.Empty;
|
|
|
|
sql += string.Format(@"DELETE FROM dbo.ICSVendor WHERE ApplyCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
//sql += string.Format(@"DELETE FROM dbo.ICSMDNNegDetail WHERE ApplyNegCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint);
|
|
try
|
|
{
|
|
if (SqlHelper.CmdExecuteNonQueryLi(sql) > 0)
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
|
|
public object GetDecimalDigits()
|
|
{
|
|
string WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location.TrimEnd(',');
|
|
try
|
|
{
|
|
string sql = string.Empty;
|
|
sql = @"select Figure from ICSConfiguration where Code='Figure001' and Enable='1' and WorkPoint='" + WorkPoint + "'";
|
|
object Figure = SqlHelper.ExecuteScalar(sql);
|
|
return Figure;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message.ToString());
|
|
}
|
|
}
|
|
public void ClearTemp()
|
|
{
|
|
Invmes.Rows.Clear();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增
|
|
/// </summary>
|
|
/// <param name="ICSASN"></param>
|
|
/// <returns></returns>
|
|
public string SaveICSVendorApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "Vendor/Create";
|
|
string result = HttpPost(APIURL, ICSASN);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="ICSASN"></param>
|
|
/// <returns></returns>
|
|
public string UpdateICSVendorApplyNeg(string ICSASN)
|
|
{
|
|
string msg = "";
|
|
string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "Vendor/Update";
|
|
string result = HttpPost(APIURL, ICSASN);
|
|
JObject Obj = (JObject)JsonConvert.DeserializeObject(result);//或者JObject jo = JObject.Parse(jsonText);
|
|
string MessAge = Obj["Message"].ToString();
|
|
string Success = Obj["Success"].ToString();
|
|
if (Success.ToUpper() == "FALSE")
|
|
{
|
|
msg = MessAge;
|
|
}
|
|
return msg;
|
|
}
|
|
/// <summary>
|
|
/// 供应商 修改数据来源
|
|
/// </summary>
|
|
/// <param name="VenCode"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetICSVendorReturnTemporary(string VenCode)
|
|
{
|
|
string sql = @"select VenCode,VenName,VenAbbName,VCCode,VCName,VenAddress,VenRegCode,VenBank,VenAccount
|
|
,VenDevDate,VenLPerson,VenPhone,VenEmail,VenPerson,VenHand,VenDisRate,VenCreLine,VenCreDate,VenPayCond,PayName,VenExch_name,MUSER,MUSERName from ICSVendor
|
|
where a.VenCode ='" + VenCode + "' ";
|
|
DataTable table = Repository().FindDataSetBySql(sql).Tables[0];
|
|
DataTable dtCloned = table.Clone();
|
|
foreach (DataColumn col in dtCloned.Columns)
|
|
{
|
|
col.DataType = typeof(string);
|
|
}
|
|
foreach (DataRow row in table.Rows)
|
|
{
|
|
DataRow newrow = dtCloned.NewRow();
|
|
foreach (DataColumn column in dtCloned.Columns)
|
|
{
|
|
newrow[column.ColumnName] = row[column.ColumnName].ToString();
|
|
|
|
}
|
|
dtCloned.Rows.Add(newrow);
|
|
}
|
|
if (Invmes.Rows.Count > 0)
|
|
{
|
|
dtCloned.Merge(Invmes, false);
|
|
}
|
|
return dtCloned;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 接口api解析
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <param name="body"></param>
|
|
/// <returns></returns>
|
|
/// <exception cref="Exception"></exception>
|
|
public static string HttpPost(string url, string body)
|
|
{
|
|
try
|
|
{
|
|
Encoding encoding = Encoding.UTF8;
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
|
request.Method = "POST";
|
|
request.Accept = "application/json, text/javascript, */*"; //"text/html, application/xhtml+xml, */*";
|
|
request.ContentType = "application/json; charset=utf-8";
|
|
|
|
byte[] buffer = encoding.GetBytes(body);
|
|
request.ContentLength = buffer.Length;
|
|
request.GetRequestStream().Write(buffer, 0, buffer.Length);
|
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
|
using (StreamReader reader = new StreamReader(response.GetResponseStream(), encoding))
|
|
{
|
|
return reader.ReadToEnd();
|
|
}
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|