First go at delete functionality.

This commit is contained in:
kougyokugentou 2020-04-29 21:47:02 -07:00
parent ffde115a00
commit 3cb7d4c482
3 changed files with 175 additions and 140 deletions

252
Form1.Designer.cs generated
View File

@ -92,6 +92,7 @@
this.btnChaosMonkey = new System.Windows.Forms.Button();
this.foundStudents_comboBox = new System.Windows.Forms.ComboBox();
this.lblFoundStudents = new System.Windows.Forms.Label();
this.studentDbID = new System.Windows.Forms.NumericUpDown();
lastNameLabel = new System.Windows.Forms.Label();
firstNameLabel = new System.Windows.Forms.Label();
student_idLabel = new System.Windows.Forms.Label();
@ -114,135 +115,123 @@
this.parent_groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.studentDbID)).BeginInit();
this.SuspendLayout();
//
// lastNameLabel
//
lastNameLabel.AutoSize = true;
lastNameLabel.Location = new System.Drawing.Point(244, 48);
lastNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lastNameLabel.Location = new System.Drawing.Point(183, 38);
lastNameLabel.Name = "lastNameLabel";
lastNameLabel.Size = new System.Drawing.Size(121, 25);
lastNameLabel.Size = new System.Drawing.Size(90, 20);
lastNameLabel.TabIndex = 3;
lastNameLabel.Text = "Last Name:";
//
// firstNameLabel
//
firstNameLabel.AutoSize = true;
firstNameLabel.Location = new System.Drawing.Point(507, 48);
firstNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
firstNameLabel.Location = new System.Drawing.Point(380, 38);
firstNameLabel.Name = "firstNameLabel";
firstNameLabel.Size = new System.Drawing.Size(122, 25);
firstNameLabel.Size = new System.Drawing.Size(90, 20);
firstNameLabel.TabIndex = 4;
firstNameLabel.Text = "First Name:";
//
// student_idLabel
//
student_idLabel.AutoSize = true;
student_idLabel.Location = new System.Drawing.Point(16, 250);
student_idLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
student_idLabel.Location = new System.Drawing.Point(12, 200);
student_idLabel.Name = "student_idLabel";
student_idLabel.Size = new System.Drawing.Size(112, 25);
student_idLabel.Size = new System.Drawing.Size(83, 20);
student_idLabel.TabIndex = 6;
student_idLabel.Text = "student id:";
//
// dOBLabel
//
dOBLabel.AutoSize = true;
dOBLabel.Location = new System.Drawing.Point(13, 332);
dOBLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
dOBLabel.Location = new System.Drawing.Point(10, 266);
dOBLabel.Name = "dOBLabel";
dOBLabel.Size = new System.Drawing.Size(63, 25);
dOBLabel.Size = new System.Drawing.Size(48, 20);
dOBLabel.TabIndex = 8;
dOBLabel.Text = "DOB:";
//
// programNameLabel
//
programNameLabel.AutoSize = true;
programNameLabel.Location = new System.Drawing.Point(507, 135);
programNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
programNameLabel.Location = new System.Drawing.Point(380, 108);
programNameLabel.Name = "programNameLabel";
programNameLabel.Size = new System.Drawing.Size(99, 25);
programNameLabel.Size = new System.Drawing.Size(73, 20);
programNameLabel.TabIndex = 10;
programNameLabel.Text = "Program:";
//
// addressLabel
//
addressLabel.AutoSize = true;
addressLabel.Location = new System.Drawing.Point(247, 221);
addressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
addressLabel.Location = new System.Drawing.Point(185, 177);
addressLabel.Name = "addressLabel";
addressLabel.Size = new System.Drawing.Size(95, 25);
addressLabel.Size = new System.Drawing.Size(70, 20);
addressLabel.TabIndex = 12;
addressLabel.Text = "address:";
//
// schoolLabel
//
schoolLabel.AutoSize = true;
schoolLabel.Location = new System.Drawing.Point(507, 221);
schoolLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
schoolLabel.Location = new System.Drawing.Point(380, 177);
schoolLabel.Name = "schoolLabel";
schoolLabel.Size = new System.Drawing.Size(84, 25);
schoolLabel.Size = new System.Drawing.Size(62, 20);
schoolLabel.TabIndex = 14;
schoolLabel.Text = "School:";
//
// genderLabel
//
genderLabel.AutoSize = true;
genderLabel.Location = new System.Drawing.Point(247, 135);
genderLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
genderLabel.Location = new System.Drawing.Point(185, 108);
genderLabel.Name = "genderLabel";
genderLabel.Size = new System.Drawing.Size(89, 25);
genderLabel.Size = new System.Drawing.Size(67, 20);
genderLabel.TabIndex = 16;
genderLabel.Text = "Gender:";
//
// gradeLevelLabel
//
gradeLevelLabel.AutoSize = true;
gradeLevelLabel.Location = new System.Drawing.Point(520, 328);
gradeLevelLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
gradeLevelLabel.Location = new System.Drawing.Point(390, 262);
gradeLevelLabel.Name = "gradeLevelLabel";
gradeLevelLabel.Size = new System.Drawing.Size(135, 25);
gradeLevelLabel.Size = new System.Drawing.Size(99, 20);
gradeLevelLabel.TabIndex = 18;
gradeLevelLabel.Text = "Grade Level:";
//
// lastNameLabel1
//
lastNameLabel1.AutoSize = true;
lastNameLabel1.Location = new System.Drawing.Point(45, 52);
lastNameLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
lastNameLabel1.Location = new System.Drawing.Point(34, 42);
lastNameLabel1.Name = "lastNameLabel1";
lastNameLabel1.Size = new System.Drawing.Size(121, 25);
lastNameLabel1.Size = new System.Drawing.Size(90, 20);
lastNameLabel1.TabIndex = 0;
lastNameLabel1.Text = "Last Name:";
//
// firstNameLabel1
//
firstNameLabel1.AutoSize = true;
firstNameLabel1.Location = new System.Drawing.Point(45, 112);
firstNameLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
firstNameLabel1.Location = new System.Drawing.Point(34, 90);
firstNameLabel1.Name = "firstNameLabel1";
firstNameLabel1.Size = new System.Drawing.Size(122, 25);
firstNameLabel1.Size = new System.Drawing.Size(90, 20);
firstNameLabel1.TabIndex = 2;
firstNameLabel1.Text = "First Name:";
//
// phoneNumberLabel
//
phoneNumberLabel.AutoSize = true;
phoneNumberLabel.Location = new System.Drawing.Point(8, 174);
phoneNumberLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
phoneNumberLabel.Location = new System.Drawing.Point(6, 139);
phoneNumberLabel.Name = "phoneNumberLabel";
phoneNumberLabel.Size = new System.Drawing.Size(161, 25);
phoneNumberLabel.Size = new System.Drawing.Size(119, 20);
phoneNumberLabel.TabIndex = 4;
phoneNumberLabel.Text = "Phone Number:";
//
// emailAddressLabel
//
emailAddressLabel.AutoSize = true;
emailAddressLabel.Location = new System.Drawing.Point(13, 240);
emailAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
emailAddressLabel.Location = new System.Drawing.Point(10, 192);
emailAddressLabel.Name = "emailAddressLabel";
emailAddressLabel.Size = new System.Drawing.Size(156, 25);
emailAddressLabel.Size = new System.Drawing.Size(115, 20);
emailAddressLabel.TabIndex = 6;
emailAddressLabel.Text = "Email Address:";
//
@ -250,16 +239,15 @@
//
this.topTableLayoutPanel.ColumnCount = 2;
this.topTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.topTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 509F));
this.topTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 382F));
this.topTableLayoutPanel.Controls.Add(this.mainMenuStrip, 0, 0);
this.topTableLayoutPanel.Controls.Add(this.studentBindingNavigator, 1, 0);
this.topTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.topTableLayoutPanel.Location = new System.Drawing.Point(0, 0);
this.topTableLayoutPanel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.topTableLayoutPanel.Name = "topTableLayoutPanel";
this.topTableLayoutPanel.RowCount = 1;
this.topTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.topTableLayoutPanel.Size = new System.Drawing.Size(1323, 44);
this.topTableLayoutPanel.Size = new System.Drawing.Size(992, 35);
this.topTableLayoutPanel.TabIndex = 0;
//
// mainMenuStrip
@ -271,8 +259,8 @@
this.fileToolStripMenuItem});
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
this.mainMenuStrip.Name = "mainMenuStrip";
this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(8, 2, 0, 2);
this.mainMenuStrip.Size = new System.Drawing.Size(814, 44);
this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(6, 2, 0, 2);
this.mainMenuStrip.Size = new System.Drawing.Size(610, 35);
this.mainMenuStrip.TabIndex = 0;
this.mainMenuStrip.Text = "mainMenuStrip";
//
@ -284,19 +272,19 @@
this.reportsToolStripMenuItem,
this.exitsavesDataToolStripMenuItem});
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(72, 40);
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 31);
this.fileToolStripMenuItem.Text = "&File";
//
// newStudentToolStripMenuItem
//
this.newStudentToolStripMenuItem.Name = "newStudentToolStripMenuItem";
this.newStudentToolStripMenuItem.Size = new System.Drawing.Size(317, 44);
this.newStudentToolStripMenuItem.Size = new System.Drawing.Size(239, 34);
this.newStudentToolStripMenuItem.Text = "&New Student";
//
// saveStudentToolStripMenuItem
//
this.saveStudentToolStripMenuItem.Name = "saveStudentToolStripMenuItem";
this.saveStudentToolStripMenuItem.Size = new System.Drawing.Size(317, 44);
this.saveStudentToolStripMenuItem.Size = new System.Drawing.Size(239, 34);
this.saveStudentToolStripMenuItem.Text = "&Save Student";
//
// reportsToolStripMenuItem
@ -305,25 +293,25 @@
this.studentBySchoolToolStripMenuItem,
this.studentsByProgramToolStripMenuItem});
this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
this.reportsToolStripMenuItem.Size = new System.Drawing.Size(317, 44);
this.reportsToolStripMenuItem.Size = new System.Drawing.Size(239, 34);
this.reportsToolStripMenuItem.Text = "Reports";
//
// studentBySchoolToolStripMenuItem
//
this.studentBySchoolToolStripMenuItem.Name = "studentBySchoolToolStripMenuItem";
this.studentBySchoolToolStripMenuItem.Size = new System.Drawing.Size(373, 44);
this.studentBySchoolToolStripMenuItem.Size = new System.Drawing.Size(283, 34);
this.studentBySchoolToolStripMenuItem.Text = "Students by school";
//
// studentsByProgramToolStripMenuItem
//
this.studentsByProgramToolStripMenuItem.Name = "studentsByProgramToolStripMenuItem";
this.studentsByProgramToolStripMenuItem.Size = new System.Drawing.Size(373, 44);
this.studentsByProgramToolStripMenuItem.Size = new System.Drawing.Size(283, 34);
this.studentsByProgramToolStripMenuItem.Text = "Students by program";
//
// exitsavesDataToolStripMenuItem
//
this.exitsavesDataToolStripMenuItem.Name = "exitsavesDataToolStripMenuItem";
this.exitsavesDataToolStripMenuItem.Size = new System.Drawing.Size(317, 44);
this.exitsavesDataToolStripMenuItem.Size = new System.Drawing.Size(239, 34);
this.exitsavesDataToolStripMenuItem.Text = "E&xit (saves data)";
//
// studentBindingNavigator
@ -347,15 +335,14 @@
this.bindingNavigatorAddNewItem,
this.bindingNavigatorDeleteItem,
this.studentBindingNavigatorSaveItem});
this.studentBindingNavigator.Location = new System.Drawing.Point(814, 0);
this.studentBindingNavigator.Location = new System.Drawing.Point(610, 0);
this.studentBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
this.studentBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;
this.studentBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;
this.studentBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem;
this.studentBindingNavigator.Name = "studentBindingNavigator";
this.studentBindingNavigator.Padding = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.studentBindingNavigator.PositionItem = this.bindingNavigatorPositionItem;
this.studentBindingNavigator.Size = new System.Drawing.Size(509, 44);
this.studentBindingNavigator.Size = new System.Drawing.Size(382, 35);
this.studentBindingNavigator.TabIndex = 2;
this.studentBindingNavigator.Text = "bindingNavigator1";
//
@ -365,7 +352,7 @@
this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));
this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorAddNewItem.Text = "Add new";
//
// studentBindingSource
@ -375,7 +362,7 @@
// bindingNavigatorCountItem
//
this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
this.bindingNavigatorCountItem.Size = new System.Drawing.Size(71, 38);
this.bindingNavigatorCountItem.Size = new System.Drawing.Size(54, 30);
this.bindingNavigatorCountItem.Text = "of {0}";
this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
//
@ -385,7 +372,7 @@
this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));
this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorDeleteItem.Text = "Delete";
//
// bindingNavigatorMoveFirstItem
@ -394,7 +381,7 @@
this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));
this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorMoveFirstItem.Text = "Move first";
//
// bindingNavigatorMovePreviousItem
@ -403,13 +390,13 @@
this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")));
this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem";
this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorMovePreviousItem.Text = "Move previous";
//
// bindingNavigatorSeparator
//
this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 44);
this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 35);
//
// bindingNavigatorPositionItem
//
@ -417,14 +404,14 @@
this.bindingNavigatorPositionItem.AutoSize = false;
this.bindingNavigatorPositionItem.Font = new System.Drawing.Font("Segoe UI", 9F);
this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(65, 39);
this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 31);
this.bindingNavigatorPositionItem.Text = "0";
this.bindingNavigatorPositionItem.ToolTipText = "Current position";
//
// bindingNavigatorSeparator1
//
this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 44);
this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 35);
//
// bindingNavigatorMoveNextItem
//
@ -432,7 +419,7 @@
this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));
this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorMoveNextItem.Text = "Move next";
//
// bindingNavigatorMoveLastItem
@ -441,13 +428,13 @@
this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));
this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(46, 38);
this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(34, 30);
this.bindingNavigatorMoveLastItem.Text = "Move last";
//
// bindingNavigatorSeparator2
//
this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 44);
this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 35);
//
// studentBindingNavigatorSaveItem
//
@ -455,17 +442,16 @@
this.studentBindingNavigatorSaveItem.Enabled = false;
this.studentBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("studentBindingNavigatorSaveItem.Image")));
this.studentBindingNavigatorSaveItem.Name = "studentBindingNavigatorSaveItem";
this.studentBindingNavigatorSaveItem.Size = new System.Drawing.Size(46, 38);
this.studentBindingNavigatorSaveItem.Size = new System.Drawing.Size(34, 30);
this.studentBindingNavigatorSaveItem.Text = "Save Data";
//
// student_pictureBox
//
this.student_pictureBox.BackColor = System.Drawing.SystemColors.Window;
this.student_pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("student_pictureBox.Image")));
this.student_pictureBox.Location = new System.Drawing.Point(16, 48);
this.student_pictureBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.student_pictureBox.Location = new System.Drawing.Point(12, 38);
this.student_pictureBox.Name = "student_pictureBox";
this.student_pictureBox.Size = new System.Drawing.Size(208, 195);
this.student_pictureBox.Size = new System.Drawing.Size(156, 156);
this.student_pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.student_pictureBox.TabIndex = 1;
this.student_pictureBox.TabStop = false;
@ -475,41 +461,37 @@
// lastNameTextBox
//
this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "LastName", true));
this.lastNameTextBox.Location = new System.Drawing.Point(249, 76);
this.lastNameTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.lastNameTextBox.Location = new System.Drawing.Point(187, 61);
this.lastNameTextBox.Name = "lastNameTextBox";
this.lastNameTextBox.Size = new System.Drawing.Size(221, 31);
this.lastNameTextBox.Size = new System.Drawing.Size(167, 26);
this.lastNameTextBox.TabIndex = 4;
this.lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
//
// firstNameTextBox
//
this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "FirstName", true));
this.firstNameTextBox.Location = new System.Drawing.Point(512, 76);
this.firstNameTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.firstNameTextBox.Location = new System.Drawing.Point(384, 61);
this.firstNameTextBox.Name = "firstNameTextBox";
this.firstNameTextBox.Size = new System.Drawing.Size(235, 31);
this.firstNameTextBox.Size = new System.Drawing.Size(177, 26);
this.firstNameTextBox.TabIndex = 5;
this.firstNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
//
// student_idTextBox
//
this.student_idTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "student_id", true));
this.student_idTextBox.Location = new System.Drawing.Point(16, 279);
this.student_idTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.student_idTextBox.Location = new System.Drawing.Point(12, 223);
this.student_idTextBox.Name = "student_idTextBox";
this.student_idTextBox.Size = new System.Drawing.Size(179, 31);
this.student_idTextBox.Size = new System.Drawing.Size(135, 26);
this.student_idTextBox.TabIndex = 7;
this.student_idTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.student_idTextBox_Validating);
//
// dob_dateTimePicker
//
this.dob_dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dob_dateTimePicker.Location = new System.Drawing.Point(16, 361);
this.dob_dateTimePicker.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.dob_dateTimePicker.Location = new System.Drawing.Point(12, 289);
this.dob_dateTimePicker.MinDate = new System.DateTime(1900, 1, 1, 0, 0, 0, 0);
this.dob_dateTimePicker.Name = "dob_dateTimePicker";
this.dob_dateTimePicker.Size = new System.Drawing.Size(179, 31);
this.dob_dateTimePicker.Size = new System.Drawing.Size(135, 26);
this.dob_dateTimePicker.TabIndex = 9;
this.dob_dateTimePicker.Validating += new System.ComponentModel.CancelEventHandler(this.dob_dateTimePicker_Validating);
//
@ -517,21 +499,19 @@
//
this.programComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.programComboBox.FormattingEnabled = true;
this.programComboBox.Location = new System.Drawing.Point(512, 164);
this.programComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.programComboBox.Location = new System.Drawing.Point(384, 131);
this.programComboBox.Name = "programComboBox";
this.programComboBox.Size = new System.Drawing.Size(235, 33);
this.programComboBox.Size = new System.Drawing.Size(177, 28);
this.programComboBox.TabIndex = 11;
this.programComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating);
//
// addressTextBox
//
this.addressTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "address", true));
this.addressTextBox.Location = new System.Drawing.Point(249, 250);
this.addressTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.addressTextBox.Location = new System.Drawing.Point(187, 200);
this.addressTextBox.Multiline = true;
this.addressTextBox.Name = "addressTextBox";
this.addressTextBox.Size = new System.Drawing.Size(221, 143);
this.addressTextBox.Size = new System.Drawing.Size(167, 115);
this.addressTextBox.TabIndex = 13;
this.addressTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
//
@ -540,10 +520,9 @@
this.schoolComboBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "School.name", true));
this.schoolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.schoolComboBox.FormattingEnabled = true;
this.schoolComboBox.Location = new System.Drawing.Point(512, 250);
this.schoolComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.schoolComboBox.Location = new System.Drawing.Point(384, 200);
this.schoolComboBox.Name = "schoolComboBox";
this.schoolComboBox.Size = new System.Drawing.Size(235, 33);
this.schoolComboBox.Size = new System.Drawing.Size(177, 28);
this.schoolComboBox.TabIndex = 15;
this.schoolComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating);
//
@ -555,10 +534,9 @@
this.genderComboBox.Items.AddRange(new object[] {
"Male",
"Female"});
this.genderComboBox.Location = new System.Drawing.Point(252, 164);
this.genderComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.genderComboBox.Location = new System.Drawing.Point(189, 131);
this.genderComboBox.Name = "genderComboBox";
this.genderComboBox.Size = new System.Drawing.Size(160, 33);
this.genderComboBox.Size = new System.Drawing.Size(121, 28);
this.genderComboBox.TabIndex = 17;
this.genderComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating);
//
@ -581,19 +559,17 @@
"10",
"11",
"12"});
this.gradeLevelComboBox.Location = new System.Drawing.Point(512, 359);
this.gradeLevelComboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.gradeLevelComboBox.Location = new System.Drawing.Point(384, 287);
this.gradeLevelComboBox.Name = "gradeLevelComboBox";
this.gradeLevelComboBox.Size = new System.Drawing.Size(160, 33);
this.gradeLevelComboBox.Size = new System.Drawing.Size(121, 28);
this.gradeLevelComboBox.TabIndex = 19;
this.gradeLevelComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating);
//
// save_button
//
this.save_button.Location = new System.Drawing.Point(19, 438);
this.save_button.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.save_button.Location = new System.Drawing.Point(14, 350);
this.save_button.Name = "save_button";
this.save_button.Size = new System.Drawing.Size(139, 68);
this.save_button.Size = new System.Drawing.Size(104, 54);
this.save_button.TabIndex = 20;
this.save_button.Text = "Save";
this.save_button.UseVisualStyleBackColor = true;
@ -609,11 +585,9 @@
this.parent_groupBox.Controls.Add(this.parent_firstNameTextBox);
this.parent_groupBox.Controls.Add(lastNameLabel1);
this.parent_groupBox.Controls.Add(this.parent_lastNameTextBox);
this.parent_groupBox.Location = new System.Drawing.Point(808, 64);
this.parent_groupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.parent_groupBox.Location = new System.Drawing.Point(606, 51);
this.parent_groupBox.Name = "parent_groupBox";
this.parent_groupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.parent_groupBox.Size = new System.Drawing.Size(459, 294);
this.parent_groupBox.Size = new System.Drawing.Size(344, 235);
this.parent_groupBox.TabIndex = 21;
this.parent_groupBox.TabStop = false;
this.parent_groupBox.Text = "Parent Information";
@ -621,10 +595,9 @@
// emailAddressTextBox
//
this.emailAddressTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "Parent.EmailAddress", true));
this.emailAddressTextBox.Location = new System.Drawing.Point(175, 236);
this.emailAddressTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.emailAddressTextBox.Location = new System.Drawing.Point(131, 189);
this.emailAddressTextBox.Name = "emailAddressTextBox";
this.emailAddressTextBox.Size = new System.Drawing.Size(228, 31);
this.emailAddressTextBox.Size = new System.Drawing.Size(172, 26);
this.emailAddressTextBox.TabIndex = 7;
this.toolTips.SetToolTip(this.emailAddressTextBox, "Enter a valid email address with @");
this.emailAddressTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.emailAddressTextBox_Validating);
@ -632,8 +605,7 @@
// phoneNumberNumericUpDown
//
this.phoneNumberNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.studentBindingSource, "Parent.PhoneNumber", true));
this.phoneNumberNumericUpDown.Location = new System.Drawing.Point(175, 174);
this.phoneNumberNumericUpDown.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.phoneNumberNumericUpDown.Location = new System.Drawing.Point(131, 139);
this.phoneNumberNumericUpDown.Maximum = new decimal(new int[] {
1410065407,
2,
@ -645,7 +617,7 @@
0,
0});
this.phoneNumberNumericUpDown.Name = "phoneNumberNumericUpDown";
this.phoneNumberNumericUpDown.Size = new System.Drawing.Size(229, 31);
this.phoneNumberNumericUpDown.Size = new System.Drawing.Size(172, 26);
this.phoneNumberNumericUpDown.TabIndex = 5;
this.toolTips.SetToolTip(this.phoneNumberNumericUpDown, "Enter 9 digit phone number with no symbols.");
this.phoneNumberNumericUpDown.Value = new decimal(new int[] {
@ -658,29 +630,26 @@
// parent_firstNameTextBox
//
this.parent_firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "Parent.FirstName", true));
this.parent_firstNameTextBox.Location = new System.Drawing.Point(173, 109);
this.parent_firstNameTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.parent_firstNameTextBox.Location = new System.Drawing.Point(130, 87);
this.parent_firstNameTextBox.Name = "parent_firstNameTextBox";
this.parent_firstNameTextBox.Size = new System.Drawing.Size(229, 31);
this.parent_firstNameTextBox.Size = new System.Drawing.Size(173, 26);
this.parent_firstNameTextBox.TabIndex = 3;
this.parent_firstNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
//
// parent_lastNameTextBox
//
this.parent_lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "Parent.LastName", true));
this.parent_lastNameTextBox.Location = new System.Drawing.Point(173, 49);
this.parent_lastNameTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.parent_lastNameTextBox.Location = new System.Drawing.Point(130, 39);
this.parent_lastNameTextBox.Name = "parent_lastNameTextBox";
this.parent_lastNameTextBox.Size = new System.Drawing.Size(229, 31);
this.parent_lastNameTextBox.Size = new System.Drawing.Size(173, 26);
this.parent_lastNameTextBox.TabIndex = 1;
this.parent_lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating);
//
// clear_button
//
this.clear_button.Location = new System.Drawing.Point(225, 438);
this.clear_button.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.clear_button.Location = new System.Drawing.Point(169, 350);
this.clear_button.Name = "clear_button";
this.clear_button.Size = new System.Drawing.Size(155, 68);
this.clear_button.Size = new System.Drawing.Size(116, 54);
this.clear_button.TabIndex = 22;
this.clear_button.Text = "Clear form for new student";
this.clear_button.UseVisualStyleBackColor = true;
@ -688,13 +657,13 @@
//
// delete_button
//
this.delete_button.Location = new System.Drawing.Point(427, 438);
this.delete_button.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.delete_button.Location = new System.Drawing.Point(320, 350);
this.delete_button.Name = "delete_button";
this.delete_button.Size = new System.Drawing.Size(139, 68);
this.delete_button.Size = new System.Drawing.Size(104, 54);
this.delete_button.TabIndex = 23;
this.delete_button.Text = "Delete";
this.delete_button.UseVisualStyleBackColor = true;
this.delete_button.Click += new System.EventHandler(this.delete_button_Click);
//
// pic_openFileDialog
//
@ -707,19 +676,17 @@
// lblSearch
//
this.lblSearch.AutoSize = true;
this.lblSearch.Location = new System.Drawing.Point(816, 369);
this.lblSearch.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblSearch.Location = new System.Drawing.Point(612, 295);
this.lblSearch.Name = "lblSearch";
this.lblSearch.Size = new System.Drawing.Size(304, 25);
this.lblSearch.Size = new System.Drawing.Size(226, 20);
this.lblSearch.TabIndex = 24;
this.lblSearch.Text = "Search Student by Last Name:";
//
// search_textBox
//
this.search_textBox.Location = new System.Drawing.Point(821, 398);
this.search_textBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.search_textBox.Location = new System.Drawing.Point(616, 318);
this.search_textBox.Name = "search_textBox";
this.search_textBox.Size = new System.Drawing.Size(377, 31);
this.search_textBox.Size = new System.Drawing.Size(284, 26);
this.search_textBox.TabIndex = 25;
this.toolTips.SetToolTip(this.search_textBox, "Type last name of student and hit enter");
this.search_textBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.search_textBox_KeyDown);
@ -730,10 +697,9 @@
//
// btnChaosMonkey
//
this.btnChaosMonkey.Location = new System.Drawing.Point(633, 438);
this.btnChaosMonkey.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnChaosMonkey.Location = new System.Drawing.Point(475, 350);
this.btnChaosMonkey.Name = "btnChaosMonkey";
this.btnChaosMonkey.Size = new System.Drawing.Size(128, 82);
this.btnChaosMonkey.Size = new System.Drawing.Size(96, 66);
this.btnChaosMonkey.TabIndex = 26;
this.btnChaosMonkey.Text = "CHAOS MONKEY";
this.btnChaosMonkey.UseVisualStyleBackColor = true;
@ -742,10 +708,9 @@
// foundStudents_comboBox
//
this.foundStudents_comboBox.FormattingEnabled = true;
this.foundStudents_comboBox.Location = new System.Drawing.Point(827, 470);
this.foundStudents_comboBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.foundStudents_comboBox.Location = new System.Drawing.Point(620, 376);
this.foundStudents_comboBox.Name = "foundStudents_comboBox";
this.foundStudents_comboBox.Size = new System.Drawing.Size(377, 33);
this.foundStudents_comboBox.Size = new System.Drawing.Size(284, 28);
this.foundStudents_comboBox.TabIndex = 27;
this.foundStudents_comboBox.SelectionChangeCommitted += new System.EventHandler(this.foundStudents_comboBox_SelectionChangeCommitted);
this.foundStudents_comboBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.foundStudents_comboBox_KeyDown);
@ -753,18 +718,26 @@
// lblFoundStudents
//
this.lblFoundStudents.AutoSize = true;
this.lblFoundStudents.Location = new System.Drawing.Point(816, 438);
this.lblFoundStudents.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblFoundStudents.Location = new System.Drawing.Point(612, 350);
this.lblFoundStudents.Name = "lblFoundStudents";
this.lblFoundStudents.Size = new System.Drawing.Size(170, 25);
this.lblFoundStudents.Size = new System.Drawing.Size(128, 20);
this.lblFoundStudents.TabIndex = 28;
this.lblFoundStudents.Text = "Found Students:";
//
// studentDbID
//
this.studentDbID.Location = new System.Drawing.Point(933, 32);
this.studentDbID.Name = "studentDbID";
this.studentDbID.Size = new System.Drawing.Size(47, 26);
this.studentDbID.TabIndex = 8;
this.studentDbID.Visible = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1323, 562);
this.ClientSize = new System.Drawing.Size(992, 450);
this.Controls.Add(this.studentDbID);
this.Controls.Add(this.lblFoundStudents);
this.Controls.Add(this.foundStudents_comboBox);
this.Controls.Add(this.btnChaosMonkey);
@ -796,7 +769,6 @@
this.Controls.Add(this.topTableLayoutPanel);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.mainMenuStrip;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "Form1";
this.Text = "KentYouthDB";
this.Load += new System.EventHandler(this.Form1_Load);
@ -813,6 +785,7 @@
this.parent_groupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.studentDbID)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -869,6 +842,7 @@
private System.Windows.Forms.Button btnChaosMonkey;
private System.Windows.Forms.Label lblFoundStudents;
private System.Windows.Forms.ComboBox foundStudents_comboBox;
private System.Windows.Forms.NumericUpDown studentDbID;
}
}

