protected void RemoveChild(object sender, EventArgs e) { String ID = Request.QueryString["ID"]; String[] name = ChildrenDropDown.Text.Split(' '); String firstName = name[0]; String lastName = name[1]; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); con.Open(); string removeQuery = ("DELETE FROM Children WHERE Id = @CurrentUser " + "and FirstName = @FirstName and LastName = @LastName "); SqlCommand Remove = new SqlCommand(removeQuery, con); Remove.Parameters.AddWithValue("@CurrentUser", ID);// "*****@*****.**"); Remove.Parameters.AddWithValue("@FirstName", firstName); Remove.Parameters.AddWithValue("@LastName", lastName); SqlDataReader addHoursReader = Remove.ExecuteReader(); ErrorMessage.Text = "Child Successfully Removed"; ChildrenDropDown.DataBind(); EditChildrenDropDown.DataBind(); con.Close(); }
protected void ChildFirst_Rename(object sender, EventArgs e) { String ID = Request.QueryString["ID"]; String Name = ChildFirst.Text; String[] FullName = EditChildrenDropDown.Text.Split(' '); if (ChildFirst.Text == "" || ChildFirst.Text == FullName[0]) { ErrorMessage.Text = "Please eneter a valid first name"; } else { UpdateVariableDB(ID, "Children", "FirstName", Name, FullName); ErrorMessage.Text = "Sucessfully Renamed: " + EditChildrenDropDown.Text + " to: " + Name; EditChildrenDropDown.DataBind(); ChildrenDropDown.DataBind(); ChildFirst.Text = ""; } }