private void btnaddstudent_Click(object sender, EventArgs e) { this.Hide(); AddStudent addnew = new AddStudent(); addnew.Show(); }
private void studentrecord_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (studentrecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Edit") { Class1.stuId = Convert.ToInt32(studentrecord.Rows[e.RowIndex].Cells[0].Value); this.Hide(); AddStudent registerStudent = new AddStudent(); registerStudent.Show(); } if (studentrecord.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Delete") { int studentId = Convert.ToInt32(studentrecord.Rows[e.RowIndex].Cells[0].Value); if (MessageBox.Show("Are you sure to perform this action!?" + studentrecord.Rows[e.RowIndex].Cells[1].Value.ToString() + "?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { SqlConnection newconn = new SqlConnection(con); newconn.Open(); SqlCommand command = new SqlCommand("delete from Student where Id = '" + studentId + "'", newconn); command.ExecuteNonQuery(); newconn.Close(); this.studentTableAdapter.Fill(this.projectBDataSet.Student); } } }
private void 学生用户ToolStripMenuItem_Click(object sender, EventArgs e) { AddStudent add = new AddStudent(); DialogResult dialogResult = add.ShowDialog(); }