Пример #1
0
        private void mnuViewAll_Click(object sender, EventArgs e)
        {
            //passes the data grid view to the ViewAll function and refreshes the data grid view on the form
            clsAssessment objAssessment = new clsAssessment();

            objAssessment.ViewAll(dgvAssessment);
        }
Пример #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (!clsValidation.ValidateTextBoxForNumeric(txtAssessmentID))
            {
                txtAssessmentID.Focus();
                return;
            }
            //creates an assessment object with only the id value
            clsAssessment objAssessment = new clsAssessment(Convert.ToInt32(txtAssessmentID.Text));

            //runs the search function for the created object
            bool valid = objAssessment.Search();

            //if an assessment was found in the Search function, then set the form elements to the supplied values
            if (valid)
            {
                txtAssessmentName.Text = objAssessment.AssessmentName;
                cmbUnitID.Text         = objAssessment.UnitID.ToString();
                cmbUnitName.Text       = objAssessment.UnitName;
                cmbTeacherID.Text      = objAssessment.TeacherID.ToString();
                cmbTeacherName.Text    = objAssessment.TeacherFirstName + " " + objAssessment.TeacherLastName;
                dtpStartDate.Value     = DateTime.Parse(objAssessment.StartDate);
                dtpDueDate.Value       = DateTime.Parse(objAssessment.DueDate);
            }
        }
Пример #3
0
        private void AssessmentForm_Load(object sender, EventArgs e)
        {
            //passes the comboboxes that need to be popluated from the database and passes the data grid view
            //then runs the Load and ViewAll functions upon loading the form
            clsAssessment objAssessment = new clsAssessment();

            ComboBox[] cmb = new ComboBox[] { cmbUnitID, cmbUnitName, cmbTeacherID, cmbTeacherName };
            objAssessment.Load(cmb);
            objAssessment.ViewAll(dgvAssessment);
            //loaded = true;
        }
Пример #4
0
        private void mnuUpdate_Click(object sender, EventArgs e)
        {
            #region Validation Area
            if (!clsValidation.ValidateTextBoxForNumeric(txtAssessmentID))
            {
                txtAssessmentID.Focus();
                return;
            }
            if (!clsValidation.ValidateComboBox(cmbUnitName))
            {
                return;
            }
            if (!clsValidation.ValidateComboBox(cmbTeacherName))
            {
                return;
            }
            if (!clsValidation.ValidateTextBox(txtAssessmentName))
            {
                txtAssessmentName.Focus();
                return;
            }
            if (!clsValidation.ValidateDate(dtpStartDate))
            {
                return;
            }
            if (!clsValidation.ValidateDate(dtpDueDate))
            {
                return;
            }
            if (!clsValidation.ValidateDateStartVsEnd(dtpStartDate, dtpDueDate))
            {
                return;
            }
            #endregion
            //create an assessment object with all values
            clsAssessment objAssessment = new clsAssessment(Convert.ToInt32(txtAssessmentID.Text), txtAssessmentName.Text,
                                                            Convert.ToInt32(cmbUnitID.Text), Convert.ToInt32(cmbTeacherID.Text),
                                                            dtpStartDate.Value.ToString("yyyy-MM-dd"), dtpDueDate.Value.ToString("yyyy-MM-dd"));

            //run the Update value for the created object
            objAssessment.Update();
            MessageBox.Show("Assessment successfully updated");

            //refresh the data grid view
            objAssessment.ViewAll(dgvAssessment);
        }
Пример #5
0
        private void mnuDelete_Click(object sender, EventArgs e)
        {
            if (!clsValidation.ValidateTextBoxForNumeric(txtAssessmentID))
            {
                txtAssessmentID.Focus();
                return;
            }
            //create and assessment object with only the id
            clsAssessment objAssessment = new clsAssessment(Convert.ToInt32(txtAssessmentID.Text));

            //run the Delete function
            objAssessment.Delete();
            MessageBox.Show("Assessment successfully deleted");

            //refresh the data grid view
            objAssessment.ViewAll(dgvAssessment);
        }
Пример #6
0
        private void mnuAdd_Click(object sender, EventArgs e)
        {
            #region Validation Area
            if (!clsValidation.ValidateComboBox(cmbUnitName))
            {
                return;
            }
            if (!clsValidation.ValidateComboBox(cmbTeacherName))
            {
                return;
            }
            if (!clsValidation.ValidateTextBox(txtAssessmentName))
            {
                txtAssessmentName.Focus();
                return;
            }
            if (!clsValidation.ValidateForAlphabet(txtAssessmentName))
            {
                txtAssessmentName.Focus();
                return;
            }
            if (!clsValidation.ValidateDate(dtpStartDate))
            {
                return;
            }
            if (!clsValidation.ValidateDate(dtpDueDate))
            {
                return;
            }
            if (!clsValidation.ValidateDateStartVsEnd(dtpStartDate, dtpDueDate))
            {
                return;
            }
            #endregion
            //create an assessment object with the supplied values
            clsAssessment objAssessment = new clsAssessment(txtAssessmentName.Text, Convert.ToInt32(cmbUnitID.Text),
                                                            Convert.ToInt32(cmbTeacherID.Text), dtpStartDate.Value.ToString("yyyy-MM-dd"),
                                                            dtpDueDate.Value.ToString("yyyy-MM-dd"));

            //run the Add function for the object created
            objAssessment.Add();
            MessageBox.Show("Assessment successfully added");

            //refresh the data grid view
            objAssessment.ViewAll(dgvAssessment);
        }