Пример #1
0
        public void display_account_data()
        {
            accnts = new classes.Accounts();

            string search = cbSearchBy.Text;

            switch (search)
            {
            case "Username":
                account_table = accnts.select_account_table("username", txtSearch.Text);
                break;

            case "User Type":
                account_table = accnts.select_account_table("user_type", txtSearch.Text);
                break;

            case "--Search by--":
                account_table = accnts.select_account_table();
                break;

            default:
                account_table = accnts.select_account_table();
                break;
            }

            dgvManageAccount.DataSource          = account_table;
            dgvManageAccount.AutoGenerateColumns = false;

            if (dgvManageAccount.Columns.Contains("action") && dgvManageAccount.Columns["action"].Visible)
            {
            }
            else
            {
                DataGridViewButtonColumn button = new DataGridViewButtonColumn();
                {
                    button.Name       = "action";
                    button.HeaderText = "Action";
                    button.Text       = "Update Account";
                    button.UseColumnTextForButtonValue = true;
                    this.dgvManageAccount.Columns.Add(button);
                }
            }
        }
Пример #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (cbEmployee.SelectedIndex == 0 || cbEmployee.SelectedIndex == -1)
     {
         MessageBox.Show("Please select the employee.", "Add Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
         cbEmployee.Focus();
         return;
     }
     else
     {
         acts = new classes.Accounts();
         int employee_id = Convert.ToInt32(cbEmployee.SelectedValue);
         if (acts.add_administrator(employee_id))
         {
             MessageBox.Show(cbEmployee.Text.ToUpper() + " has been set as administrator.", "Add Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information);
             uc.frmDashboard.admin.mu.ucManageAccount.instance.display_account_data();
             this.Close();
         }
         else
         {
             return;
         }
     }
 }
Пример #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtStudentNumber.Text == "Student Number" || string.IsNullOrEmpty(txtStudentNumber.Text))
            {
                MessageBox.Show("Please indicate the student number.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStudentNumber.Text = "";
                txtStudentNumber.Focus();
                return;
            }
            else
            {
                if (txtFirstName.Text == "First Name" || string.IsNullOrEmpty(txtFirstName.Text))
                {
                    MessageBox.Show("Please indicate the first name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtFirstName.Text = "";
                    txtFirstName.Focus();
                    return;
                }
                else
                {
                    if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                    {
                        MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtLastName.Text = "";
                        txtLastName.Focus();
                        return;
                    }
                    else
                    {
                        if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                        {
                            MessageBox.Show("Please indicate the last name.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtLastName.Text = "";
                            txtLastName.Focus();
                            return;
                        }
                        else
                        {
                            if (cbCourse.SelectedIndex == 0 || cbCourse.SelectedIndex == -1)
                            {
                                MessageBox.Show("Please indicate the course.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                cbCourse.Focus();
                                return;
                            }
                            else
                            {
                                if (cbYearLevel.SelectedIndex == 0 || cbYearLevel.SelectedIndex == -1)
                                {
                                    MessageBox.Show("Please indicate the year level.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    cbYearLevel.Focus();
                                    return;
                                }
                                else
                                {
                                    if (cbStatus.SelectedIndex == 0 || cbStatus.SelectedIndex == -1)
                                    {
                                        MessageBox.Show("Please indicate the status.", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                        cbStatus.Focus();
                                        return;
                                    }
                                    else
                                    {
                                        string student_number  = txtStudentNumber.Text;
                                        string first_name      = txtFirstName.Text;
                                        string middle_name     = (txtMiddleName.Text == "Middle Name") ? string.Empty : txtMiddleName.Text;
                                        string last_name       = txtLastName.Text;
                                        string contact_number  = (txtContactNumber.Text == "Contact Number") ? string.Empty : txtContactNumber.Text;
                                        string email           = (txtEmail.Text == "Email") ? string.Empty : txtEmail.Text;
                                        int    course_id       = Convert.ToInt32(cbCourse.SelectedValue);
                                        string year_level      = cbYearLevel.Text;
                                        string status          = cbStatus.Text;
                                        Byte[] profile_picture = classes.Configuration.ConvertScreenCaptureToByte(pbPreview.Image);

                                        personal_information = new classes.PersonalInformation();
                                        if (personal_information.insert_personal_information(first_name, middle_name, last_name, contact_number, email, profile_picture))
                                        {
                                            student = new classes.Student();
                                            if (student.insert_student(student_number, course_id, year_level, status))
                                            {
                                                account = new classes.Accounts();
                                                if (account.insert_account(student_number, "Student"))
                                                {
                                                    MessageBox.Show((first_name + " " + last_name).ToUpper() + " has been added!", "Add Student", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                    includes.uc.frmDashboard.admin.mu.ucManageStudent.instance.display_student_data();
                                                    this.Close();
                                                }
                                                else
                                                {
                                                    return;
                                                }
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtEmployeeID.Text == "Employee ID" || string.IsNullOrEmpty(txtEmployeeID.Text))
            {
                MessageBox.Show("Please indicate the employee id.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmployeeID.Text = "";
                txtEmployeeID.Focus();
                return;
            }
            else
            {
                if (txtFirstName.Text == "First Name" || string.IsNullOrEmpty(txtFirstName.Text))
                {
                    MessageBox.Show("Please indicate the first name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtFirstName.Text = "";
                    txtFirstName.Focus();
                    return;
                }
                else
                {
                    if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                    {
                        MessageBox.Show("Please indicate the last name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtLastName.Text = "";
                        txtLastName.Focus();
                        return;
                    }
                    else
                    {
                        if (txtLastName.Text == "Last Name" || string.IsNullOrEmpty(txtLastName.Text))
                        {
                            MessageBox.Show("Please indicate the last name.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtLastName.Text = "";
                            txtLastName.Focus();
                            return;
                        }
                        else
                        {
                            if (cbDepartment.SelectedIndex == 0 || cbDepartment.SelectedIndex == -1)
                            {
                                MessageBox.Show("Please indicate the department.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                cbDepartment.Focus();
                                return;
                            }
                            else
                            {
                                if (cbPosition.SelectedIndex == 0 || cbPosition.SelectedIndex == -1)
                                {
                                    MessageBox.Show("Please indicate the position.", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    cbPosition.Focus();
                                    return;
                                }
                                else
                                {
                                    string employee_id     = txtEmployeeID.Text;
                                    string first_name      = txtFirstName.Text;
                                    string middle_name     = (txtMiddleName.Text == "Middle Name") ? string.Empty : txtMiddleName.Text;
                                    string last_name       = txtLastName.Text;
                                    string contact_number  = (txtContactNumber.Text == "Contact Number") ? string.Empty : txtContactNumber.Text;
                                    string email           = (txtEmail.Text == "Email") ? string.Empty : txtEmail.Text;
                                    int    department_id   = Convert.ToInt32(cbDepartment.SelectedValue);
                                    int    position_id     = Convert.ToInt32(cbPosition.SelectedValue);
                                    Byte[] profile_picture = classes.Configuration.ConvertScreenCaptureToByte(pbPreview.Image);

                                    personal_information = new classes.PersonalInformation();
                                    if (personal_information.insert_personal_information(first_name, middle_name, last_name, contact_number, email, profile_picture))
                                    {
                                        employee = new classes.Employee();
                                        if (employee.insert_employee(employee_id, department_id, position_id))
                                        {
                                            account = new classes.Accounts();
                                            if (account.insert_account(employee_id, "Employee"))
                                            {
                                                MessageBox.Show((first_name + " " + last_name).ToUpper() + " has been added!", "Add Employee", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                includes.uc.frmDashboard.admin.mu.ucManageEmployee.instance.display_employee_data();
                                                this.Close();
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }