repater列求和

repater:

sql里面求和

 

 1 public void showList()
 2         {
 3             string fromdate = txtFromDate.Text;
 4             string todate = txtToDate.Text;
 5             string sales = ddlSales.SelectedValue;
 6             DataTable dt = B_Commission.getSales_volume(fromdate,todate,sales);
 7             rptList_stk.DataSource =dt;
 8             rptList_stk.DataBind();
 9 
10             if (dt != null && dt.Rows.Count > 0)
11             {
12                 foreach (DataRow dr in dt.Rows)
13                 {
14                     p_sub_total = p_sub_total + dr["amount"].getDbl();
15                     P_sub_profit = P_sub_profit + dr["profit"].getDbl();
16                 }
17             }
18 
19             lbl_Total.Text = MyNumber.showNum_TwoDecimal(p_sub_total);
20             lbl_Total_profit.Text = MyNumber.showNum_TwoDecimal(P_sub_profit);
21         }

if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
Model.MP_invoiceItem mp = ((Model.MP_invoiceItem)e.Item.DataItem);(使用model转化的时候)
tal = tal + Convert.ToDecimal(mp.amount);
}
if (e.Item.ItemType == ListItemType.Footer)
{
Label lbl = (Label)e.Item.FindControl("lbl_Total");
lbl.Text = tal.getString();
}

 

Model.MP_invoiceItem mp = ((Model.MP_invoiceItem)e.Item.DataItem);
Label lbl = (Label)e.Item.FindControl("lbl_Total");
lbl.Text = mp.amount.getString();
tal = tal + Convert.ToDecimal(mp["amount"]);

repeater增删改

 1 获得linkbutton的CommandArgument的值
 2 int spec_id = e.CommandArgument.getInt();
 3 
 4 if (e.CommandName == "Edit")
 5             {
 6                 textcommand = int.Parse(e.CommandArgument.ToString());
 7             }
 8             else if (e.CommandName == "Cancel")
 9             {
10                 textcommand = -1;
11             }
12             else if (e.CommandName == "Update")
13             {
14                 //Update
15                 int spec_id = e.CommandArgument.getInt();
16                 string batch_code = ((TextBox)this.rptList.Items[e.Item.ItemIndex].FindControl("txtBatchCode")).Text.Trim();
17                 string step_code = ((TextBox)this.rptList.Items[e.Item.ItemIndex].FindControl("txtStepCode")).Text.Trim();
18                 int qty = ((TextBox)this.rptList.Items[e.Item.ItemIndex].FindControl("txtQty")).Text.Trim().getInt();
19                 string warranty = ((TextBox)this.rptList.Items[e.Item.ItemIndex].FindControl("txtWarranty")).Text.Trim();
20 
21                 B_Item.updateItemSpac(batch_code, step_code, qty, warranty, spec_id);
22                 this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('更新ID:" +
23                      e.CommandArgument + ";页面值:A," + batch_code + "----B," + step_code + "----C," + qty + "');", true);
24                 AppendRowForUpdate();
25             }
26             else if (e.CommandName == "Delete")
27             {
28                 //Delete.  
29                 for (int i = 0; i < rptList.Items.Count; i++)
30                 {
31                     CheckBox chk = (CheckBox)rptList.Items[i].FindControl("ckboxRemove");
32                     if (chk.Checked)
33                     {
34                         int spec_id = e.CommandArgument.getInt();
35                         B_Item.deleteItemSpac(spec_id);
36                     }
37                 }
38                 this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('删除ID:" + e.CommandArgument + "');", true);
39                 AppendRowForUpdate();
40             }
41 
42             ShowItemspec();
43             AppendRowForUpdate();
44         }
45     }
46 }

 

posted @ 2017-02-10 15:41  suan1717  阅读(296)  评论(0编辑  收藏  举报