DataTable tab = new DataTable ();
tab = Dbutil.getdataset (Strcmd, "TESTA. V_yhj_vip_wx_xsmx "). Tables[0];
Create a small table:
DataView view = new DataView (tab);
DataTable ordertable = view. ToTable (True, "ORDERDATE", "Member_code", "Inv_num", "Zje", "Zfje", "Sell_qty", "Shop_code");
Generate a smaller table in ordertable-based Str_inv_num
for (int i = 0; i < OrderTable.Rows.Count; i++)
{
for (int j = 0; J < OrderTable.Columns.Count; J + +)
{
if (j = = 0)
{
Str_inv_date = Ordertable.rows[i][j]. ToString (). Trim ();
Shop_code = tab. ROWS[I][J]. ToString ();
}
if (j = = 1)
Str_membercode = Ordertable.rows[i][j]. ToString (). Trim ();
if (j = = 2)
{
Str_inv_num = Ordertable.rows[i][j]. ToString (). Trim ();
Subinv_num = Str_inv_num;
}
if (j = = 3)
Inv_totalamt = Convert.ToInt32 (Ordertable.rows[i][j]. ToString (). Trim ());
if (j = = 4)
Str_inv_amt = Convert.ToInt32 (Ordertable.rows[i][j]. ToString (). Trim ());
if (j = = 5)
Int_sell_qty = Convert.ToInt32 (Ordertable.rows[i][j]. ToString (). Trim ());
if (j = = 6)
Str_shop_code = tab. ROWS[I][J]. ToString (). Trim ();
}
if (Str_old_inv_num.trim ()!=str_inv_num.trim ())//Remove a member who has more than 2 documents, and each document has multiple items for sale in duplicate records. At present, the first item of the first ticket will be listed in the goods, if a list has more than one item, there will be duplicate data without this sentence. Cause the result to be incorrect.
{
View. RowFilter = "inv_num=" + str_inv_num+ "'";
orderdetailtable = view. ToTable (True, "Inv_num", "SKU", "C_short_de", "Sell_qty", "serial_no");
list<cofflineorderdetail> Lcofflineorderdetail = dbutil.getlist<cofflineorderdetail> (orderDetailTable );//Returns a generic list
OracleAccess.logger.Debug ("Cal_getofflineorder table:" + STR_VIP. ToString () + DateTime.Now.ToLongDateString () + DateTime.Now.ToLongTimeString () +
"," + Str_inv_date + "," + Str_membercode + "," + Str_inv_num + "," + Inv_totalamt + "," + Str_inv_amt + "," + int_s Ell_qty + "," + Str_shop_code +
Dbutil.tojson (Subtab));
Listorder. ADD (New Cofflineorder (Str_inv_date, Str_membercode, Str_inv_num, Inv_totalamt, Str_inv_amt, Str_shop_code, Int_Sell_ Qty, Lcofflineorderdetail));
View. RowFilter = "";
Str_old_inv_num = Str_inv_num;
}
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Eliminate duplicate data on a large DataTable, create 2 small DataTable, save multiple database connections, increase efficiency, and speed up program operation