Add a new numericupdown for parent db id
Add function to clearformerrors and call it on clearform as well as after a student is found. Bugfix regarding update parent Show message box upon updating student and parent Properly consolidate new student toolstrip and save student toolstrip to the already written event.
This commit is contained in:
parent
3a1828d4a8
commit
b5530e4a28
39
Form1.Designer.cs
generated
39
Form1.Designer.cs
generated
@ -55,7 +55,6 @@
|
||||
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();
|
||||
@ -82,6 +81,8 @@
|
||||
this.lblFoundStudents = new System.Windows.Forms.Label();
|
||||
this.studentDbID = new System.Windows.Forms.NumericUpDown();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.parentDbID = new System.Windows.Forms.NumericUpDown();
|
||||
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 +99,13 @@
|
||||
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.parentDbID)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lastNameLabel
|
||||
@ -269,7 +271,6 @@
|
||||
this.fileToolStripMenuItem});
|
||||
this.mainMenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.mainMenuStrip.Name = "mainMenuStrip";
|
||||
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";
|
||||
@ -291,14 +292,14 @@
|
||||
this.newStudentToolStripMenuItem.Name = "newStudentToolStripMenuItem";
|
||||
this.newStudentToolStripMenuItem.Size = new System.Drawing.Size(262, 34);
|
||||
this.newStudentToolStripMenuItem.Text = "&New Student";
|
||||
this.newStudentToolStripMenuItem.Click += new System.EventHandler(this.newStudentToolStripMenuItem_Click);
|
||||
this.newStudentToolStripMenuItem.Click += new System.EventHandler(this.clear_button_Click);
|
||||
//
|
||||
// saveStudentToolStripMenuItem
|
||||
//
|
||||
this.saveStudentToolStripMenuItem.Name = "saveStudentToolStripMenuItem";
|
||||
this.saveStudentToolStripMenuItem.Size = new System.Drawing.Size(262, 34);
|
||||
this.saveStudentToolStripMenuItem.Text = "&Save Student";
|
||||
this.saveStudentToolStripMenuItem.Click += new System.EventHandler(this.saveStudentToolStripMenuItem_Click);
|
||||
this.saveStudentToolStripMenuItem.Click += new System.EventHandler(this.save_button_Click);
|
||||
//
|
||||
// reportsToolStripMenuItem
|
||||
//
|
||||
@ -358,10 +359,6 @@
|
||||
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));
|
||||
@ -610,7 +607,7 @@
|
||||
// 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(559, 338);
|
||||
this.btnChaosMonkey.Location = new System.Drawing.Point(559, 366);
|
||||
this.btnChaosMonkey.Name = "btnChaosMonkey";
|
||||
this.btnChaosMonkey.Size = new System.Drawing.Size(106, 54);
|
||||
this.btnChaosMonkey.TabIndex = 26;
|
||||
@ -644,10 +641,11 @@
|
||||
// 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(933, 32);
|
||||
this.studentDbID.Location = new System.Drawing.Point(5, 32);
|
||||
this.studentDbID.Name = "studentDbID";
|
||||
this.studentDbID.Size = new System.Drawing.Size(47, 30);
|
||||
this.studentDbID.TabIndex = 8;
|
||||
this.studentDbID.TabStop = false;
|
||||
this.studentDbID.Visible = false;
|
||||
//
|
||||
// panel1
|
||||
@ -683,12 +681,25 @@
|
||||
this.panel1.Controls.Add(lastNameLabel);
|
||||
this.panel1.Controls.Add(this.lastNameTextBox);
|
||||
this.panel1.Controls.Add(this.student_pictureBox);
|
||||
this.panel1.Controls.Add(this.parentDbID);
|
||||
this.panel1.Location = new System.Drawing.Point(0, 34);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.panel1.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(1068, 553);
|
||||
this.panel1.TabIndex = 29;
|
||||
//
|
||||
// parentDbID
|
||||
//
|
||||
this.parentDbID.Location = new System.Drawing.Point(942, -2);
|
||||
this.parentDbID.Name = "parentDbID";
|
||||
this.parentDbID.Size = new System.Drawing.Size(47, 26);
|
||||
this.parentDbID.TabIndex = 29;
|
||||
this.parentDbID.Visible = false;
|
||||
//
|
||||
// studentBindingSource
|
||||
//
|
||||
this.studentBindingSource.DataSource = typeof(DBWizard.Models.Student);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
@ -708,7 +719,6 @@
|
||||
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();
|
||||
@ -716,6 +726,8 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentDbID)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.parentDbID)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -762,6 +774,7 @@
|
||||
private System.Windows.Forms.NumericUpDown studentDbID;
|
||||
private System.Windows.Forms.ToolStripMenuItem exitWithoutSavingToolStripMenuItem;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.NumericUpDown parentDbID;
|
||||
}
|
||||
}
|
||||
|
||||
|
38
Form1.cs
38
Form1.cs
@ -162,11 +162,14 @@ namespace DBWizard
|
||||
|
||||
//save data to sqldb.
|
||||
//update existing student.
|
||||
//TODO: test new update.
|
||||
if(SqliteDataAccess.GetStudentByDbID(Int32.Parse(studentDbID.Value.ToString())) != null)
|
||||
{
|
||||
student.id = Int32.Parse(studentDbID.Value.ToString());
|
||||
parent.parent_id = Int32.Parse(parentDbID.Value.ToString());
|
||||
|
||||
SqliteDataAccess.UpdateStudent(student);
|
||||
SqliteDataAccess.UpdateParent(parent,student.parent_id);
|
||||
SqliteDataAccess.UpdateParent(parent);
|
||||
MessageBox.Show("Student and parent successfully updated.");
|
||||
}
|
||||
else //new student
|
||||
{
|
||||
@ -348,14 +351,21 @@ namespace DBWizard
|
||||
emailAddressTextBox.Text = string.Empty;
|
||||
|
||||
ClearFoundStudentsComboBox();
|
||||
|
||||
ClearFormErrors();
|
||||
} //ClearForm()
|
||||
|
||||
/* Clears form errors out of the errorprovider.
|
||||
* INPUTS: no args
|
||||
* OUTPUT: void
|
||||
*/
|
||||
private void ClearFormErrors()
|
||||
{
|
||||
//clear form errors
|
||||
foreach (Control c in errorProvider1.ContainerControl.Controls)
|
||||
{
|
||||
errorProvider1.SetError(c, "");
|
||||
}
|
||||
|
||||
} //ClearForm()
|
||||
}
|
||||
|
||||
//Clears the found student combobox.
|
||||
private void ClearFoundStudentsComboBox()
|
||||
@ -417,11 +427,10 @@ namespace DBWizard
|
||||
dob_dateTimePicker.Value = DateTime.Parse(foundStudent.DOB);
|
||||
|
||||
//May need to select the index on these comboboxes.
|
||||
//TODO: TEEESSTICLES
|
||||
genderComboBox.Text = foundStudent.gender;
|
||||
gradeLevelComboBox.Text = foundStudent.GradeLevel;
|
||||
|
||||
//TODO: Moar Testicles
|
||||
//TODO: Test
|
||||
student_pictureBox.Image = (foundStudent.photo != null) ? (Image)ByteArrayToObject(foundStudent.photo) : Properties.Resources.student;
|
||||
|
||||
//Now populate the parent.
|
||||
@ -432,6 +441,11 @@ namespace DBWizard
|
||||
parent_firstNameTextBox.Text = stuParent.FirstName;
|
||||
phoneNumberNumericUpDown.Value = stuParent.PhoneNumber;
|
||||
emailAddressTextBox.Text = stuParent.EmailAddress;
|
||||
parentDbID.Value = stuParent.parent_id;
|
||||
|
||||
//Clear form errors, if any.
|
||||
ClearFormErrors();
|
||||
|
||||
} //foundStudents_comboBox_SelectionChangeCommitted
|
||||
|
||||
/* Deletes a student.
|
||||
@ -476,16 +490,6 @@ namespace DBWizard
|
||||
//If there's an error, oh well, we tried, exit anyway.
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
private void newStudentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
clear_button_Click(clear_button, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void saveStudentToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
save_button_Click(save_button, EventArgs.Empty);
|
||||
}
|
||||
#endregion
|
||||
} //Form1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user