Ejemplo n.º 1
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            string uname                 = metroLabeluname.Text;
            CommonDBTransaction c        = new CommonDBTransaction();
            string              sqlcheck = "SELECT PId FROM Professor WHERE username= '******'";
            DataTable           d        = c.searchData(sqlcheck);
            string              profid   = d.ToString();
            CommonDBTransaction co       = new CommonDBTransaction();

            modId = metroComboBoxMod.Text;
            string    sql = "SELECT * FROM ProfessorModule WHERE pId = '" + profid + "'AND mid='" + modId + "'";
            DataTable dt  = co.searchData(sql);

            if (dt.Rows.Count > 0)
            {
                MetroMessageBox.Show(this, "You have already registered for this module!", "Warning");
                metroGridSelectMod.DataSource = dt;
                metroGridSelectMod.Refresh();
            }
            else
            {
                pt.addProffessorModule();
                MetroMessageBox.Show(this, "Registration successful");
            }
        }
 private void metroButtonRegAddU_Click(object sender, EventArgs e)
 {
     if (metroTextBoxUnames.Text == "" || metroTextBoxPws.Text == "")
     {
         MessageBox.Show("Fields cannot be empty");
     }
     else
     {
         CommonDBTransaction c = new CommonDBTransaction();
         string    sql         = "SELECT * FROM Registar WHERE Username = '******'";
         DataTable d           = c.searchData(sql);
         metroGridRegs.DataSource = d;
         if (d.Rows.Count > 0)
         {
             MetroMessageBox.Show(this, "This Data already exist");
         }
         else
         {
             Registar             obj = new Registar(metroTextBoxUnames.Text, metroTextBoxPws.Text);
             RegistarTransactions tr  = new RegistarTransactions();
             tr.addRegistar(obj);
             MetroMessageBox.Show(this, "Data Saved Sucessfully !");
             clearReg();
         }
     }
 }
 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);
             }
         }
     }
 }
        //load faculty
        void loadModuleFaculty()
        {
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT * FROM Module WHERE Faculty='" + metroComboBoxFaculty.Text + "'";
            DataTable dt          = c.searchData(sql);

            metroGridModules.DataSource = dt;
        }
Ejemplo n.º 5
0
        void DataGridViewMod()
        {
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT MId,Programme,Faculty,Semester,Duration,ModuleFee FROM Module WHERE MId='" + metroComboBoxMod.Text + "'";
            DataTable dt          = c.searchData(sql);

            metroGridSelectMod.DataSource = dt;
        }
        void loadSessionProfessorModule()
        {
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT * FROM ProfessorModule WHERE mid = '" + metroComboBoxMod.Text + "'";
            DataTable dt          = c.searchData(sql);

            if (dt.Rows.Count > 0)
            {
                metroGridProf.DataSource = dt;
            }
        }
Ejemplo n.º 7
0
        void ViewModules()
        {
            DataRow             dr;
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT MId FROM Module";
            DataTable dt          = c.searchData(sql);

            dr           = dt.NewRow();
            dr.ItemArray = new object[] { "--Select Module--" };
            dt.Rows.InsertAt(dr, 0);
            metroComboBoxMod.ValueMember   = "MId";
            metroComboBoxMod.DisplayMember = "MId";
            metroComboBoxMod.DataSource    = dt;
        }
        Student s = new Student(); //student instance
        //load combo box
        void loadCombo()
        {
            DataRow             dr;
            CommonDBTransaction c = new CommonDBTransaction();                   // new insance
            string    sql         = "SELECT * FROM Module";
            DataTable dt          = c.searchData(sql);                           // execute query

            if (metroTabControlStudent.SelectedTab.Equals(metroTabPageRegister)) // based on page execute code
            {
                dr           = dt.NewRow();
                dr.ItemArray = new object[] { "--Select Faculty--" }; // load data to array
                dt.Rows.InsertAt(dr, 0);
                metroComboBoxFaculty.ValueMember   = "Faculty";       //displat only faculty
                metroComboBoxFaculty.DisplayMember = "Faculty";
                metroComboBoxFaculty.DataSource    = dt;
            }
        }