View File

@ -161,6 +161,7 @@ namespace DBWizard
student.parent_id = SqliteDataAccess.InsertNewParent(parent);
SqliteDataAccess.InsertNewStudent(student);
MessageBox.Show("Student successfully added");
ClearForm();
}
}
@ -310,6 +311,8 @@ namespace DBWizard
phoneNumberNumericUpDown.Value = phoneNumberNumericUpDown.Minimum;
emailAddressTextBox.Text = string.Empty;
ClearFoundStudentsComboBox();
//clear form errors
foreach (Control c in errorProvider1.ContainerControl.Controls)
{
@ -356,9 +359,10 @@ namespace DBWizard
//The found students combo box is not completely
//cleared upon clearform. Do this now.
ClearFoundStudentsComboBox();
//ClearFoundStudentsComboBox();
//Populate the form based on the found student.
studentDbID.Value = foundStudent.id;
lastNameTextBox.Text = foundStudent.LastName;
firstNameTextBox.Text = foundStudent.FirstName;
programComboBox.SelectedIndex = foundStudent.program_id;
@ -384,5 +388,23 @@ namespace DBWizard
phoneNumberNumericUpDown.Value = stuParent.PhoneNumber;
emailAddressTextBox.Text = stuParent.EmailAddress;
} //foundStudents_comboBox_SelectionChangeCommitted
private void delete_button_Click(object sender, EventArgs e)
{
if (studentDbID.Value <= 0)
return;
//collect up the student and parent.
Student stu = SqliteDataAccess.GetStudentByDbID(Int32.Parse(studentDbID.Value.ToString()));
Parent par = SqliteDataAccess.GetParentByID(stu.parent_id);
//Nerf 'em.
SqliteDataAccess.DeleteStudent(stu);
SqliteDataAccess.DeleteParent(par);
//Dispose of the objects.
ClearForm();
MessageBox.Show("Student deleted from database.");
}
} //Form1
}

