怎麼樣datatable表中增加一行合計行?

2022-04-29 05:00:09 字數 2246 閱讀 5417

引言:

假設存在乙個datatable物件dt,具有以下列名:產品名稱productname,數量quantity,單價price,金額money,那麼我們可通過下列方式給它新增合計行以繫結到datagrid物件

double sumquantity=0;

double summoney=0;

for(int i=0;i

datarow dr=dt.newrow ();

dr["productname"]="合計";

dr["quantity"]=sumquantity;

dr["money"]=summoney;

dt.rows.add(dr);

擴充套件例項:

存在乙個datatable物件table,新增一行統計彙總資訊

void ucsearchxuhang1_selectreportevent(object

sender, eventargs e)

else) "

, ids);

string sql = string

.empty;

where +=whereids;

sql = string.format(@"

select cr.casename as 用例名稱,

case cr.timeelapsed when -1 then 0 else cr.timeelapsed end as 用例用時,

cr.casestepcount as 用例步驟總數,

cr.finishedstepcount as 完成步驟數,

case cr.resultcode when 3 then '成功' when 4 then '失敗' when 5 then '未知' when 6 then '取消' else '錯誤' end as 執行結果

from caserecords cr,steprecords sr

where sr.caserecordid=cr.recordid and cr.executestate=16

", where

, ucsearchxuhang1.selectnames);

datatable table = this.areport.sqlserverreturndataset(sql).tables[0

];

string sqlto = string.format(@"

select(select count(0) from caserecords as cr where cr.resultcode=3 and cr.executestate=16 ) as succeednum,

(select count(0) from caserecords as cr where cr.resultcode<>3 and cr.executestate=16 ) as failnum

", where

); datatable successtable = this.areport.sqlserverreturndataset(sqlto).tables[0

];

for (int i = 0; i < successtable.columns.count; i++)

}totalnum = successnum +failnum;

if (totalnum > 0

) 條 %

", successnum, succeedrate);

strmsgfail = string.format("

失敗:條 %

", failnum, failrate);

strmsgtotal = string.format("

總共:條

", totalnum);

}try datarow row =table.newrow();

if (table != null

) ,,

", strmsgsuccess, strmsgfail, strmsgtotal);

}else

table.rows.add(row);

}catch

(exception)

xuhangdata.datasource =table;

}}

結果如下圖:

怎麼樣分析表或索引

q 怎麼樣分析表或索引 a 命令列方式可以採用analyze命令 如analyze table tablename compute statistics analyze index cluster indexname estimate statistics analyze table tablena...

怎麼樣修改android中語言

查了很多的網頁,上面都只有寫要修改product locales欄位.但.mk檔案太多的,我找了很久都沒有找到這個欄位在 定義的.最後發現的結果 device rockchip sdkdemo boardconfig.mk中.這個資料夾在標準的android 中屬於定製檔案目錄,可以在相應的專案中找...

在中軟國際怎麼樣

入職第一天 當時還在中軟,認識了幾個有工作經驗的,相互交談了一下。覺得還不錯。入職第三天 負責人給我專案的配置手冊,讓我照著上面配置。很頭大,全新的領域,很多名詞我都不知道。只能逼著自己接受。他下午還是照常看我的學習情況。入職第四天 負責人沒有給我指定任務,我又熟悉了專案,翻了翻他們的部落格,下午負...