Ejemplo n.º 9
0
        void loadComboShowMods()
        {
            DataRow             dr;
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT mid FROM ProfessorModule WHERE pId = '" + profid + "'";
            DataTable dt          = c.searchData(sql);

            if (dt.Rows.Count > 0)
            {
                dr           = dt.NewRow();
                dr.ItemArray = new object[] { "--Select Module--" };
                dt.Rows.InsertAt(dr, 0);
                metroComboBoxRMods.ValueMember   = "mid";
                metroComboBoxRMods.DisplayMember = "mid";
                metroComboBoxRMods.DataSource    = dt;
            }
        }
        void DataGridViewModules()
        {
            DataRow             dr;
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT * FROM Module";
            DataTable dt          = c.searchData(sql);

            metroGridModules.DataSource = dt;
            if (metroTabControlR.SelectedTab.Equals(AssignModules))
            {
                dr           = dt.NewRow();
                dr.ItemArray = new object[] { "--Select Module--" };
                dt.Rows.InsertAt(dr, 0);
                metroComboBoxMod.ValueMember   = "MId";
                metroComboBoxMod.DisplayMember = "MId";
                metroComboBoxMod.DataSource    = dt;
            }
        }
Ejemplo n.º 11
0
        void loadComboTab()
        {
            DataRow             dr;
            CommonDBTransaction c = new CommonDBTransaction();
            string    sql         = "SELECT mid FROM StudentModule";
            DataTable dt          = c.searchData(sql);

            if (metroTabControlP.SelectedTab.Equals(metroTabPageModuleRoster))
            {
                if (dt.Rows.Count > 0)
                {
                    dr           = dt.NewRow();
                    dr.ItemArray = new object[] { "--Select Module--" };
                    dt.Rows.InsertAt(dr, 0);
                    metroComboBoxMr.ValueMember   = "mid";
                    metroComboBoxMr.DisplayMember = "mid";
                    metroComboBoxMr.DataSource    = dt;
                }
            }
        }
        void loadComboTab()
        {
            StudentTransactions std = new StudentTransactions();

            std.getStudentId(metroLabelUser.Text);
            String              stid = s.getid();
            DataRow             dr;
            CommonDBTransaction c   = new CommonDBTransaction();
            string              sql = "SELECT mid FROM StudentModule WHERE sid = '" + stid + "'";
            DataTable           dt  = c.searchData(sql);

            if (dt.Rows.Count > 0)
            {
                dr           = dt.NewRow();
                dr.ItemArray = new object[] { "--Select Module--" };
                dt.Rows.InsertAt(dr, 0);
                metroComboBoxModl.ValueMember   = "mid";
                metroComboBoxModl.DisplayMember = "mid";
                metroComboBoxModl.DataSource    = dt;
            }
        }
 private void metroButtonRegister_Click(object sender, EventArgs e)
 {
     //validate data
     if (metroTextBoxModId.Text == "" || metroTextBoxMod.Text == "" || metroComboBoxFaculty.Text == "" || metroTextBoxSem.Text == "" || metroTextBoxDuration.Text == "" || metroTextBoxMFee.Text == "" || metroTextBoxMOverview.Text == "")
     {
         MetroMessageBox.Show(this, "Fields cannot be left empty");
     }
     else
     {
         modId = metroTextBoxModId.Text;
         StudentTransactions st       = new StudentTransactions();
         string uname                 = metroLabelUser.Text;
         CommonDBTransaction c        = new CommonDBTransaction();
         string              sqlcheck = "SELECT SId FROM Student WHERE username= '******'";
         DataTable           d        = c.searchData(sqlcheck);//validate data from db
         string              profid   = d.ToString();
         CommonDBTransaction co       = new CommonDBTransaction();
         modId = metroTextBoxModId.Text;
         string    sql = "SELECT * FROM StudentModule WHERE sid = '" + profid + "'AND mid='" + modId + "'";
         DataTable dt  = co.searchData(sql);//validate data from db
         if (dt.Rows.Count > 0)
         {
             MetroMessageBox.Show(this, "You have already registered for this module!", "Warning");
             metroGridModules.DataSource = dt;
             metroGridModules.Refresh();
         }
         else
         {
             st.addstudentModule(); // insert data
             modFee = metroTextBoxMFee.Text;
             Bill            b  = new Bill(modFee, stdId, modId);
             BillTransaction bt = new BillTransaction();
             bt.addBill(b); //insert data
             this.Hide();
             Billing bill = new Billing();
             bill.Show();
             MetroMessageBox.Show(this, "Registration successful");
         }
     }
 }
 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!");
     }
 }
 private void metroButtonProceed_Click(object sender, EventArgs e)
 {
     if (metroComboBoxOptStd.Text == "Add")
     {
         if (metroTextBoxStudentId.Text == "" || metroTextBoxFirstName.Text == "" || metroTextBoxLastName.Text == "" || metroTextBoxDOB.Text == "" || metroTextBoxMobileNo.Text == "" || metroTextBoxEmail.Text == "" || metroTextBoxAddress.Text == "" || metroComboBoxGen.Text == "" || metroTextBoxUsername.Text == "" || metroTextBoxPassword.Text == "")
         {
             MetroMessageBox.Show(this, "Fields cannot be left empty");
         }
         if (!Regex.Match(metroTextBoxMobileNo.Text, @"^\d{10}$").Success)
         {
             MetroMessageBox.Show(this, "Please re-enter the contact number", "Warning");
             metroTextBoxMobileNo.Focus();
         }
         if (!Regex.Match(metroTextBoxEmail.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,4})+)$").Success)
         {
             MetroMessageBox.Show(this, "Invalid E-Mail address Please re-enter correct address");
             metroTextBoxEmail.Focus();
         }
         else
         {
             CommonDBTransaction c = new CommonDBTransaction();
             string    sql         = "SELECT * FROM Student WHERE SId = '" + metroTextBoxStudentId.Text + "' or Username = '******'";
             DataTable d           = c.searchData(sql);
             metroGridStudents.DataSource = d;
             if (d.Rows.Count > 0)
             {
                 MetroMessageBox.Show(this, "This Data already exist");
             }
             else
             {
                 Student             obj = new Student(metroTextBoxStudentId.Text, metroTextBoxFirstName.Text, metroTextBoxLastName.Text, metroTextBoxDOB.Text, metroTextBoxMobileNo.Text, metroTextBoxEmail.Text, metroTextBoxAddress.Text, metroComboBoxGen.Text, metroTextBoxUsername.Text, metroTextBoxPassword.Text);
                 StudentTransactions tr  = new StudentTransactions();
                 tr.addstudent(obj);
                 MetroMessageBox.Show(this, "Data Saved Sucessfully !");
                 clearStudent();
                 metroGridStudents.Refresh();
             }
         }
     }
     else if (metroComboBoxOptStd.Text == "Update")
     {
         if (metroTextBoxStudentId.Text == "" || metroTextBoxFirstName.Text == "" || metroTextBoxLastName.Text == "" || metroTextBoxDOB.Text == "" || metroTextBoxMobileNo.Text == "" || metroTextBoxEmail.Text == "" || metroTextBoxAddress.Text == "" || metroComboBoxGen.Text == "" || metroTextBoxUsername.Text == "" || metroTextBoxPassword.Text == "")
         {
             MetroMessageBox.Show(this, "Fields cannot be left empty");
         }
         if (!Regex.Match(metroTextBoxMobileNo.Text, @"^\d{10}$").Success)
         {
             MetroMessageBox.Show(this, "Please re-enter the contact number", "Warning");
             metroTextBoxMobileNo.Focus();
         }
         if (!Regex.Match(metroTextBoxEmail.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,4})+)$").Success)
         {
             MetroMessageBox.Show(this, "Invalid E-Mail address Please re-enter correct address");
             metroTextBoxEmail.Focus();
         }
         else
         {
             Student             obj = new Student(metroTextBoxStudentId.Text, metroTextBoxFirstName.Text, metroTextBoxLastName.Text, metroTextBoxDOB.Text, metroTextBoxMobileNo.Text, metroTextBoxEmail.Text, metroTextBoxAddress.Text, metroComboBoxGen.Text, metroTextBoxUsername.Text, metroTextBoxPassword.Text);
             StudentTransactions tr  = new StudentTransactions();
             tr.updateStudent(obj);
             MetroMessageBox.Show(this, "Data Saved Sucessfully !");
             clearStudent();
             metroGridStudents.Refresh();
         }
     }
     else if (metroComboBoxOptStd.Text == "Search")
     {
         Student             obj = new Student();
         StudentTransactions tr2 = new StudentTransactions();
         try
         {
             obj = tr2.dataFill(metroTextSearch.Text);
             metroTextBoxStudentId.Text = obj.getid();
             metroTextBoxFirstName.Text = obj.getFirstName();
             metroTextBoxLastName.Text  = obj.getLastName();
             metroTextBoxDOB.Text       = obj.getDOB();
             metroTextBoxMobileNo.Text  = obj.getContactNo();
             metroTextBoxEmail.Text     = obj.getEmail();
             metroTextBoxAddress.Text   = obj.getAddress();
             metroComboBoxGen.Text      = obj.getGender();
             metroTextBoxUsername.Text  = obj.getUsername();
             metroTextBoxPassword.Text  = obj.getPassword();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Stafford University Registration System", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else if (metroComboBoxOptStd.Text == "Delete")
     {
         if (metroGridStudents.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)
             {
                 StudentTransactions tr3 = new StudentTransactions();
                 try
                 {
                     tr3.deleteFromStudentModule(metroTextBoxStudentId.Text);
                     tr3.deleteStudent(metroTextBoxStudentId.Text);
                     MetroMessageBox.Show(this, "Successfully Deleted");
                     clearStudent();
                 }
                 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!");
     }
 }