private void metroButtonSearchMod_Click(object sender, EventArgs e)
 {
     if (metroComboBoxOptProf.Text == "Search")
     {
         Module             obj = new Module();
         ModuleTransactions tr2 = new ModuleTransactions();
         try
         {
             obj = tr2.datafill(metroTextSearch.Text);
             metroTextBoxModuleId.Text    = obj.getID();
             metroTextBoxModuleName.Text  = obj.getMName();
             metroComboBoxSemester.Text   = obj.getSemester();
             metroTextBoxFaculty.Text     = obj.getFaculty();
             metroTextBoxDuration.Text    = obj.getDuration();
             metroTextBoxDescription.Text = obj.getModuleOverview();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Stafford University Registration System", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MetroMessageBox.Show(this, "Please select the search option!");
     }
 }
Beispiel #2
0
        private void metroComboBoxMod_SelectedIndexChanged(object sender, EventArgs e)
        {
            Module             m  = new Module();
            ModuleTransactions mt = new ModuleTransactions();

            mt.dataFillCMBX(metroComboBoxMod.Text);
            m = mt.datafill(metroComboBoxMod.Text);
            metroComboBoxMod.Text = m.getID();
            metroTextBoxMod.Text  = m.getMName();
            metroTextBoxF.Text    = m.getFaculty();
            metroTextD.Text       = m.getDuration();
            metroTextBoxMFee.Text = m.getModulefee();
            metroTextBoxSem.Text  = m.getSemester();
        }
        private void metroComboBoxFac_SelectedIndexChanged(object sender, EventArgs e)
        {
            Module             m  = new Module();
            ModuleTransactions mt = new ModuleTransactions();

            mt.dataFillCMBX(metroComboBoxMod.Text);
            m = mt.datafill(metroComboBoxMod.Text);
            metroComboBoxMod.Text   = m.getID();
            metroTextBoxModule.Text = m.getMName();
            metroTextBoxFac.Text    = m.getFaculty();
            metroTextBoxDur.Text    = m.getDuration();
            metroTextBoxMFee.Text   = m.getModulefee();
            loadSessionProfessorModule();
            loadSessionStudentModule();
        }
 private void metroButtonProceedMod_Click(object sender, EventArgs e)
 {
     if (metroComboBoxMods.Text == "Add")
     {
         if (metroTextBoxModuleId.Text == "" || metroTextBoxModuleName.Text == "" || metroTextBoxFaculty.Text == "" || metroTextBoxFaculty.Text == "" || metroTextBoxDuration.Text == "" || metroTextBoxFee.Text == "" || metroTextBoxDescription.Text == "")
         {
             MetroMessageBox.Show(this, "Please fill all fields in order to add a new Module!");
         }
         else
         {
             CommonDBTransaction c = new CommonDBTransaction();
             string    sql         = "SELECT * FROM Module WHERE MId = '" + metroTextBoxModuleId.Text + "'";
             DataTable d           = c.searchData(sql);
             metroGridModules.DataSource = d;
             if (d.Rows.Count > 0)
             {
                 MetroMessageBox.Show(this, "This Data already exist");
             }
             else
             {
                 Module             obj = new Module(metroTextBoxModuleId.Text, metroTextBoxModuleName.Text, metroTextBoxFaculty.Text, metroComboBoxSemester.Text, metroTextBoxDuration.Text, metroTextBoxFee.Text, metroTextBoxDescription.Text);
                 ModuleTransactions tr  = new ModuleTransactions();
                 tr.addModule(obj);
                 MetroMessageBox.Show(this, "Data Saved Sucessfully !");
                 clearModule();
                 metroGridModules.Refresh();
             }
         }
     }
     else if (metroComboBoxMods.Text == "Update")
     {
         if (metroTextBoxModuleId.Text == "" || metroTextBoxModuleName.Text == "" || metroTextBoxFaculty.Text == "" || metroTextBoxFaculty.Text == "" || metroTextBoxDuration.Text == "" || metroTextBoxFee.Text == "" || metroTextBoxDescription.Text == "")
         {
             MetroMessageBox.Show(this, "Please fill all fields in order to add a new Module!");
         }
         else
         {
             Module             obj = new Module(metroTextBoxModuleId.Text, metroTextBoxModuleName.Text, metroTextBoxFaculty.Text, metroComboBoxSemester.Text, metroTextBoxDuration.Text, metroTextBoxFee.Text, metroTextBoxDescription.Text);
             ModuleTransactions tr  = new ModuleTransactions();
             tr.updateModule(obj);
             MetroMessageBox.Show(this, "Data Saved Sucessfully !");
             clearModule();
             metroGridModules.Refresh();
         }
     }
     else if (metroComboBoxMods.Text == "Search")
     {
         Module             obj = new Module();
         ModuleTransactions tr2 = new ModuleTransactions();
         try
         {
             obj = tr2.datafill(metroTextBoxSearchMod.Text);
             metroTextBoxModuleId.Text    = obj.getID();
             metroTextBoxModuleName.Text  = obj.getMName();
             metroTextBoxFaculty.Text     = obj.getFaculty();
             metroComboBoxSemester.Text   = obj.getSemester();
             metroTextBoxDuration.Text    = obj.getDuration();
             metroTextBoxFee.Text         = obj.getModulefee();
             metroTextBoxDescription.Text = obj.getModuleOverview();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Stafford University Registration System", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else if (metroComboBoxMods.Text == "Delete")
     {
         if (metroGridModules.Rows.Count == 0)
         {
             MetroMessageBox.Show(this, "No data found to delete");
         }
         else
         {
             DialogResult del = MessageBox.Show("Are you Sure you want to delete :" + metroTextBoxSearchMod.Text + "", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (del == DialogResult.Yes)
             {
                 ModuleTransactions tr3 = new ModuleTransactions();
                 try
                 {
                     tr3.deleteStudentModule(metroTextBoxSearchMod.Text);
                     tr3.deleteModule(metroTextBoxSearchMod.Text);
                     MetroMessageBox.Show(this, "Successfully Deleted");
                     metroGridModules.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!");
     }
 }