Browse Source

到货单多站点

master
DESKTOP-DIHMM3I\22375 3 years ago
parent
commit
fa1340e960
  1. 165
      ICSSoft.ERP.WebAPI/ICSSoft.DataProject/CreatePOArrive.cs
  2. 2
      ICSSoft.ERP.WebAPI/ICSSoft.ERP.WebAPI/Web.config
  3. 1
      ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSPOArrive.cs

165
ICSSoft.ERP.WebAPI/ICSSoft.DataProject/CreatePOArrive.cs

@ -15,6 +15,7 @@ namespace ICSSoft.DataProject
{
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 ConnStr = System.Configuration.ConfigurationManager.AppSettings["ConnStr"];
private static string ERPDB = System.Configuration.ConfigurationManager.AppSettings["ERPDB"];
private static string Type = System.Configuration.ConfigurationManager.AppSettings["Type"];
//参数示例
@ -49,17 +50,24 @@ namespace ICSSoft.DataProject
throw new Exception("传送数据为空!");
}
string res = string.Empty;
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
try
{
string sql = string.Empty;
foreach (ICSPOArrive info in infos)
{
try
{
connString = string.Format(connString, info.WorkPoint);
conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
if (info.MTime < new DateTime(2000, 01, 01))
throw new Exception("请输入正确的操作时间:" + info.MTime);
sql = @" SELECT A.ID,A.cCode,A.cVenCode,D.cVenName,C.CDEPNAME,A.cDepCode,C.cDepName,A.cpocode,A.cMaker,A.cMakeTime,A.cverifier,A.caudittime,
@ -83,9 +91,7 @@ namespace ICSSoft.DataProject
sql = string.Format(sql, info.DNCode, info.MTime, info.User);
dt = DBHelper.SQlReturnData(sql, cmd);
json = JsonConvert.SerializeObject(dt);
}
cmd.Transaction.Commit();
return json;
}
catch (Exception ex)
{
@ -102,6 +108,10 @@ namespace ICSSoft.DataProject
conn.Dispose();
}
}
return json;
}
/// <summary>
/// 生成到货单
/// </summary>
@ -114,7 +124,7 @@ namespace ICSSoft.DataProject
throw new Exception("传送数据为空!");
}
string res = string.Empty;
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConnStr);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlCommand cmd = new SqlCommand();
@ -125,23 +135,23 @@ namespace ICSSoft.DataProject
string sql = string.Empty;
foreach (ICSPOArrive info in infos)
{
if (info.MTime<new DateTime(2000,01,01))
if (info.MTime < new DateTime(2000, 01, 01))
throw new Exception("请输入正确的操作时间:" + info.MTime);
string Lotnos = "";
foreach (var detail in info.details)
{
sql = @"IF EXISTS(SELECT LOTNO FROM ICSASNDETAIL WHERE LOTNO='{1}' AND STNO='{2}' AND ISNULL(RECEIVEQTY,0)>0)
sql = @"IF EXISTS(SELECT LOTNO FROM ICSASNDETAIL WHERE LOTNO='{1}' AND STNO='{2}' AND ISNULL(RECEIVEQTY,0)>0) and WorkPoint='{3}'
RAISERROR('{1}',16,1)
UPDATE ICSASNDETAIL SET RECEIVEQTY=ISNULL(RECEIVEQTY,0)+{0} WHERE LOTNO='{1}' AND STNO='{2}'
UPDATE ICSASNDETAIL SET RECEIVEQTY=ISNULL(RECEIVEQTY,0)+{0} WHERE LOTNO='{1}' AND STNO='{2}' and WorkPoint='{3}'
--IF EXISTS(SELECT LOTNO FROM ICSASNDETAIL WHERE LOTNO='{1}' AND STNO='{2}' AND RECEIVEQTY>PLANQTY)
-- RAISERROR('{1}',16,1)";
sql = string.Format(sql, detail.Quantity, detail.LOTNO,info.ASNNO);
DBHelper.CmdExecuteNonQuery(sql, cmd, "送货单号:"+ info.ASNNO+",条码:"+ detail.LOTNO+"未查询到对应数据!");
sql = string.Format(sql, detail.Quantity, detail.LOTNO, info.ASNNO, info.WorkPoint);
DBHelper.CmdExecuteNonQuery(sql, cmd, "送货单号:" + info.ASNNO + ",条码:" + detail.LOTNO + "未查询到对应数据!");
Lotnos += "'" + detail.LOTNO + "',";
}
if (string.IsNullOrWhiteSpace(Lotnos))
throw new Exception("送货单号:" + info.ASNNO+",无条码信息!");
CreatePUArrive( infos);
throw new Exception("送货单号:" + info.ASNNO + ",无条码信息!");
CreatePUArrive(infos);
}
cmd.Transaction.Commit();
return res;
@ -171,49 +181,72 @@ namespace ICSSoft.DataProject
public string CreatePUArrive(List<ICSPOArrive> Bills)
{
string res = string.Empty;
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
string str = "";
DataTable dt = null;
SqlTransaction sqlTran = conn.BeginTransaction();
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
int num = 0;
foreach (ICSPOArrive head in Bills)
{
num= head.details.Count();
num = head.details.Count();
}
DateTime time = DateTime.Now;
Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", "PuArrival", "" + num + "");
int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
int iChildId = Convert.ToInt32( dic["iChildId"].ToString());
DateTime date=DateTime.Now;
string iBaseCodeLen = DBHelper.GetAllRDCode("26", "" + time + "","admin");
//int iBaseCodeLen = Convert.ToInt32(dic["iBaseCodeLen"].ToString());
//int cVouchCodeBase = Convert.ToInt32(dic["cVouchCodeBase"].ToString());
List<ICSPOArrive> datas = new List<ICSPOArrive>();
string sql = "";
int irowno = 0;
try
{
foreach (ICSPOArrive head in Bills)
{
try
{
connString = string.Format(connString, head.WorkPoint);
conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
string[] ss = head.WorkPoint.Split('_');
ERPDB = ss[1];
DateTime time = DateTime.Now;
Dictionary<string, int> dic = DBHelper.GetAllCode("" + ERPDB + "", "PuArrival", "" + num + "");
int iFatherId = Convert.ToInt32(dic["iFatherId"].ToString());
int iChildId = Convert.ToInt32(dic["iChildId"].ToString());
DateTime date = DateTime.Now;
string iBaseCodeLen = DBHelper.GetAllRDCode("26", "" + time + "", "admin");
string DEF_ID = DBHelper.GetDefaultTemplate(Type, cmd);
#region 主表
sql = @"INSERT INTO PU_ArrivalVouch
sql = @"INSERT INTO dbo.PU_ArrivalVouch
(iVTid, ID, cCode, cPTCode, dDate, cVenCode, cDepCode, cPersonCode, cPayCode, cexch_name, iExchRate, iTaxRate, cMemo, cBusType, cMaker, bNegative,
iDiscountTaxType, iBillType, cMakeTime, cAuditDate, caudittime, cverifier, iverifystateex, IsWfControlled, iflowid, iPrintCount, cpocode)
SELECT @iVTid, @ID, @cCode, cPTCode, CONVERT(NVARCHAR(10), GETDATE(), 23), cVenCode, cDepCode, cPersonCode, cPayCode, cexch_name, nflat, iTaxRate, cMemo, '', @User, 0,
iDiscountTaxType, 0, GETDATE(), CONVERT(NVARCHAR(10), GETDATE(), 23), GETDATE(), @User, 2, 0, 0, iPrintCount, cPOID
FROM PO_Pomain WHERE 1=1 AND POID = @POID ";
cmd.Parameters.Clear();
cmd.Parameters.Add(new SqlParameter("@iVTid", DEF_ID));
cmd.Parameters.Add(new SqlParameter("@ID", iFatherId));
cmd.Parameters.Add(new SqlParameter("@cCode", iBaseCodeLen));
cmd.Parameters.Add(new SqlParameter("@User", head.User));
cmd.Parameters.Add(new SqlParameter("@POID", head.POCode));
//cmd.Parameters.Add(new SqlParameter("@dDate", data.dMate));
cmd.CommandText = sql;
try
@ -252,7 +285,7 @@ FROM PO_Pomain WHERE 1=1 AND POID = @POID ";
irowno += 1;
sql = @"
INSERT INTO PU_ArrivalVouchs
INSERT INTO dbo.PU_ArrivalVouchs
(Autoid, ID, cInvCode, iQuantity, iOriCost, iOriTaxCost, iOriMoney, iOriTaxPrice, iOriSum, iCost, iMoney, iTaxPrice, iSum, iTaxRate,
iPOsID, fValidInQuan, fRealQuantity, fValidQuantity, fRetQuantity, fInValidInQuan, bGsp, fValidNum, fValidInNum, fRealNum, bTaxCost,
SoType, fInvalidInNum, iinvexchrate, cordercode, RejectSource, iExpiratDateCalcu, iordertype, ivouchrowno, bgift,
@ -268,6 +301,7 @@ pd.ID, 0, @iQuantity, @iQuantity, 0, 0, 0, null, null, null, 1,
@Batch, @cDefine37, null, null, null, null, null FROM PO_Podetails pd
left join po_pomain b on pd.poid=b.poid
WHERE pd.ID = @iPOsID ";
cmd.Parameters.Clear();
cmd.Parameters.Add(new SqlParameter("@iPOsID", body.PODetailID));
cmd.Parameters.Add(new SqlParameter("@Autoid", iChildId));
@ -277,6 +311,7 @@ WHERE pd.ID = @iPOsID ";
cmd.Parameters.Add(new SqlParameter("@cordercode", head.POCode));
cmd.Parameters.Add(new SqlParameter("@ivouchrowno", irowno));
cmd.Parameters.Add(new SqlParameter("@dPDate", head.MTime));
if (cMassUnit == 1)
{
cmd.Parameters.Add(new SqlParameter("@dVDate", head.MTime.AddYears(iMassDate).Date));
@ -332,11 +367,8 @@ LEFT JOIN dbo.Department C ON A.cDepCode = C.cDepCode LEFT JOIN dbo.Vendor D ON
LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AND A.ID = '{0}' ";
sql = string.Format(sql, iFatherId);
dt = DBHelper.SQlReturnData(sql, cmd);
}
str = JsonConvert.SerializeObject(dt);
str += JsonConvert.SerializeObject(dt);
cmd.Transaction.Commit();
}
catch (Exception ex)
{
@ -344,6 +376,10 @@ LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AN
log.Error(ex.Message);
throw new Exception(ex.Message);
}
}
return str;
}
@ -357,26 +393,30 @@ LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AN
throw new Exception("传送数据为空!");
}
string res = string.Empty;
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
try
{
string sql = string.Empty;
foreach (ICSPOArrive info in infos)
{
try
{
connString = string.Format(connString, info.WorkPoint);
conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
if (info.MTime < new DateTime(2000, 01, 01))
throw new Exception("请输入正确的操作时间:" + info.MTime);
sql = @"UPDATE dbo.PU_ArrivalVouch SET cVerifier ='" + info.User + @"' ,
cAuditTime=CONVERT(VARCHAR(50),GETDATE(),112),cAuditDate=GETDATE() WHERE ID='{0}'";
sql = string.Format(sql,info.ID);
sql = string.Format(sql, info.ID);
DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
}
cmd.Transaction.Commit();
return json;
}
catch (Exception ex)
{
@ -393,6 +433,10 @@ LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AN
conn.Dispose();
}
}
return json;
}
/// <summary>
/// 删除请购单
/// </summary>
@ -406,26 +450,28 @@ LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AN
throw new Exception("传送数据为空!");
}
string res = string.Empty;
SqlConnection conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
try
{
string sql = string.Empty;
foreach (ICSPOArrive info in infos)
{
try
{
connString = string.Format(connString, info.WorkPoint);
conn = new System.Data.SqlClient.SqlConnection(connString);
conn.Open();
SqlTransaction sqlTran = conn.BeginTransaction();
cmd = new SqlCommand();
cmd.Transaction = sqlTran;
cmd.Connection = conn;
if (info.MTime < new DateTime(2000, 01, 01))
throw new Exception("请输入正确的操作时间:" + info.MTime);
sql = @" DELETE dbo.PU_ArrivalVouch WHERE ID='{0}'";
sql = string.Format(sql, info.ID);
DBHelper.CmdExecuteNonQuery(sql, cmd, "未查询到对应数据!");
}
cmd.Transaction.Commit();
return res;
;
}
catch (Exception ex)
{
@ -443,5 +489,10 @@ LEFT JOIN dbo.PO_Podetails E ON B.iPOsID = E.ID WHERE A.cverifier IS NOT NULL AN
}
}
return res;
}
}
}

2
ICSSoft.ERP.WebAPI/ICSSoft.ERP.WebAPI/Web.config

@ -9,7 +9,7 @@
<add key="Type" value="26"/>
<add key="ConnStr" value="Data Source=192.168.1.88;Database=ICSWMS_Base_Test;Uid=sa;Pwd=aA123456;"/>
<!--<add key="ERPConnStr" value="Data Source=192.168.1.36;Database=UFDATA_105_2019;Uid=sa;Pwd=p@ssw0rd;"/>-->
<add key="ERPConnStr" value="Data Source=192.168.1.218;Database=UFDATA_105_2019;Uid=sa;Pwd=aA123456;"/>
<add key="ERPConnStr" value="Data Source=192.168.1.218;Database={0};Uid=sa;Pwd=aA123456;"/>
<add key="webpages:Version" value="3.0.0.0"/>
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>

1
ICSSoft.ERP.WebAPI/ICSSoft.Entity/ICSPOArrive.cs

@ -11,6 +11,7 @@ namespace ICSSoft.Entity
public string DNCode;//到货单
public string WHCode;//仓库
public string POCode;//采购订单
public string WorkPoint;//采购订单
public string User;
public string ID;
public DateTime MTime;

Loading…
Cancel
Save