private void metroButtonSearchLec_Click(object sender, EventArgs e) { if (metroTextBoxSearchLec.Text == "") { MetroMessageBox.Show(this, "Search Field cannot be left empty"); } else { Professor obj = new Professor(); ProffessorTransactions tr2 = new ProffessorTransactions(); try { obj = tr2.dataFill(metroTextBoxSearchLec.Text); metroTextBoxProfessorId.Text = obj.getid(); metroTextBoxFname.Text = obj.getFirstName(); metroTextBoxLName.Text = obj.getLastName(); metroTextBoxDOB2.Text = obj.getDOB(); metroTextBoxMNo.Text = obj.getContactNo(); metroTextBoxEm.Text = obj.getEmail(); metroTextBoxAddr.Text = obj.getAddress(); metroComboBoxGend.Text = obj.getGender(); metroTextBoxUName.Text = obj.getUsername(); metroTextBoxPW.Text = obj.getPassword(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Stafford University Registration System", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
void DataGridViewProf() { ProffessorTransactions c1 = new ProffessorTransactions(); string sql1 = "SELECT * FROM Professor"; DataTable dt1 = c1.searchData(sql1); metroGridProfessor.DataSource = dt1; }
private void LecturerHome_Load(object sender, EventArgs e) { metroLabeluname.Text = Login.u; ProffessorTransactions pt = new ProffessorTransactions(); p = pt.getProfessorId(metroLabeluname.Text); profid = p.getid(); loadComboShowMods(); loadComboTab(); }
private void metroButtonProceedLect_Click(object sender, EventArgs e) { if (metroComboBoxOptProf.Text == "Add") { if (metroTextBoxProfessorId.Text == "" || metroTextBoxFname.Text == "" || metroTextBoxLName.Text == "" || metroTextBoxDOB2.Text == "" || metroTextBoxMNo.Text == "" || metroTextBoxEm.Text == "" || metroTextBoxAddr.Text == "" || metroComboBoxGend.Text == "" || metroTextBoxUName.Text == "" || metroTextBoxPW.Text == "") { MetroMessageBox.Show(this, "Fields cannot be left empty"); } if (!Regex.Match(metroTextBoxMNo.Text, @"^\d{10}$").Success) { MetroMessageBox.Show(this, "Please re-enter the contact number", "Warning"); metroTextBoxMNo.Focus(); } if (!Regex.Match(metroTextBoxEm.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,4})+)$").Success) { MetroMessageBox.Show(this, "Invalid E-Mail address Please re-enter correct address"); metroTextBoxEm.Focus(); } else { ProffessorTransactions c = new ProffessorTransactions(); string sql = "SELECT * FROM Professor WHERE PId = '" + metroTextBoxProfessorId.Text + "' or Username = '******'"; DataTable d = c.searchData(sql); metroGridStudents.DataSource = d; if (d.Rows.Count > 0) { MetroMessageBox.Show(this, "This Data already exist"); } else { Professor obj = new Professor(metroTextBoxProfessorId.Text, metroTextBoxFname.Text, metroTextBoxLName.Text, metroTextBoxDOB2.Text, metroTextBoxMNo.Text, metroTextBoxEm.Text, metroTextBoxAddr.Text, metroComboBoxGend.Text, metroTextBoxUName.Text, metroTextBoxPW.Text); ProffessorTransactions tr = new ProffessorTransactions(); tr.addProffessor(obj); MetroMessageBox.Show(this, "Data Saved Sucessfully !"); clearProfessor(); metroGridProfessor.Refresh(); } } } else if (metroComboBoxOptProf.Text == "Update") { if (metroTextBoxProfessorId.Text == "" || metroTextBoxFname.Text == "" || metroTextBoxLName.Text == "" || metroTextBoxDOB2.Text == "" || metroTextBoxMNo.Text == "" || metroTextBoxEm.Text == "" || metroTextBoxAddr.Text == "" || metroComboBoxGend.Text == "" || metroTextBoxUName.Text == "" || metroTextBoxPW.Text == "") { MetroMessageBox.Show(this, "Fields cannot be left empty"); } if (!Regex.Match(metroTextBoxMNo.Text, @"^\d{10}$").Success) { MetroMessageBox.Show(this, "Please re-enter the contact number", "Warning"); metroTextBoxMNo.Focus(); } if (!Regex.Match(metroTextBoxEm.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,4})+)$").Success) { MetroMessageBox.Show(this, "Invalid E-Mail address Please re-enter correct address"); metroTextBoxEm.Focus(); } else { Professor obj = new Professor(metroTextBoxProfessorId.Text, metroTextBoxFname.Text, metroTextBoxLName.Text, metroTextBoxDOB2.Text, metroTextBoxMNo.Text, metroTextBoxEm.Text, metroTextBoxAddr.Text, metroComboBoxGend.Text, metroTextBoxUName.Text, metroTextBoxPW.Text); ProffessorTransactions tr = new ProffessorTransactions(); tr.updateProffessor(obj); MetroMessageBox.Show(this, "Data Saved Sucessfully !"); clearProfessor(); metroGridProfessor.Refresh(); } } else if (metroComboBoxOptProf.Text == "Search") { Professor obj = new Professor(); ProffessorTransactions tr2 = new ProffessorTransactions(); try { obj = tr2.dataFill(metroTextBoxSearchLec.Text); metroTextBoxProfessorId.Text = obj.getid(); metroTextBoxFname.Text = obj.getFirstName(); metroTextBoxLName.Text = obj.getLastName(); metroTextBoxDOB2.Text = obj.getDOB(); metroTextBoxMNo.Text = obj.getContactNo(); metroTextBoxEm.Text = obj.getEmail(); metroTextBoxAddr.Text = obj.getAddress(); metroComboBoxGend.Text = obj.getGender(); metroTextBoxUName.Text = obj.getUsername(); metroTextBoxPW.Text = obj.getPassword(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Stafford University Registration System", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (metroComboBoxOptProf.Text == "Delete") { if (metroGridProfessor.Rows.Count == 0) { MetroMessageBox.Show(this, "No data found to delete"); } else { DialogResult del = MessageBox.Show("Are you Sure you want to delete :" + metroTextBoxStudentId.Text + "", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (del == DialogResult.Yes) { ProffessorTransactions tr3 = new ProffessorTransactions(); try { tr3.deleteFromProffessorModule(metroTextBoxStudentId.Text); tr3.deleteProffessorr(metroTextBoxStudentId.Text); MetroMessageBox.Show(this, "Successfully Deleted"); metroGridProfessor.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Delete Student", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Ok. As per confirmation, this record has not been deleted."); } } } else { MetroMessageBox.Show(this, "Please select a option button to Proceed!"); } }