private void metrobuttonAssignMod_Click(object sender, EventArgs e)
 {
     if (metroComboBoxMod.Text == "" && metroTextBoxFac.Text == "" && metroTextBoxDur.Text == "" && metroTextBoxMFee.Text == "" && metroTextBoxModule.Text == "" && metroTextBoxStDate.Text == "" && metroTextBoxEDate.Text == "")
     {
         MetroMessageBox.Show(this, "Fields cannot be left empty");
     }
     else
     {
         CommonDBTransaction c = new CommonDBTransaction();
         string    sql         = "SELECT * FROM AssignModule WHERE mid ='" + metroComboBoxMod.Text + "'";
         DataTable d           = c.searchData(sql);
         if (d.Rows.Count > 0)
         {
             MetroMessageBox.Show(this, "This Data already exist");
         }
         else
         {
             if (metroGridProf.Rows.Count < 2)
             {
                 MetroMessageBox.Show(this, "Insuffcient Students for the module requirement!");
             }
             else if (metroGridProf.Rows.Count > 9)
             {
                 MetroMessageBox.Show(this, "The number of students for this module has been equiped with!");
             }
             else
             {
                 AssignModule am = new AssignModule();
                 am.setmid(metroComboBoxMod.Text);
                 am.setprogramme(metroTextBoxModule.Text);
                 am.setfaculty(metroTextBoxFac.Text);
                 am.setmodfee(metroTextBoxMFee.Text);
                 am.setduration(metroTextBoxDur.Text);
                 am.setstarddate(metroTextBoxStDate.Text);
                 am.setenddate(metroTextBoxEDate.Text);
                 StringBuilder sb        = new StringBuilder();
                 string        seperator = "";
                 for (int i = 0; i < metroGridStd.Rows.Count; i++)
                 {
                     sb.AppendFormat("{0}{1}", seperator, metroGridStd.Rows[i].Cells[0].Value.ToString());
                     seperator = ",";
                 }
                 string lid = sb.ToString();
                 am.setlid(lid);
                 StringBuilder sb1        = new StringBuilder();
                 string        seperator1 = "";
                 for (int i = 0; i < metroGridProf.Rows.Count; i++)
                 {
                     sb1.AppendFormat("{0}{1}", seperator1, metroGridProf.Rows[i].Cells[0].Value.ToString());
                     seperator1 = ",";
                 }
                 string sid = sb1.ToString();
                 am.setsid(sid);
                 AssignModuleTransaction amt = new AssignModuleTransaction();
                 amt.addModule(am);
             }
         }
     }
 }
 private void metroButtonDrops_Click(object sender, EventArgs e)
 {
     //validate data
     if (metroComboBoxModl.Text == "")
     {
         MetroMessageBox.Show(this, "Please select module to proceed!");
     }
     else
     {
         AssignModuleTransaction amt = new AssignModuleTransaction();
         amt.deleteStudentModule(metroComboBoxModl.Text);    // delete data from db
         MetroMessageBox.Show(this, "Successfully Deleted"); // message
     }
 }
Esempio n. 3
0
        private void metroButton2_Click(object sender, EventArgs e)
        {
            AssignModule            am  = new AssignModule();
            AssignModuleTransaction amt = new AssignModuleTransaction();

            try
            {
                am = amt.fillDataProf(metroComboBoxRMods.Text);
                metroComboBoxRMods.Text  = am.getmid();
                metroTextBoxFacM.Text    = am.getfaculty();
                metroTextBoxP.Text       = am.getprogramme();
                metroTextBoxModFees.Text = am.getmodfee();
                metroTextBoxStd.Text     = am.getstartdate();
                metroTextBoxEnd.Text     = am.getenddate();
            }
            catch
            {
                MetroMessageBox.Show(this, "Course not yet assinged");
            }
        }
        private void metroComboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            //load values to input fields
            AssignModule            am  = new AssignModule();
            AssignModuleTransaction amt = new AssignModuleTransaction();

            try
            {
                am = amt.fillData(metroComboBoxMods.Text);
                metroComboBoxMods.Text   = am.getmid();
                metroTextBoxMFac.Text    = am.getfaculty();
                metroTextBoxProgram.Text = am.getprogramme();
                metroTextBoxMFees.Text   = am.getmodfee();
                metroTextBoxstDate.Text  = am.getstartdate();
                metroTextBoxedDate.Text  = am.getenddate();
            }
            catch
            {
                MetroMessageBox.Show(this, "Course not yet assinged");
            }
        }