private void btnEdit_Click(object sender, EventArgs e)
        {
            Accounts acc = accountsBindingSource.Current as Accounts;

            if (acc == null)
            {
                return;
            }
            else
            {
                if (acc.level == 1)
                {
                    comboPosRe.Visible = false;
                    labelPos.Visible   = false;
                }
                comboPosFilter.Enabled = false;
                dataGridView.Enabled   = false;
                panCRUD.Enabled        = false;
                panSave.Enabled        = true;
                txtUserName.Enabled    = false;
                txtPass.Enabled        = false;
                txtConPass.Enabled     = false;
                panSearch.Enabled      = false;
                comboPosRe.Enabled     = true;
                comboPosRe.DataSource  = PositionBUS.GetAll();
            }
        }
Exemple #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure want to delete this name?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
     {
         Positions pos = positionsBindingSource.Current as Positions;
         PositionBUS.delete(pos);
         positionsBindingSource.RemoveCurrent();
     }
 }
Exemple #3
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearch.Text))
     {
         MessageBox.Show("Search field is empty!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         positionsBindingSource.DataSource = PositionBUS.search(txtSearch.Text);
         Positions pos = positionsBindingSource.Current as Positions;
         txtSearch.Clear();
     }
 }
 private void btnAdd_Click(object sender, EventArgs e)
 {
     comboPosRe.DataSource = PositionBUS.GetAll();
     accountsBindingSource.Add(new Accounts());
     accountsBindingSource.MoveLast();
     dataGridView.Enabled = false;
     panCRUD.Enabled      = false;
     panSave.Enabled      = true;
     txtConPass.Clear();
     txtUserName.Enabled    = true;
     txtPass.Enabled        = true;
     txtConPass.Enabled     = true;
     panSearch.Enabled      = false;
     comboPosFilter.Enabled = false;
 }
Exemple #5
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Positions pos = positionsBindingSource.Current as Positions;

            if (pos.Id != 0)
            {
                panCRUD.Enabled = true;
                panSave.Enabled = false;
                positionsBindingSource.DataSource = PositionBUS.GetAll();
            }
            else
            {
                panCRUD.Enabled = true;
                panSave.Enabled = false;
                positionsBindingSource.RemoveCurrent();
            }
        }
Exemple #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Positions pos = positionsBindingSource.Current as Positions;

            if (string.IsNullOrEmpty(txtPosName.Text))
            {
                MessageBox.Show("Name field is empty!", "Eror", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtPosName.Focus();
            }
            else
            {
                if (pos.Id == 0)
                {
                    if (PositionBUS.checkName(txtPosName.Text) == true)
                    {
                        MessageBox.Show("This name is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPosName.Clear();
                        txtPosName.Focus();
                    }
                    else
                    {
                        PositionBUS.insert(pos);
                        positionsBindingSource.MoveLast();
                        MessageBox.Show("Add successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        panCRUD.Enabled = true;
                        panSave.Enabled = false;
                    }
                }
                else
                {
                    PositionBUS.edit(pos);
                    MessageBox.Show("Update successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    panSave.Enabled = false;
                    panCRUD.Enabled = true;
                }
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            comboPosRe.Visible = true;
            labelPos.Visible   = true;
            Accounts acc      = accountsBindingSource.Current as Accounts;
            string   position = comboPosRe.SelectedValue.ToString();
            string   imageURL = acc.imageURL;

            if (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtPass.Text) || string.IsNullOrEmpty(txtF_Name.Text) || string.IsNullOrEmpty(txtL_Name.Text) || string.IsNullOrEmpty(txtEmail.Text) ||
                string.IsNullOrEmpty(txtPhone.Text) || string.IsNullOrEmpty(txtAddress.Text))
            {
                MessageBox.Show("Please type all the informaton!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Regex pattern = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                if (!pattern.IsMatch(txtEmail.Text))
                {
                    MessageBox.Show("This mail is invalid! Please use another mail.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEmail.Clear();
                    txtEmail.Focus();
                }
                else
                {
                    Regex patternPhone = new Regex(@"[0-9]{10}");
                    if (!patternPhone.IsMatch(txtPhone.Text))
                    {
                        MessageBox.Show("Wrong phone number! Please enter your phone again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtPhone.Focus();
                    }
                    else
                    {
                        if (acc.Id == 0)
                        {
                            if (AccountBUS.checkUsername(txtUserName.Text) == true)
                            {
                                MessageBox.Show("This username is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                txtUserName.Focus();
                            }
                            else
                            {
                                if (txtPass.Text != txtConPass.Text)
                                {
                                    MessageBox.Show("Password does not match the confirm password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    txtConPass.Focus();
                                }
                                else
                                {
                                    AccountBUS.insert(txtUserName.Text, txtPass.Text, txtF_Name.Text, txtL_Name.Text, txtEmail.Text, txtPhone.Text, txtAddress.Text, position, imageURL);
                                    MessageBox.Show("Save successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    accountsBindingSource.DataSource = AccountBUS.GetAll();
                                    accountsBindingSource.MoveLast();
                                    panCRUD.Enabled        = true;
                                    panSave.Enabled        = false;
                                    panSearch.Enabled      = true;
                                    comboPosFilter.Enabled = true;
                                    dataGridView.Enabled   = true;
                                }
                            }
                        }
                        else
                        {
                            positionsBindingSource.DataSource = PositionBUS.GetAll();
                            int id = acc.Id;
                            AccountBUS.edit(acc, id, txtF_Name.Text, txtL_Name.Text, txtEmail.Text, txtPhone.Text, txtAddress.Text, position, imageURL);
                            MessageBox.Show("Save successfully!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            accountsBindingSource.DataSource = AccountBUS.GetAll();
                            panCRUD.Enabled        = true;
                            panSave.Enabled        = false;
                            panSearch.Enabled      = true;
                            dataGridView.Enabled   = true;
                            comboPosFilter.Enabled = true;
                        }
                    }
                }
            }
        }
 private void btnRef_Click(object sender, EventArgs e)
 {
     positionsBindingSource.DataSource = PositionBUS.GetAll();
 }
 private void btnAccRef_Click(object sender, EventArgs e)
 {
     accountsBindingSource.DataSource  = AccountBUS.GetAll();
     positionsBindingSource.DataSource = PositionBUS.GetAll();
 }