Implement student search capability.
This commit is contained in:
parent
3c61b605a4
commit
a6ad325b6c
16
Form1.Designer.cs
generated
16
Form1.Designer.cs
generated
@ -54,6 +54,7 @@
|
||||
this.exitsavesDataToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.studentBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components);
|
||||
this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
|
||||
this.studentBindingSource = new System.Windows.Forms.BindingSource(this.components);
|
||||
this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
|
||||
this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();
|
||||
this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
|
||||
@ -91,7 +92,6 @@
|
||||
this.btnChaosMonkey = new System.Windows.Forms.Button();
|
||||
this.foundStudents_comboBox = new System.Windows.Forms.ComboBox();
|
||||
this.lblFoundStudents = new System.Windows.Forms.Label();
|
||||
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();
|
||||
@ -109,11 +109,11 @@
|
||||
this.mainMenuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingNavigator)).BeginInit();
|
||||
this.studentBindingNavigator.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.student_pictureBox)).BeginInit();
|
||||
this.parent_groupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lastNameLabel
|
||||
@ -269,7 +269,7 @@
|
||||
this.reportsToolStripMenuItem,
|
||||
this.exitsavesDataToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 29);
|
||||
this.fileToolStripMenuItem.Size = new System.Drawing.Size(54, 31);
|
||||
this.fileToolStripMenuItem.Text = "&File";
|
||||
//
|
||||
// newStudentToolStripMenuItem
|
||||
@ -352,6 +352,10 @@
|
||||
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(34, 30);
|
||||
this.bindingNavigatorAddNewItem.Text = "Add new";
|
||||
//
|
||||
// studentBindingSource
|
||||
//
|
||||
this.studentBindingSource.DataSource = typeof(DBWizard.Models.Student);
|
||||
//
|
||||
// bindingNavigatorCountItem
|
||||
//
|
||||
this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
|
||||
@ -716,10 +720,6 @@
|
||||
this.lblFoundStudents.TabIndex = 28;
|
||||
this.lblFoundStudents.Text = "Found Students:";
|
||||
//
|
||||
// studentBindingSource
|
||||
//
|
||||
this.studentBindingSource.DataSource = typeof(DBWizard.Models.Student);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
|
||||
@ -765,12 +765,12 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingNavigator)).EndInit();
|
||||
this.studentBindingNavigator.ResumeLayout(false);
|
||||
this.studentBindingNavigator.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.student_pictureBox)).EndInit();
|
||||
this.parent_groupBox.ResumeLayout(false);
|
||||
this.parent_groupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.phoneNumberNumericUpDown)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.errorProvider1)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.studentBindingSource)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
75
Form1.cs
75
Form1.cs
@ -256,12 +256,11 @@ namespace DBWizard
|
||||
|
||||
}
|
||||
|
||||
//TODO: Remove Chaos Monkey button
|
||||
//TODO: Remove Chaos Monkey button prior to release
|
||||
private void btnChaosMonkey_Click(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show("CHAOS MONKEY");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
private void clear_button_Click(object sender, EventArgs e)
|
||||
@ -297,7 +296,34 @@ namespace DBWizard
|
||||
NumericUpDown nud = (NumericUpDown)c;
|
||||
nud.Value = nud.Minimum;
|
||||
}
|
||||
|
||||
if(c is PictureBox)
|
||||
{
|
||||
PictureBox pb = (PictureBox)c;
|
||||
pb.Image = Properties.Resources.student;
|
||||
}
|
||||
} // foreach
|
||||
|
||||
//clear parent data
|
||||
parent_lastNameTextBox.Text = string.Empty;
|
||||
parent_firstNameTextBox.Text = string.Empty;
|
||||
phoneNumberNumericUpDown.Value = phoneNumberNumericUpDown.Minimum;
|
||||
emailAddressTextBox.Text = string.Empty;
|
||||
|
||||
//clear form errors
|
||||
foreach (Control c in errorProvider1.ContainerControl.Controls)
|
||||
{
|
||||
errorProvider1.SetError(c, "");
|
||||
}
|
||||
|
||||
} //ClearForm()
|
||||
|
||||
private void ClearFoundStudentsComboBox()
|
||||
{
|
||||
foundStudents_comboBox.DataSource = null;
|
||||
foundStudents_comboBox.Items.Clear();
|
||||
foundStudents_comboBox.Text = string.Empty;
|
||||
foundStudents_comboBox.SelectedIndex = -1;
|
||||
}
|
||||
|
||||
private void search_textBox_KeyDown(object sender, KeyEventArgs e)
|
||||
@ -306,16 +332,12 @@ namespace DBWizard
|
||||
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
foundStudents_comboBox.Items.Clear();
|
||||
foundStudents_comboBox.Text = String.Empty;
|
||||
ClearFoundStudentsComboBox();
|
||||
|
||||
foundStudents = SqliteDataAccess.FindStudentByLastname(search_textBox.Text);
|
||||
|
||||
foreach (Student s in foundStudents)
|
||||
{
|
||||
foundStudents_comboBox.Items.Add(s);
|
||||
}
|
||||
|
||||
foundStudents_comboBox.DataSource = foundStudents;
|
||||
foundStudents_comboBox.DisplayMember = "DisplayName";
|
||||
foundStudents_comboBox.Text = (foundStudents.Count > 0) ? "Students found, click here" : "No students found";
|
||||
}
|
||||
}
|
||||
@ -329,7 +351,38 @@ namespace DBWizard
|
||||
//TODO:Populate the form based on the found student.
|
||||
private void foundStudents_comboBox_SelectionChangeCommitted(object sender, EventArgs e)
|
||||
{
|
||||
Student foundStudent = foundStudents_comboBox.SelectedItem as Student;
|
||||
ClearForm();
|
||||
}
|
||||
}
|
||||
|
||||
//The found students combo box is not completely
|
||||
//cleared upon clearform. Do this now.
|
||||
ClearFoundStudentsComboBox();
|
||||
|
||||
//Populate the form based on the found student.
|
||||
lastNameTextBox.Text = foundStudent.LastName;
|
||||
firstNameTextBox.Text = foundStudent.FirstName;
|
||||
programComboBox.SelectedIndex = foundStudent.program_id;
|
||||
schoolComboBox.SelectedIndex = foundStudent.school_id;
|
||||
addressTextBox.Text = foundStudent.address;
|
||||
student_idTextBox.Text = foundStudent.student_id;
|
||||
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
|
||||
student_pictureBox.Image = (foundStudent.photo != null) ? (Image)ByteArrayToObject(foundStudent.photo) : Properties.Resources.student;
|
||||
|
||||
//Now populate the parent.
|
||||
Parent stuParent = new Parent();
|
||||
stuParent = SqliteDataAccess.GetParentByID(foundStudent.parent_id);
|
||||
|
||||
parent_lastNameTextBox.Text = stuParent.LastName;
|
||||
parent_firstNameTextBox.Text = stuParent.FirstName;
|
||||
phoneNumberNumericUpDown.Value = stuParent.PhoneNumber;
|
||||
emailAddressTextBox.Text = stuParent.EmailAddress;
|
||||
} //foundStudents_comboBox_SelectionChangeCommitted
|
||||
} //Form1
|
||||
}
|
||||
|
@ -21,15 +21,15 @@ namespace DBWizard.Models
|
||||
public string GradeLevel { get; set; }
|
||||
public byte[] photo { get; set; }
|
||||
|
||||
//readonly property to populate the found student searchbox.
|
||||
// this is a "Get" only property
|
||||
public string DisplayName{
|
||||
get =>
|
||||
$"{LastName}, {FirstName} - Student ID: {student_id}";
|
||||
}
|
||||
|
||||
public virtual Parent Parent { get; set; }
|
||||
public virtual Program Program { get; set; }
|
||||
public virtual School School { get; set; }
|
||||
|
||||
//override toString for search functionality.
|
||||
public override string ToString()
|
||||
{
|
||||
string str = $"{LastName}, {FirstName} student id: {student_id}";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user