Beispiel #1
0
    //Commit Button Actions
    protected void CommitButton_Click(object sender, EventArgs e)
    {
        name     = SchoolNameTextbox.Text;
        nickname = SchoolNicknameTextbox.Text;
        address  = SchoolAddressTextbox.Text;

        //School validation
        if (SchoolNameTextbox.Text == " " || SchoolNameTextbox.Text == "")
        {
            MessageBox.Show("Please Enter a School Name!");
        }
        else if (SchoolNicknameTextbox.Text == " " || SchoolNicknameTextbox.Text == "")
        {
            MessageBox.Show("Please Enter a School NickName!");
        }

        else if (SchoolAddressTextbox.Text == " " || SchoolAddressTextbox.Text == "")
        {
            MessageBox.Show("Please Enter a School Address!");
        }

        else
        {
            Schools school = new Schools(schoolID, name, nickname, address);
            //Establishes connection
            //Open database connection
            sc.Open();
            System.Data.SqlClient.SqlCommand insert = new System.Data.SqlClient.SqlCommand("LeandraRiosLab3", sc);
            insert.Connection = sc;

            insert.CommandType = CommandType.StoredProcedure;
            insert.Parameters.AddWithValue("@schoolName", name);
            insert.Parameters.AddWithValue("@schoolNickname", nickname);
            insert.Parameters.AddWithValue("@schoolAddress", address);
            insert.Parameters.AddWithValue("@lastUpdatedBy", school.getLastUpdatedBy());
            insert.Parameters.AddWithValue("@lastUpdated", school.getLastUpdated());
            insert.ExecuteNonQuery();

            sc.Close();
        }
    }