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(); } }
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; }
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(); } }
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(); }