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.
94 lines
3.8 KiB
94 lines
3.8 KiB
using ICSSoft.Common;
|
|
using ICSSoft.Entity;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ICSSoft.DataProject
|
|
{
|
|
public class SalesReturnBack
|
|
{
|
|
|
|
/// <summary>
|
|
/// 获取销售发货
|
|
/// </summary>
|
|
/// <param name="infos"></param>
|
|
/// <returns></returns>
|
|
private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
private static string connString = System.Configuration.ConfigurationManager.AppSettings["ERPConnStr"];
|
|
private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
|
|
private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
|
|
public string Get(List<ICSSalesReturnBack> infos)
|
|
{
|
|
|
|
List<ICSSalesReturnBack> szJson = new List<ICSSalesReturnBack>();
|
|
DataTable dt = null;
|
|
string json = "";
|
|
if (infos.Count <= 0)
|
|
{
|
|
throw new Exception("传送数据为空!");
|
|
}
|
|
string res = string.Empty;
|
|
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
|
|
conn.Open();
|
|
SqlTransaction sqlTran = conn.BeginTransaction();
|
|
SqlCommand cmd = new SqlCommand();
|
|
cmd.Transaction = sqlTran;
|
|
cmd.Connection = conn;
|
|
try
|
|
{
|
|
string sql = string.Empty;
|
|
foreach (ICSSalesReturnBack info in infos)
|
|
{
|
|
if (info.MTime < new DateTime(2000, 01, 01))
|
|
throw new Exception("请输入正确的操作时间:" + info.MTime);
|
|
sql = @" select a.DLID ,a.cDLCode ,a.cCusCode,c.cCusName,a.cDepCode ,
|
|
d.cDepName,b.cordercode ,a.cMaker ,a.dcreatesystime ,
|
|
b.AutoID ,b.irowno,b.cInvCode ,b.iQuantity ,b.iNum ,b.iSOsID
|
|
FROM dbo.DispatchList a
|
|
INNER JOIN dbo.DispatchLists b ON a.DLID = b.DLID
|
|
LEFT JOIN dbo.Customer c ON a.cCusCode = c.cCusCode
|
|
left join Department d on a.cDepCode=d.cDepCode where b.iQuantity<0";
|
|
if (!string.IsNullOrWhiteSpace(info.SDNRTCode))
|
|
{
|
|
sql += " and a.cDLCode='{0}'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(info.MTime.ToString()))
|
|
{
|
|
sql += " and ISNULL(a.dnmodifytime ,ISNULL(a.dverifydate , ISNULL(a.dnmodifytime , a.dcreatesystime )))>='{1}'";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(info.User))
|
|
{
|
|
sql += "and a.CMAKER='{2}'";
|
|
}
|
|
sql = string.Format(sql, info.SDNRTCode, info.MTime, info.User);
|
|
dt = DBHelper.SQlReturnData(sql, cmd);
|
|
if (dt.Rows.Count <= 0 || dt == null)
|
|
throw new Exception("销售发货单号:" + info.SDNRTCode + ",无信息!");
|
|
json = JsonConvert.SerializeObject(dt);
|
|
}
|
|
cmd.Transaction.Commit();
|
|
return json;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
cmd.Transaction.Rollback();
|
|
log.Error(ex.Message);
|
|
throw new Exception(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
if (conn.State == ConnectionState.Open)
|
|
{
|
|
conn.Close();
|
|
}
|
|
conn.Dispose();
|
|
}
|
|
}
|
|
}
|
|
}
|