1. See the concept first to see the Highplayer blog
http://blog.csdn.net/highplayer/article/details/6613817
2.
protected void Staticstresstest (object sender, EventArgs e)
{
#region Myregion
if (string. IsNullOrEmpty (Txt_computedate_. Value))
{
Page.ClientScript.RegisterClientScriptBlock (JSUtil.CurrentPage.GetType (), Util.newguid (), @ "<script>$. Messager.alert (' Operation Tip ', ' query date cannot be empty! ');</script> ");
Return
}
DataTable dt = new DataTable ();
DateTime computedate = DateTime.Parse (txt_computedate_. Value);
double[] Termlist =
{
0.01, 0.02, 0.03, 0.05, 0.1, 0.2, 0.3, 0.5, 1, 2, 5, 0,-0.01,-0.02,-0.03,
-0.05,-0.1,-0.2,-0.3,-0.5,-1,-2,-5
};
string[] NameList =
{
"Add_one_percent", "Add_two_percent", "Add_three_percent", "Add_five_percent",
"Add_ten_percent", "Add_twenty_percent", "Add_thirty_percent", "Add_fifty_percent",
"Add_one_hundred_percent", "Add_two_hundred_percent",
"Add_five_hundred_percent", "Unchanged_value", "Minus_one_percent", "Minus_two_percent",
"Minus_three_percent", "Minus_five_percent", "Minus_ten_percent", "Minus_twenty_percent",
"Minus_thirty_percent", "Minus_fifty_percent", "Minus_one_hundred_percent",
"Minus_two_hundred_percent",
"Minus_five_hundred_percent"
};
for (int i = 0; i < termlist.length; i++)
{
Shockinputdata shockinputdata = new Shockinputdata ();
Shockinputdata.shockvaluetypeid = (int) lookupitems.value_type_percentage;
Shockinputdata.shockvalue = Termlist[i];
Shockinputdata.shockmodeid = (int) Lookupitems.shock_mode_add;
Shockinputdata.shockscope = "All";
Shockinputdata.shockflag = Constants.shock_yes;
Shockinputdata.shocktype = "Marketprice";
Psvc.generatestressedtrancashflowbydateswithshock (Computedate, Computedate, Computedate,
ComputeDate, Shockinputdata, "stress_test_static");
Payoffcomputationservice.computetransactionpayoffbydate (computedate, "stress_test_static");
String sql =
"Select t.portfolio_id as item_id,t.transaction_id, t.transaction_sub_id,t.as_of_date as Compute_ Date,po.portfolio_name,round (sum (t.mark_to_market_value), 2) "+
Namelist[i] +
" from Tran_payoff T "+
" inner Join Bas_portfolio PO on po.portfolio_id=t.portfolio_id "+
" where T.result_use_type = ' stress_test_static ' and as_of _date=:computedate "+
" GROUP by T.portfolio_id,t.as_of_date,t.transaction_id,t.transaction_sub_id,po.portfolio _name ";
QueryInfo dsinfo = new QueryInfo ();
Dsinfo.customsql = SQL;
Dsinfo.addparam ("Computedate", computedate);
DataSet tempset = Dao.excutedataset (Dsinfo);
Tempset.tables[0]. PrimaryKey = new[]
{
Tempset.tables[0]. Columns[0],
Tempset.tables[0]. Columns[1],
Tempset.tables[0]. COLUMNS[2],
Tempset.tables[0]. COLUMNS[3]
};
if (i = = 0)
{
dt = tempset.tables[0];
}
Else
{
dt. Merge (Tempset.tables[0]);
}
}
var resultlist = dt. Tolist<rskstaticstresstest> ();
QueryInfo deleteinfo = new QueryInfo ();
Deleteinfo.customsql = "Delete from rskstaticstresstest where computedate=:computedate";
DELETEINFO.PARAMETERS.ADD ("Computedate", computedate);
Dao.executeupdate (Deleteinfo);
Dao.saveorupdateall (resultlist);
Aspxgridview1.datasource = DT; session["Rsk_staticstress_dev"] = DT;
Aspxgridview1.databind ();
#endregion
Page.ClientScript.RegisterClientScriptBlock (JSUtil.CurrentPage.GetType (), Util.newguid (), @ "<script> Datagrid.waitmessage (' Loading data, please later: ');</script> ");
Thread.Sleep (5000);
Page.ClientScript.RegisterClientScriptBlock (JSUtil.CurrentPage.GetType (), Util.newguid (), @ "<script> Datagrid.removewaitmessage ();</script> ");
Page.ClientScript.RegisterClientScriptBlock (JSUtil.CurrentPage.GetType (), Util.newguid (), @ "<script>$. Messager.alert (' Operation Tip ', ' Calculation succeeded! ');</script> ");
}
The merge operation after the DataTable is set PrimaryKey