コード例 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            RegisterForm register = new RegisterForm();

            this.Hide();
            register.Show();
        }
コード例 #2
0
 private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Update")
     {
         updatesource.var = Convert.ToInt32(DataGridView1.Rows[e.RowIndex].Cells[0].Value);
         this.Hide();
         RegisterForm registerStudent = new RegisterForm();
         registerStudent.Show();
     }
     if (DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete")
     {
         int stdId = Convert.ToInt32(DataGridView1.Rows[e.RowIndex].Cells[0].Value);
         if (MessageBox.Show("Do you want to delete " + DataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             con.Open();
             SqlCommand command = new SqlCommand("DELETE FROM Student WHERE Id  = '" + stdId + "'", con);
             command.ExecuteNonQuery();
             con.Close();
             this.studentTableAdapter.Fill(this.projectBDataSet1.Student);
         }
     }
 }