118 lines
5.4 KiB
Plaintext
Executable File
118 lines
5.4 KiB
Plaintext
Executable File
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Web;
|
|
|
|
namespace GuangFu.StringTracing.Common
|
|
{
|
|
public class Other
|
|
{
|
|
|
|
public static string SaveStockSpaceInfo( List<string> spArr, List<string> arrNumber, string StockID, string strERPID = "")
|
|
{
|
|
string text = "";
|
|
string text2 = "where 1=1 ";
|
|
string text3 = "";
|
|
DBHelpe db = new DBHelpe();
|
|
string sQL = " select T1.FINTERID,T1.FNUMBER,T1.FNAME,T1.FFLEXNUMBER, \r\n IsHave = case isnull(T2.FINTERID, '') when '' then 0 else 1 end \r\n from T_BAS_FLEXVALUES T1 \r\n left join T_BD_STOCKFLEXITEM T2 on T2.FINTERID = " + StockID + " \r\n and T2.FFLEXID = T1.FINTERID \r\n order by T2.FENTRYID \u3000 \r\n";
|
|
DataTable dataTable = db.ExecuteTable(sQL);
|
|
new List<string>();
|
|
new List<string>();
|
|
DataTable dataTable2 = db.ExecuteTable("select FFLEXNUMBER,CONVERT(VARCHAR(50),'') AS SPID, CONVERT(VARCHAR(50),'') AS SPNUMBER from T_BAS_FLEXVALUES order by FNUMBER");
|
|
foreach (DataColumn column in dataTable2.Columns)
|
|
{
|
|
column.ReadOnly = false;
|
|
}
|
|
|
|
for (int i = 0; i < dataTable2.Rows.Count; i++)
|
|
{
|
|
dataTable2.Rows[i]["SPID"] = spArr[i];
|
|
dataTable2.Rows[i]["SPNUMBER"] = arrNumber[i];
|
|
}
|
|
|
|
List<TStockSpace> list = new List<TStockSpace>();
|
|
Dictionary<string, string> dictionary = new Dictionary<string, string>();
|
|
int num = 0;
|
|
foreach (DataRow row in dataTable.Rows)
|
|
{
|
|
DataRow[] array = dataTable2.Select("FFLEXNUMBER='" + row["FFLEXNUMBER"].ToString() + "'");
|
|
if (array.Length != 0)
|
|
{
|
|
if (Convert.ToInt32(row["IsHave"]) == 1)
|
|
{
|
|
text3 = ((!(text3 == "")) ? (text3 + "." + array[0]["SPNUMBER"].ToString()) : array[0]["SPNUMBER"].ToString());
|
|
dictionary.Add(row["FFLEXNUMBER"].ToString(), array[0]["SPID"].ToString());
|
|
}
|
|
|
|
if (spArr.Count > num)
|
|
{
|
|
string text4 = array[0]["SPID"].ToString();
|
|
text2 = text2 + " and " + row["FFLEXNUMBER"].ToString() + "='" + text4 + "'";
|
|
list.Add(new TStockSpace
|
|
{
|
|
FieldName = row["FFLEXNUMBER"].ToString(),
|
|
ID = text4
|
|
});
|
|
}
|
|
}
|
|
|
|
num++;
|
|
}
|
|
|
|
DataTable dataTable3 = db.ExecuteTable(" select FINTERID from T_BAS_FLEXVALUESDETAIL (nolock) " + text2);
|
|
if (dataTable3.Rows.Count > 0)
|
|
{
|
|
text = dataTable3.Rows[0]["FINTERID"].ToString();
|
|
}
|
|
else
|
|
{
|
|
text = db.ExecuteTable("select isnull(max(FINTERID)+1,100001) from T_BAS_FLEXVALUESDETAIL ").Rows[0][0].ToString();
|
|
DataTable source = db.ExecuteTable("select t1.FNAME\r\n from T_BAS_FLEXVALUESENTRY t1\r\n left join T_BAS_FLEXVALUES t2 on t2.FINTERID = t1.FINTERID\r\n left join T_BD_STOCKFLEXITEM t3 on t3.FINTERID = '" + StockID + "' and t3.FFLEXID = t2.FINTERID\r\n where t1.FDETAILID in ('" + string.Join("','", dictionary.Values) + "')\r\n \u3000order by t3.FENTRYID ");
|
|
string text5 = "";
|
|
string text6 = " insert into T_BAS_FLEXVALUESDETAIL(";
|
|
text6 += "FINTERID";
|
|
text5 = text5 + "'" + text + "'";
|
|
text6 += ",FNUMBER";
|
|
text5 = text5 + ",'" + text3 + "'";
|
|
text6 += ",FNAME";
|
|
text5 = text5 + ",'" + string.Join(".", (from o in source.AsEnumerable()
|
|
select o["FNAME"].ToString()).ToList()) + "'";
|
|
text6 += ",UID";
|
|
text5 = text5 + ",'" + Guid.NewGuid().ToString() + "'";
|
|
foreach (TStockSpace item in list)
|
|
{
|
|
text6 = text6 + "," + item.FieldName;
|
|
text5 = text5 + ",'" + item.ID + "'";
|
|
}
|
|
|
|
text6 = text6 + ") values(" + text5 + ")";
|
|
try
|
|
{
|
|
db.ExecuteNonQuery(text6);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
text = "";
|
|
}
|
|
}
|
|
|
|
|
|
return text;
|
|
}
|
|
|
|
}
|
|
public class TStockSpace
|
|
{
|
|
public string LOCID { get; set; }
|
|
|
|
public string ID { get; set; }
|
|
|
|
public string FieldName { get; set; }
|
|
|
|
public string FNumber { get; set; }
|
|
|
|
public string FName { get; set; }
|
|
}
|
|
} |