From 9b34935a4781b620cb4cbdc5379d25baccd70831 Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Thu, 30 Apr 2020 22:41:08 -0700 Subject: [PATCH] Documentation and code cleanup/organization --- Form1.Designer.cs | 238 +++++++++++++++++++------------------------- Form1.cs | 46 +++++---- SqliteDataAccess.cs | 92 ++++++++++++++--- 3 files changed, 206 insertions(+), 170 deletions(-) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index 13b088c..8e22808 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -55,6 +55,7 @@ this.exitsavesDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.student_pictureBox = new System.Windows.Forms.PictureBox(); this.lastNameTextBox = new System.Windows.Forms.TextBox(); + this.studentBindingSource = new System.Windows.Forms.BindingSource(this.components); this.firstNameTextBox = new System.Windows.Forms.TextBox(); this.student_idTextBox = new System.Windows.Forms.TextBox(); this.dob_dateTimePicker = new System.Windows.Forms.DateTimePicker(); @@ -81,7 +82,6 @@ this.lblFoundStudents = new System.Windows.Forms.Label(); this.studentDbID = new System.Windows.Forms.NumericUpDown(); this.panel1 = new System.Windows.Forms.Panel(); - this.studentBindingSource = new System.Windows.Forms.BindingSource(this.components); lastNameLabel = new System.Windows.Forms.Label(); firstNameLabel = new System.Windows.Forms.Label(); student_idLabel = new System.Windows.Forms.Label(); @@ -98,12 +98,12 @@ this.topTableLayoutPanel.SuspendLayout(); this.mainMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.student_pictureBox)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).BeginInit(); this.parent_groupBox.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.studentDbID)).BeginInit(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).BeginInit(); this.SuspendLayout(); // // lastNameLabel @@ -111,10 +111,9 @@ lastNameLabel.AutoSize = true; lastNameLabel.BackColor = System.Drawing.Color.Transparent; lastNameLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - lastNameLabel.Location = new System.Drawing.Point(629, 7); - lastNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lastNameLabel.Location = new System.Drawing.Point(472, 6); lastNameLabel.Name = "lastNameLabel"; - lastNameLabel.Size = new System.Drawing.Size(122, 35); + lastNameLabel.Size = new System.Drawing.Size(93, 26); lastNameLabel.TabIndex = 3; lastNameLabel.Text = "Last Name:"; // @@ -123,10 +122,9 @@ firstNameLabel.AutoSize = true; firstNameLabel.BackColor = System.Drawing.Color.Transparent; firstNameLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - firstNameLabel.Location = new System.Drawing.Point(320, 7); - firstNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + firstNameLabel.Location = new System.Drawing.Point(240, 6); firstNameLabel.Name = "firstNameLabel"; - firstNameLabel.Size = new System.Drawing.Size(126, 35); + firstNameLabel.Size = new System.Drawing.Size(97, 26); firstNameLabel.TabIndex = 4; firstNameLabel.Text = "First Name:"; // @@ -135,10 +133,9 @@ student_idLabel.AutoSize = true; student_idLabel.BackColor = System.Drawing.Color.Transparent; student_idLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - student_idLabel.Location = new System.Drawing.Point(49, 228); - student_idLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + student_idLabel.Location = new System.Drawing.Point(37, 182); student_idLabel.Name = "student_idLabel"; - student_idLabel.Size = new System.Drawing.Size(123, 35); + student_idLabel.Size = new System.Drawing.Size(93, 26); student_idLabel.TabIndex = 6; student_idLabel.Text = "Student ID:"; // @@ -147,10 +144,9 @@ dOBLabel.AutoSize = true; dOBLabel.BackColor = System.Drawing.Color.Transparent; dOBLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - dOBLabel.Location = new System.Drawing.Point(320, 98); - dOBLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + dOBLabel.Location = new System.Drawing.Point(240, 78); dOBLabel.Name = "dOBLabel"; - dOBLabel.Size = new System.Drawing.Size(65, 35); + dOBLabel.Size = new System.Drawing.Size(49, 26); dOBLabel.TabIndex = 8; dOBLabel.Text = "DOB:"; // @@ -159,10 +155,9 @@ programNameLabel.AutoSize = true; programNameLabel.BackColor = System.Drawing.Color.Transparent; programNameLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - programNameLabel.Location = new System.Drawing.Point(629, 98); - programNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + programNameLabel.Location = new System.Drawing.Point(472, 78); programNameLabel.Name = "programNameLabel"; - programNameLabel.Size = new System.Drawing.Size(104, 35); + programNameLabel.Size = new System.Drawing.Size(79, 26); programNameLabel.TabIndex = 10; programNameLabel.Text = "Program:"; // @@ -171,10 +166,9 @@ addressLabel.AutoSize = true; addressLabel.BackColor = System.Drawing.Color.Transparent; addressLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - addressLabel.Location = new System.Drawing.Point(320, 275); - addressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + addressLabel.Location = new System.Drawing.Point(240, 220); addressLabel.Name = "addressLabel"; - addressLabel.Size = new System.Drawing.Size(96, 35); + addressLabel.Size = new System.Drawing.Size(74, 26); addressLabel.TabIndex = 12; addressLabel.Text = "Address:"; // @@ -183,10 +177,9 @@ schoolLabel.AutoSize = true; schoolLabel.BackColor = System.Drawing.Color.Transparent; schoolLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - schoolLabel.Location = new System.Drawing.Point(629, 187); - schoolLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + schoolLabel.Location = new System.Drawing.Point(472, 150); schoolLabel.Name = "schoolLabel"; - schoolLabel.Size = new System.Drawing.Size(84, 35); + schoolLabel.Size = new System.Drawing.Size(64, 26); schoolLabel.TabIndex = 14; schoolLabel.Text = "School:"; // @@ -195,10 +188,9 @@ genderLabel.AutoSize = true; genderLabel.BackColor = System.Drawing.Color.Transparent; genderLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - genderLabel.Location = new System.Drawing.Point(320, 187); - genderLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + genderLabel.Location = new System.Drawing.Point(240, 150); genderLabel.Name = "genderLabel"; - genderLabel.Size = new System.Drawing.Size(91, 35); + genderLabel.Size = new System.Drawing.Size(69, 26); genderLabel.TabIndex = 16; genderLabel.Text = "Gender:"; // @@ -207,10 +199,9 @@ gradeLevelLabel.AutoSize = true; gradeLevelLabel.BackColor = System.Drawing.Color.Transparent; gradeLevelLabel.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - gradeLevelLabel.Location = new System.Drawing.Point(629, 275); - gradeLevelLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + gradeLevelLabel.Location = new System.Drawing.Point(472, 220); gradeLevelLabel.Name = "gradeLevelLabel"; - gradeLevelLabel.Size = new System.Drawing.Size(134, 35); + gradeLevelLabel.Size = new System.Drawing.Size(101, 26); gradeLevelLabel.TabIndex = 18; gradeLevelLabel.Text = "Grade Level:"; // @@ -218,10 +209,9 @@ // lastNameLabel1.AutoSize = true; lastNameLabel1.BackColor = System.Drawing.Color.Transparent; - lastNameLabel1.Location = new System.Drawing.Point(13, 117); - lastNameLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + lastNameLabel1.Location = new System.Drawing.Point(10, 94); lastNameLabel1.Name = "lastNameLabel1"; - lastNameLabel1.Size = new System.Drawing.Size(122, 35); + lastNameLabel1.Size = new System.Drawing.Size(93, 26); lastNameLabel1.TabIndex = 0; lastNameLabel1.Text = "Last Name:"; // @@ -229,10 +219,9 @@ // firstNameLabel1.AutoSize = true; firstNameLabel1.BackColor = System.Drawing.Color.Transparent; - firstNameLabel1.Location = new System.Drawing.Point(13, 63); - firstNameLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + firstNameLabel1.Location = new System.Drawing.Point(10, 50); firstNameLabel1.Name = "firstNameLabel1"; - firstNameLabel1.Size = new System.Drawing.Size(126, 35); + firstNameLabel1.Size = new System.Drawing.Size(97, 26); firstNameLabel1.TabIndex = 2; firstNameLabel1.Text = "First Name:"; // @@ -240,10 +229,9 @@ // phoneNumberLabel.AutoSize = true; phoneNumberLabel.BackColor = System.Drawing.Color.Transparent; - phoneNumberLabel.Location = new System.Drawing.Point(13, 174); - phoneNumberLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + phoneNumberLabel.Location = new System.Drawing.Point(10, 139); phoneNumberLabel.Name = "phoneNumberLabel"; - phoneNumberLabel.Size = new System.Drawing.Size(164, 35); + phoneNumberLabel.Size = new System.Drawing.Size(124, 26); phoneNumberLabel.TabIndex = 4; phoneNumberLabel.Text = "Phone Number:"; // @@ -251,10 +239,9 @@ // emailAddressLabel.AutoSize = true; emailAddressLabel.BackColor = System.Drawing.Color.Transparent; - emailAddressLabel.Location = new System.Drawing.Point(13, 236); - emailAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + emailAddressLabel.Location = new System.Drawing.Point(10, 189); emailAddressLabel.Name = "emailAddressLabel"; - emailAddressLabel.Size = new System.Drawing.Size(157, 35); + emailAddressLabel.Size = new System.Drawing.Size(119, 26); emailAddressLabel.TabIndex = 6; emailAddressLabel.Text = "Email Address:"; // @@ -265,11 +252,10 @@ this.topTableLayoutPanel.Controls.Add(this.mainMenuStrip, 0, 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); 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(1424, 44); + this.topTableLayoutPanel.Size = new System.Drawing.Size(1068, 35); this.topTableLayoutPanel.TabIndex = 0; // // mainMenuStrip @@ -277,13 +263,14 @@ this.mainMenuStrip.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.mainMenuStrip.Dock = System.Windows.Forms.DockStyle.None; + this.mainMenuStrip.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2); this.mainMenuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); this.mainMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 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(1424, 40); + this.mainMenuStrip.Padding = new System.Windows.Forms.Padding(6, 2, 0, 2); + this.mainMenuStrip.Size = new System.Drawing.Size(1068, 33); this.mainMenuStrip.TabIndex = 0; this.mainMenuStrip.Text = "mainMenuStrip"; // @@ -296,20 +283,20 @@ this.exitWithoutSavingToolStripMenuItem, this.exitsavesDataToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(72, 36); + this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 29); this.fileToolStripMenuItem.Text = "&File"; // // newStudentToolStripMenuItem // this.newStudentToolStripMenuItem.Name = "newStudentToolStripMenuItem"; - this.newStudentToolStripMenuItem.Size = new System.Drawing.Size(349, 44); + this.newStudentToolStripMenuItem.Size = new System.Drawing.Size(262, 34); this.newStudentToolStripMenuItem.Text = "&New Student"; this.newStudentToolStripMenuItem.Click += new System.EventHandler(this.newStudentToolStripMenuItem_Click); // // saveStudentToolStripMenuItem // this.saveStudentToolStripMenuItem.Name = "saveStudentToolStripMenuItem"; - this.saveStudentToolStripMenuItem.Size = new System.Drawing.Size(349, 44); + this.saveStudentToolStripMenuItem.Size = new System.Drawing.Size(262, 34); this.saveStudentToolStripMenuItem.Text = "&Save Student"; this.saveStudentToolStripMenuItem.Click += new System.EventHandler(this.saveStudentToolStripMenuItem_Click); // @@ -319,32 +306,32 @@ this.studentBySchoolToolStripMenuItem, this.studentsByProgramToolStripMenuItem}); this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; - this.reportsToolStripMenuItem.Size = new System.Drawing.Size(349, 44); + this.reportsToolStripMenuItem.Size = new System.Drawing.Size(262, 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"; // // exitWithoutSavingToolStripMenuItem // this.exitWithoutSavingToolStripMenuItem.Name = "exitWithoutSavingToolStripMenuItem"; - this.exitWithoutSavingToolStripMenuItem.Size = new System.Drawing.Size(349, 44); + this.exitWithoutSavingToolStripMenuItem.Size = new System.Drawing.Size(262, 34); this.exitWithoutSavingToolStripMenuItem.Text = "Exit without saving"; this.exitWithoutSavingToolStripMenuItem.Click += new System.EventHandler(this.exitWithoutSavingToolStripMenuItem_Click); // // exitsavesDataToolStripMenuItem // this.exitsavesDataToolStripMenuItem.Name = "exitsavesDataToolStripMenuItem"; - this.exitsavesDataToolStripMenuItem.Size = new System.Drawing.Size(349, 44); + this.exitsavesDataToolStripMenuItem.Size = new System.Drawing.Size(262, 34); this.exitsavesDataToolStripMenuItem.Text = "E&xit (saves data)"; this.exitsavesDataToolStripMenuItem.Click += new System.EventHandler(this.exitsavesDataToolStripMenuItem_Click); // @@ -352,35 +339,36 @@ // 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(55, 27); - this.student_pictureBox.Margin = new System.Windows.Forms.Padding(4); + this.student_pictureBox.Location = new System.Drawing.Point(41, 22); 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; this.student_pictureBox.Tag = "DefaultImage"; - this.student_pictureBox.Click += new System.EventHandler(this.pictureBox1_Click); + this.student_pictureBox.DoubleClick += new System.EventHandler(this.student_pictureBox_DoubleClick); // // lastNameTextBox // this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "LastName", true)); this.lastNameTextBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lastNameTextBox.Location = new System.Drawing.Point(635, 46); - this.lastNameTextBox.Margin = new System.Windows.Forms.Padding(4); + this.lastNameTextBox.Location = new System.Drawing.Point(476, 37); this.lastNameTextBox.Name = "lastNameTextBox"; - this.lastNameTextBox.Size = new System.Drawing.Size(221, 38); + this.lastNameTextBox.Size = new System.Drawing.Size(167, 30); this.lastNameTextBox.TabIndex = 4; this.lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating); // + // studentBindingSource + // + this.studentBindingSource.DataSource = typeof(DBWizard.Models.Student); + // // firstNameTextBox // this.firstNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "FirstName", true)); this.firstNameTextBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.firstNameTextBox.Location = new System.Drawing.Point(324, 46); - this.firstNameTextBox.Margin = new System.Windows.Forms.Padding(4); + this.firstNameTextBox.Location = new System.Drawing.Point(243, 37); this.firstNameTextBox.Name = "firstNameTextBox"; - this.firstNameTextBox.Size = new System.Drawing.Size(235, 38); + this.firstNameTextBox.Size = new System.Drawing.Size(177, 30); this.firstNameTextBox.TabIndex = 5; this.firstNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating); // @@ -388,10 +376,9 @@ // this.student_idTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "student_id", true)); this.student_idTextBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.student_idTextBox.Location = new System.Drawing.Point(55, 269); - this.student_idTextBox.Margin = new System.Windows.Forms.Padding(4); + this.student_idTextBox.Location = new System.Drawing.Point(41, 215); this.student_idTextBox.Name = "student_idTextBox"; - this.student_idTextBox.Size = new System.Drawing.Size(179, 38); + this.student_idTextBox.Size = new System.Drawing.Size(135, 30); this.student_idTextBox.TabIndex = 7; this.student_idTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.student_idTextBox_Validating); // @@ -399,11 +386,10 @@ // this.dob_dateTimePicker.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.dob_dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Short; - this.dob_dateTimePicker.Location = new System.Drawing.Point(326, 136); - this.dob_dateTimePicker.Margin = new System.Windows.Forms.Padding(4); + this.dob_dateTimePicker.Location = new System.Drawing.Point(244, 109); 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, 38); + this.dob_dateTimePicker.Size = new System.Drawing.Size(135, 30); this.dob_dateTimePicker.TabIndex = 9; this.dob_dateTimePicker.Validating += new System.ComponentModel.CancelEventHandler(this.dob_dateTimePicker_Validating); // @@ -412,10 +398,9 @@ this.programComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.programComboBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.programComboBox.FormattingEnabled = true; - this.programComboBox.Location = new System.Drawing.Point(635, 131); - this.programComboBox.Margin = new System.Windows.Forms.Padding(4); + this.programComboBox.Location = new System.Drawing.Point(476, 105); this.programComboBox.Name = "programComboBox"; - this.programComboBox.Size = new System.Drawing.Size(235, 43); + this.programComboBox.Size = new System.Drawing.Size(177, 34); this.programComboBox.TabIndex = 11; this.programComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating); // @@ -423,11 +408,10 @@ // this.addressTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "address", true)); this.addressTextBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.addressTextBox.Location = new System.Drawing.Point(326, 314); - this.addressTextBox.Margin = new System.Windows.Forms.Padding(4); + this.addressTextBox.Location = new System.Drawing.Point(244, 251); this.addressTextBox.Multiline = true; this.addressTextBox.Name = "addressTextBox"; - this.addressTextBox.Size = new System.Drawing.Size(221, 81); + this.addressTextBox.Size = new System.Drawing.Size(167, 66); this.addressTextBox.TabIndex = 13; this.addressTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating); // @@ -437,10 +421,9 @@ this.schoolComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.schoolComboBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.schoolComboBox.FormattingEnabled = true; - this.schoolComboBox.Location = new System.Drawing.Point(635, 225); - this.schoolComboBox.Margin = new System.Windows.Forms.Padding(4); + this.schoolComboBox.Location = new System.Drawing.Point(476, 180); this.schoolComboBox.Name = "schoolComboBox"; - this.schoolComboBox.Size = new System.Drawing.Size(235, 43); + this.schoolComboBox.Size = new System.Drawing.Size(177, 34); this.schoolComboBox.TabIndex = 15; this.schoolComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating); // @@ -453,10 +436,9 @@ this.genderComboBox.Items.AddRange(new object[] { "Male", "Female"}); - this.genderComboBox.Location = new System.Drawing.Point(326, 225); - this.genderComboBox.Margin = new System.Windows.Forms.Padding(4); + this.genderComboBox.Location = new System.Drawing.Point(244, 180); this.genderComboBox.Name = "genderComboBox"; - this.genderComboBox.Size = new System.Drawing.Size(160, 43); + this.genderComboBox.Size = new System.Drawing.Size(121, 34); this.genderComboBox.TabIndex = 17; this.genderComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating); // @@ -480,20 +462,18 @@ "10", "11", "12"}); - this.gradeLevelComboBox.Location = new System.Drawing.Point(635, 314); - this.gradeLevelComboBox.Margin = new System.Windows.Forms.Padding(4); + this.gradeLevelComboBox.Location = new System.Drawing.Point(476, 251); this.gradeLevelComboBox.Name = "gradeLevelComboBox"; - this.gradeLevelComboBox.Size = new System.Drawing.Size(160, 43); + this.gradeLevelComboBox.Size = new System.Drawing.Size(121, 34); this.gradeLevelComboBox.TabIndex = 19; this.gradeLevelComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.ComboBox_Validating); // // save_button // this.save_button.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.save_button.Location = new System.Drawing.Point(105, 457); - this.save_button.Margin = new System.Windows.Forms.Padding(4); + this.save_button.Location = new System.Drawing.Point(79, 366); 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; @@ -512,11 +492,9 @@ this.parent_groupBox.Controls.Add(this.parent_lastNameTextBox); this.parent_groupBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.parent_groupBox.ForeColor = System.Drawing.SystemColors.ControlText; - this.parent_groupBox.Location = new System.Drawing.Point(917, 225); - this.parent_groupBox.Margin = new System.Windows.Forms.Padding(4); + this.parent_groupBox.Location = new System.Drawing.Point(688, 180); this.parent_groupBox.Name = "parent_groupBox"; - this.parent_groupBox.Padding = new System.Windows.Forms.Padding(4); - this.parent_groupBox.Size = new System.Drawing.Size(464, 311); + this.parent_groupBox.Size = new System.Drawing.Size(348, 249); this.parent_groupBox.TabIndex = 21; this.parent_groupBox.TabStop = false; this.parent_groupBox.Text = "Parent Information"; @@ -524,10 +502,9 @@ // emailAddressTextBox // this.emailAddressTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.studentBindingSource, "Parent.EmailAddress", true)); - this.emailAddressTextBox.Location = new System.Drawing.Point(186, 232); - this.emailAddressTextBox.Margin = new System.Windows.Forms.Padding(4); + this.emailAddressTextBox.Location = new System.Drawing.Point(140, 186); this.emailAddressTextBox.Name = "emailAddressTextBox"; - this.emailAddressTextBox.Size = new System.Drawing.Size(228, 38); + this.emailAddressTextBox.Size = new System.Drawing.Size(172, 30); 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); @@ -535,8 +512,7 @@ // phoneNumberNumericUpDown // this.phoneNumberNumericUpDown.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.studentBindingSource, "Parent.PhoneNumber", true)); - this.phoneNumberNumericUpDown.Location = new System.Drawing.Point(185, 174); - this.phoneNumberNumericUpDown.Margin = new System.Windows.Forms.Padding(4); + this.phoneNumberNumericUpDown.Location = new System.Drawing.Point(139, 139); this.phoneNumberNumericUpDown.Maximum = new decimal(new int[] { 1410065407, 2, @@ -548,7 +524,7 @@ 0, 0}); this.phoneNumberNumericUpDown.Name = "phoneNumberNumericUpDown"; - this.phoneNumberNumericUpDown.Size = new System.Drawing.Size(229, 38); + this.phoneNumberNumericUpDown.Size = new System.Drawing.Size(172, 30); this.phoneNumberNumericUpDown.TabIndex = 5; this.toolTips.SetToolTip(this.phoneNumberNumericUpDown, "Enter 9 digit phone number with no symbols."); this.phoneNumberNumericUpDown.Value = new decimal(new int[] { @@ -561,30 +537,27 @@ // 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(185, 63); - this.parent_firstNameTextBox.Margin = new System.Windows.Forms.Padding(4); + this.parent_firstNameTextBox.Location = new System.Drawing.Point(139, 50); this.parent_firstNameTextBox.Name = "parent_firstNameTextBox"; - this.parent_firstNameTextBox.Size = new System.Drawing.Size(229, 38); + this.parent_firstNameTextBox.Size = new System.Drawing.Size(173, 30); 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(185, 117); - this.parent_lastNameTextBox.Margin = new System.Windows.Forms.Padding(4); + this.parent_lastNameTextBox.Location = new System.Drawing.Point(139, 94); this.parent_lastNameTextBox.Name = "parent_lastNameTextBox"; - this.parent_lastNameTextBox.Size = new System.Drawing.Size(229, 38); + this.parent_lastNameTextBox.Size = new System.Drawing.Size(173, 30); this.parent_lastNameTextBox.TabIndex = 1; this.parent_lastNameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.String_TextBox_Validating); // // clear_button // this.clear_button.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.clear_button.Location = new System.Drawing.Point(324, 457); - this.clear_button.Margin = new System.Windows.Forms.Padding(4); + this.clear_button.Location = new System.Drawing.Point(243, 366); 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"; this.clear_button.UseVisualStyleBackColor = true; @@ -593,10 +566,9 @@ // delete_button // this.delete_button.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.delete_button.Location = new System.Drawing.Point(560, 457); - this.delete_button.Margin = new System.Windows.Forms.Padding(4); + this.delete_button.Location = new System.Drawing.Point(420, 366); 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; @@ -615,20 +587,18 @@ this.lblSearch.AutoSize = true; this.lblSearch.BackColor = System.Drawing.Color.Transparent; this.lblSearch.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblSearch.Location = new System.Drawing.Point(946, 5); - this.lblSearch.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblSearch.Location = new System.Drawing.Point(710, 4); this.lblSearch.Name = "lblSearch"; - this.lblSearch.Size = new System.Drawing.Size(300, 35); + this.lblSearch.Size = new System.Drawing.Size(226, 26); this.lblSearch.TabIndex = 24; this.lblSearch.Text = "Search Student by Last Name:"; // // search_textBox // this.search_textBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.search_textBox.Location = new System.Drawing.Point(952, 56); - this.search_textBox.Margin = new System.Windows.Forms.Padding(4); + this.search_textBox.Location = new System.Drawing.Point(714, 45); this.search_textBox.Name = "search_textBox"; - this.search_textBox.Size = new System.Drawing.Size(377, 38); + this.search_textBox.Size = new System.Drawing.Size(284, 30); 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); @@ -640,10 +610,9 @@ // btnChaosMonkey // this.btnChaosMonkey.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.btnChaosMonkey.Location = new System.Drawing.Point(745, 422); - this.btnChaosMonkey.Margin = new System.Windows.Forms.Padding(4); + this.btnChaosMonkey.Location = new System.Drawing.Point(559, 338); this.btnChaosMonkey.Name = "btnChaosMonkey"; - this.btnChaosMonkey.Size = new System.Drawing.Size(141, 68); + this.btnChaosMonkey.Size = new System.Drawing.Size(106, 54); this.btnChaosMonkey.TabIndex = 26; this.btnChaosMonkey.Text = "CHAOS"; this.btnChaosMonkey.UseVisualStyleBackColor = true; @@ -654,10 +623,9 @@ // this.foundStudents_comboBox.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.foundStudents_comboBox.FormattingEnabled = true; - this.foundStudents_comboBox.Location = new System.Drawing.Point(952, 157); - this.foundStudents_comboBox.Margin = new System.Windows.Forms.Padding(4); + this.foundStudents_comboBox.Location = new System.Drawing.Point(714, 126); this.foundStudents_comboBox.Name = "foundStudents_comboBox"; - this.foundStudents_comboBox.Size = new System.Drawing.Size(377, 43); + this.foundStudents_comboBox.Size = new System.Drawing.Size(284, 34); 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); @@ -667,20 +635,18 @@ this.lblFoundStudents.AutoSize = true; this.lblFoundStudents.BackColor = System.Drawing.Color.Transparent; this.lblFoundStudents.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblFoundStudents.Location = new System.Drawing.Point(946, 109); - this.lblFoundStudents.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblFoundStudents.Location = new System.Drawing.Point(710, 87); this.lblFoundStudents.Name = "lblFoundStudents"; - this.lblFoundStudents.Size = new System.Drawing.Size(169, 35); + this.lblFoundStudents.Size = new System.Drawing.Size(128, 26); this.lblFoundStudents.TabIndex = 28; this.lblFoundStudents.Text = "Found Students:"; // // studentDbID // this.studentDbID.Font = new System.Drawing.Font("Sitka Display", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.studentDbID.Location = new System.Drawing.Point(1244, 40); - this.studentDbID.Margin = new System.Windows.Forms.Padding(4); + this.studentDbID.Location = new System.Drawing.Point(933, 32); this.studentDbID.Name = "studentDbID"; - this.studentDbID.Size = new System.Drawing.Size(63, 38); + this.studentDbID.Size = new System.Drawing.Size(47, 30); this.studentDbID.TabIndex = 8; this.studentDbID.Visible = false; // @@ -717,27 +683,23 @@ this.panel1.Controls.Add(lastNameLabel); this.panel1.Controls.Add(this.lastNameTextBox); this.panel1.Controls.Add(this.student_pictureBox); - this.panel1.Location = new System.Drawing.Point(0, 43); + this.panel1.Location = new System.Drawing.Point(0, 34); + this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(1424, 691); + this.panel1.Size = new System.Drawing.Size(1068, 553); this.panel1.TabIndex = 29; // - // studentBindingSource - // - this.studentBindingSource.DataSource = typeof(DBWizard.Models.Student); - // // 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(1424, 735); + this.ClientSize = new System.Drawing.Size(1068, 600); this.Controls.Add(this.panel1); this.Controls.Add(this.studentDbID); 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); - this.MinimumSize = new System.Drawing.Size(1421, 806); + this.MinimumSize = new System.Drawing.Size(1071, 656); this.Name = "Form1"; this.Text = "KentYouthDB"; this.Load += new System.EventHandler(this.Form1_Load); @@ -746,6 +708,7 @@ this.mainMenuStrip.ResumeLayout(false); this.mainMenuStrip.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.student_pictureBox)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).EndInit(); this.parent_groupBox.ResumeLayout(false); this.parent_groupBox.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).EndInit(); @@ -753,7 +716,6 @@ ((System.ComponentModel.ISupportInitialize)(this.studentDbID)).EndInit(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/Form1.cs b/Form1.cs index 6f059dd..5db4a6e 100644 --- a/Form1.cs +++ b/Form1.cs @@ -29,18 +29,20 @@ namespace DBWizard { public partial class Form1 : Form { + //Global instance of the SqliteDataAccess object. SqliteDataAccess SqliteDataAccess = new SqliteDataAccess(); - bool bStudentRecordExists = false; public Form1() { InitializeComponent(); } + //Needed to populate the pre-filled comboboxes. Do not remove. private void Form1_Load(object sender, EventArgs e) { FillComboBoxes(); } + /* Fills program and school combo boxes on the form * with the static data from the sqlite db. * input: no input @@ -65,14 +67,29 @@ namespace DBWizard } //TODO: implement + /* On click of the picture box, open a file picker dialog box + * for the user to browse/choose a picture. + * Once the user clicks OK, the _FileOK event below fires, + * validates the input. If file is OK, then read the file from disk, + * convert it into an Image, and save it to the student picture box. + */ private void student_pictureBox_DoubleClick(object sender, EventArgs e) { DialogResult dr = pic_openFileDialog.ShowDialog(); if(dr == DialogResult.OK) { + //Place in dicpic box + + //change tag of pic box to something else + student_pictureBox.Tag = "dickpic"; } } + //TODO: Test + /* Event that occurs when the user clicks Open in the file dialog box. + * Check to see if the photo size is too large for the database. + * If so, reject the file and inform the user. + */ private void pic_openFileDialog_FileOk(object sender, CancelEventArgs e) { byte[] dickpic; @@ -87,19 +104,13 @@ namespace DBWizard } } - //TODO: implement - private void pictureBox1_Click(object sender, EventArgs e) - { - DialogResult dr = pic_openFileDialog.ShowDialog(); - if(dr == DialogResult.OK) - { - //Place in dicpic box - - //change tag of pic box to something else - student_pictureBox.Tag = "dickpic"; - } - } - + /* Event that fires when user clicks the save button or + * chooses File > Save Student. + * + * Saves student to database. + * If existing student, update student. + * If new student, insert student. + */ private void save_button_Click(object sender, EventArgs e) { byte[] dickpic; @@ -116,6 +127,7 @@ namespace DBWizard } } + //TODO: Add Check - if pic is not default pic, //Validate the picture is under 2147483647 characters in length. dickpic = ObjectToByteArray(student_pictureBox.Image); if(dickpic.Length >= 2147483647) //THAT'S WHAT SHE SAID @@ -150,7 +162,8 @@ namespace DBWizard //save data to sqldb. //update existing student. - if(SqliteDataAccess.FindStudentByStudentId(student.student_id).Count > 0) + //TODO: test new update. + if(SqliteDataAccess.GetStudentByDbID(Int32.Parse(studentDbID.Value.ToString())) != null) { SqliteDataAccess.UpdateStudent(student); SqliteDataAccess.UpdateParent(parent,student.parent_id); @@ -301,6 +314,7 @@ namespace DBWizard { PictureBox pb = (PictureBox)c; pb.Image = Properties.Resources.student; + pb.Tag = "DefaultImage"; } } // foreach @@ -429,7 +443,5 @@ namespace DBWizard { save_button_Click(save_button, EventArgs.Empty); } - - } //Form1 } diff --git a/SqliteDataAccess.cs b/SqliteDataAccess.cs index 638a2f0..4914b13 100644 --- a/SqliteDataAccess.cs +++ b/SqliteDataAccess.cs @@ -11,6 +11,29 @@ namespace DBWizard { class SqliteDataAccess { + #region student + // ***************** Create ***************** + + /* Inserts a new student to the SQL database. + * INPUT: student + * OUTPUT: new row to SQL database, null to program. + */ + internal void InsertNewStudent(Student stu) + { + using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) + { + string strQuery = "INSERT INTO STUDENTS (student_id, parent_id, FirstName, LastName, DOB, gender, address, program_id, school_id, GradeLevel, photo)" + + "VALUES (@student_id, @parent_id, @FirstName, @LastName, @DOB, @gender, @address, @program_id, @school_id, @GradeLevel, @photo)"; + cnn.Execute(strQuery, stu); + } + } + + // ***************** Read ***************** + + /* Gets a list of all students with the provided last name as equality. + * INPUT: String last name + * OUTPUT List + */ public List FindStudentByLastname(string last_name) { //A using statement protects us as a failsafe: it guarantees the connection to the @@ -24,20 +47,24 @@ namespace DBWizard } } - //Used in delete function + /* Gets a single student from the db given the db id field. + * This function is also usedl used in delete functionality of Form1.cs + * INPUT: integer database id + * OUTPUT: student + */ public Student GetStudentByDbID(int dbid_in) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) { string strQuery = "SELECT * FROM students WHERE id=@id"; - var output = cnn.Query(strQuery, new { id = dbid_in }); - var stuList = output.ToList(); - Student student = stuList[0]; + var stu_out = cnn.Query(strQuery, new { id = dbid_in }).Single(); - return student; + return stu_out; } } - //Can also be used for search function. + + //Can also be used for search function, but currently unused. + //TODO: cleanup if we decide not to use this. public List FindStudentByStudentId(string studentid_in) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) @@ -49,6 +76,16 @@ namespace DBWizard } } + // ***************** Update ***************** + + /* Updates an individual student in the DB. + * Needs to do field mapping in the Execute call because + * the photo field can be null or not null, and + * the conditional operator can be used to change the query on the fly. + * + * INPUT: Student + * OUTPUT: Data to SQL Database, void to program + */ internal void UpdateStudent(Student stu) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) @@ -72,16 +109,12 @@ namespace DBWizard } } - internal void InsertNewStudent(Student stu) - { - using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) - { - string strQuery = "INSERT INTO STUDENTS (student_id, parent_id, FirstName, LastName, DOB, gender, address, program_id, school_id, GradeLevel, photo)" + - "VALUES (@student_id, @parent_id, @FirstName, @LastName, @DOB, @gender, @address, @program_id, @school_id, @GradeLevel, @photo)"; - cnn.Execute(strQuery, stu); - } - } + // ***************** Delete ***************** + /* Deletes a student record from the database. + * INPUT: student + * OUTPUT: void + */ internal void DeleteStudent(Student stu_in) { //protect query from 0 or negative indexes. @@ -95,8 +128,15 @@ namespace DBWizard } } + #endregion + + #region parent + // ***************** Create ***************** + /* Inserts a new parent. * returns parent id as the new row # it just inserted. + * INPUT: parent + * OUTPUT: int */ internal int InsertNewParent(Parent par) { @@ -110,6 +150,17 @@ namespace DBWizard } } + // ***************** Read ***************** + + // ***************** Update ***************** + + /* Update a parent to the SQL database. + * Needs to do the mapping as parent_id is not stored on the parent object of the form. + * but it is stored in the student object if the student is found. + * + * INPUT: Parent, int parent_id + * OUTPUT: Data to SQL database, void to program. + */ internal void UpdateParent(Parent par, int parent_id_in) { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) @@ -129,6 +180,15 @@ namespace DBWizard } } + // ***************** Delete ***************** + + #endregion + + #region Misc + /* Returns the list of available programs from the DB to fill the Programs drop-down. + * INPUT: no args + * OUTPUT: List + */ internal List GetPrograms() { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString())) @@ -140,6 +200,8 @@ namespace DBWizard } } + #endregion + internal List GetSchools() { using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))