|
|
using Newtonsoft.Json.Linq;using Newtonsoft.Json;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;using System.Linq;using System.Text;using System.Threading.Tasks;using System.IO;using System.Net;using NFine.Code;using System.Data.Common;using System.Reflection.Emit;
namespace NFine.Application.WMS{ /// <summary>
/// 委外到货单
/// </summary>
public class ICSODeliveryNoticeApp : RepositoryFactory<ICSVendor> {
public static DataTable Invmes = new DataTable();
/// <summary>
/// 委外到货单 删除
/// </summary>
/// <param name="keyValue"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public string DeleteICSODeliveryNoticeApplyNeg(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.ICSODeliveryNotice WHERE ODNCode IN ({0}) and WorkPoint ='{1}'", keyValue.TrimEnd(','), WorkPoint); //sql += string.Format(@"DELETE FROM dbo.ICSMOApplyNegDetail 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; }
/// <summary>
/// 委外到货单 查询
/// </summary>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetODeliveryNoticeApplyNeg(ref Pagination jqgridparam) { DataTable dt = new DataTable(); List<DbParameter> parameter = new List<DbParameter>(); string sql = @"select a.ODNCode,a.CreatePerson from ICSODeliveryNotice a
group by a.ODNCode,a.CreatePerson";
sql = string.Format(sql); DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); }
/// <summary>
/// 委外到货单 明细查询
/// </summary>
/// <param name="jqgridparam"></param>
/// <returns></returns>
public DataTable GetODeliveryNoticeApplyNegDetail(string ApplyNegCode, ref Pagination jqgridparam) { DataTable dt = new DataTable(); object Figure = GetDecimalDigits(); List<DbParameter> parameter = new List<DbParameter>(); string sql = @"SELECT a.ID,a.ODNCode,a.Sequence,a.VenCode,d.VenName,a.DepCode,g.DepName,a.InvCode,a.Quantity,a.ODNType,a.RCVQuantity,a.Amount,a.UnitPrice,a.Currency,a.OOID,c.OOCode,a.OASNCode
,a.WHCode,e.WarehouseName as WHName,a.Status,a.CreatePerson,a.CreateDateTime ,a.ExtensionID,a.MUSER,a.MUSERName,a.MTIME,a.WorkPoint,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10 from ICSODeliveryNotice a left join ICSInventory b on a.InvCode = b.InvCode and a.WorkPoint = b.WorkPoint left join ICSOutsourcingOrder c on a.OOID = c.ID and a.WorkPoint = c.WorkPoint left join ICSVendor d on a.VenCode = d.VenCode and a.WorkPoint = d.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint left join ICSWarehouse e on a.WHCode = e.WarehouseCode and a.WorkPoint=e.WorkPoint left join ICSDepartment g on a.DepCode = g.DepCode and a.WorkPoint = g.WorkPoint where a.ODNCode = '" + ApplyNegCode + "' ";
sql = string.Format(sql, Figure); DataTable dttest = Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); return Repository().FindTablePageBySql(sql.ToString(), parameter.ToArray(), ref jqgridparam); } 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 SaveICSODeliveryNoticeApplyNeg(string ICSASN) { string msg = ""; string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ODeliveryNotice/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 UpdateICSODeliveryNoticeApplyNeg(string ICSASN) { string msg = ""; string APIURL = ConfigurationManager.ConnectionStrings["APIURL"].ConnectionString + "ODeliveryNotice/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="WorkPoint"></param>
/// <returns></returns>
public string GetCode(string WorkPoint) { WorkPoint = NFine.Code.OperatorProvider.Provider.GetCurrent().Location; string OOCode = string.Empty; if (!string.IsNullOrEmpty(WorkPoint)) {
OOCode = GetSerialCode(WorkPoint, "ICSODeliveryNotice", "ODNCode", "OD", 8); } if (!string.IsNullOrWhiteSpace(OOCode)) { string sqlISHave = @"SELECT ODNCode FROM ICSODeliveryNotice a
WHERE a.ODNCode = '{0}'";
sqlISHave = string.Format(sqlISHave, OOCode); DataTable dtIsHave = SqlHelper.GetDataTableBySql(sqlISHave); if (dtIsHave.Rows.Count > 0) { throw new Exception("单号已存在!"); } } return OOCode; }
public string GetSerialCode(string workPointCode, string tbName, string colName, string Pre, int numLen) { string sql = "EXEC Addins_GetSerialCode '{0}','{1}','{2}','{3}',{4}"; sql = string.Format(sql, new object[] { workPointCode, tbName, colName, Pre, numLen }); return SqlHelper.ExecuteScalar(sql).ToString(); } public void UpdateODeliveryNoticeOrderApplyNegTemp(string json) { var data = json.ToJObject(); string usercode = NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode; var info = Invmes.Select(string.Format("TLZID='{0}'", data["TLZID"])); if (info != null && info.Length > 0) { info[0]["ZJID"] = data["ZJID"]; info[0]["InvName"] = data["InvName"]; } else { DataRow newrow = Invmes.NewRow(); newrow["ZJID"] = data["ZJID"]; Invmes.Rows.Add(newrow); } }
public DataTable GetICSODeliveryNoticeReturnTemporary(string ODNCode) { string sql = @"SELECT a.ID,a.ODNCode,a.Sequence,a.VenCode,d.VenName,a.DepCode,g.DepName,a.InvCode,a.Quantity,a.ODNType,a.RCVQuantity,a.Amount,a.UnitPrice,a.Currency,a.OOID,c.OOCode,a.OASNCode
,a.WHCode,e.WarehouseName as WHName,a.Status,a.CreatePerson,a.CreateDateTime ,a.ExtensionID,a.MUSER,a.MUSERName,a.MTIME,a.WorkPoint,f.Colspan ,f.ProjectCode ,f.BatchCode ,f.Version ,f.Brand ,f.cFree1 ,f.cFree2 ,f.cFree3 ,f.cFree4 ,f.cFree5 ,f.cFree6 ,f.cFree7 ,f.cFree8 ,f.cFree9 ,f.cFree10 ,a.EATTRIBUTE1,a.EATTRIBUTE2,a.EATTRIBUTE3,a.EATTRIBUTE4,a.EATTRIBUTE5,a.EATTRIBUTE6,a.EATTRIBUTE7,a.EATTRIBUTE8, a.EATTRIBUTE9,a.EATTRIBUTE10 from ICSODeliveryNotice a left join ICSInventory b on a.InvCode = b.InvCode and a.WorkPoint = b.WorkPoint left join ICSOutsourcingOrder c on a.OOID = c.ID and a.WorkPoint = c.WorkPoint left join ICSVendor d on a.VenCode = d.VenCode and a.WorkPoint = d.WorkPoint left join ICSExtension f on a.ExtensionID=f.ID and a.WorkPoint=f.WorkPoint left join ICSWarehouse e on a.WHCode = e.WarehouseCode and a.WorkPoint=e.WorkPoint left join ICSDepartment g on a.DepCode = g.DepCode and a.WorkPoint = g.WorkPoint where a.ODNCode ='" + ODNCode + "' ";
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); } } }}
|