private void StudentInsertForm_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'libraryDataSet1.Student' table. You can move, or remove it, as needed. // this.studentTableAdapter.Fill(this.libraryDataSet1.Student); label7.Hide(); // TODO: This line of code loads data into the 'sessionDataSet.Session' table. You can move, or remove it, as needed. this.sessionTableAdapter.Fill(this.sessionDataSet.Session); SessionComboBox.SelectedValue = 0; DepartmentComboBox.SelectedValue = 0; label4.Hide(); label5.Hide(); label6.Hide(); label16.Hide(); label15.Hide(); this.Height = 650; label9.Hide(); label11.Hide(); label12.Hide(); StudentAddForm.Hide(); label8.Hide(); StudentGridView.ForeColor = Color.Black; LoadStudentGridView(); using (var con = new SqlConnection(@"data source=.\SQLEXPRESS;DATABASE=Library ;Integrated Security=true;")) { var cmd = new SqlCommand("select DepartmentShortName,DepartmentFullName from Department", con); con.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { try { var departmenShortName = reader.GetString(0); var departmenFullName = reader.GetString(1); string departmenName = ""; departmenName = departmenShortName != "" ? departmenShortName : departmenFullName; DepartmentComboBox.Items.Add(departmenName); } catch (Exception exception) { MessageBox.Show(exception.Message); } } } exitAddToolStripMenuItem.Enabled = false; }
private void exitAddToolStripMenuItem_Click(object sender, EventArgs e) { exitAddToolStripMenuItem.Enabled = false; addToolStripMenuItem.Enabled = true; StudentAddForm.Hide(); this.Height = 650; StudentGridView.Show(); SearchButton.Show(); StudentSearctBox.Show(); label10.Show(); StudentDeleteButton.Show(); label11.Hide(); label12.Hide(); FirstPageButton.Show(); NextPageButton.Show(); PreviousButton.Show(); LastPageButton.Show(); }