Ejemplo n.º 1
0
        public ActionResult Index()
        {
            StudentTransactions st           = new StudentTransactions();
            List <Student>      listStudents = st.loadStudents();

            return(View(listStudents));
        }
        void DataGridViewStudents()
        {
            StudentTransactions c = new StudentTransactions();
            string    sql         = "SELECT * FROM Student";
            DataTable dt          = c.searchData(sql);

            metroGridStudents.DataSource = dt;
        }
        private void StudentHome_Load(object sender, EventArgs e)
        {
            metroLabelUser.Text = Login.u; //logged in user name
            StudentTransactions st = new StudentTransactions();

            s     = st.getStudentId(metroLabelUser.Text); // get user id
            stdId = s.getid();
            //execute methods onload
            loadCombo();
            loadComboShowMods();
            loadComboTab();
        }
Ejemplo n.º 4
0
        private void metroButton3_Click(object sender, EventArgs e)
        {
            StudentTransactions c = new StudentTransactions();
            string    sql         = "SELECT * FROM StudentModule";
            DataTable dt          = c.searchData(sql);

            metroGridMRos.DataSource = dt;
            if (dt.Rows.Count > 0)
            {
                metroLabeltotal.Text = metroGridMRos.Rows.Count.ToString();
            }
            else
            {
                MetroMessageBox.Show(this, "Still no one has registered for the " + metroComboBoxMr.Text + " Courses.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
        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 metroButtonSearch_Click(object sender, EventArgs e)
        {
            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);
            }
        }
 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!");
     }
 }