예제 #1
0
    //called by button clicked by user
    //uses bound data along with abstract layer calls to update database
    public void addFundsClick(object sender, CommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);

        System.Diagnostics.Debug.WriteLine(id);
        DataAbstract DA   = new DataAbstract();
        DataRow      DR   = DA.returnOneGoal(id).Tables[0].Rows[0];
        double       prev = Convert.ToDouble(DR.Field <object>("CurrentAmt"));

        Button       addBtn = sender as Button;                       //finding listview item, finding textbox value
        ListViewItem lvi    = addBtn.NamingContainer as ListViewItem; //gets listViewItem containing the clicked button
        TextBox      tb     = lvi.FindControl("AddAmt") as TextBox;
        string       tbs    = tb.Text;

        if (tbs != "")
        {
            double toAdd     = Convert.ToDouble(tbs);
            double newAmount = prev + toAdd;
            DA.updateGoalCurrentAmount(id, newAmount, Convert.ToInt64(Session["account"]));
            Response.Redirect("~/Goals.aspx");
        }
    }