View File

@ -24,6 +24,19 @@ namespace DBWizard
}
}
//Used in delete function
public Student GetStudentByDbID(int dbid_in)
{
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
string strQuery = "SELECT * FROM students WHERE id=@id";
var output = cnn.Query<Student>(strQuery, new { id = dbid_in });
var stuList = output.ToList();
Student student = stuList[0];
return student;
}
}
//Can also be used for search function.
public List<Student> FindStudentByStudentId(string studentid_in)
{
@ -69,6 +82,19 @@ namespace DBWizard
}
}
internal void DeleteStudent(Student stu_in)
{
//protect query from 0 or negative indexes.
if (stu_in.id <= 0)
return;
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
string strQuery = "DELETE FROM STUDENTS WHERE id=@id;";
cnn.Execute(strQuery, stu_in);
}
}
/* Inserts a new parent.
* returns parent id as the new row # it just inserted.
*/
@ -138,6 +164,19 @@ namespace DBWizard
}
}
internal void DeleteParent(Parent par_in)
{
//protect query from 0 or negative indexes.
if (par_in.parent_id <= 0)
return;
using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
{
string strQuery = "DELETE FROM Parents WHERE parent_id=@parent_id;";
cnn.Execute(strQuery, par_in);
}
}
private static string LoadConnectionString(string id = "Default")
{
return ConfigurationManager.ConnectionStrings[id].ConnectionString;