private void BtnAdd_Click(object sender, EventArgs e) { if (txtFullName.Text == "" || txtDoB.Text == "" || txtContact.Text == "" || txtAddress.Text == "" || txtUser.Text == "" || txtPass.Text == "") { MessageBox.Show("Please Fill all the provided blanks!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { for (int i = 0; i < grdStaff.Rows.Count; i++) { if (grdStaff.Rows[i].Cells[5].Value.ToString() == txtUser.Text) { MessageBox.Show("Username already exists", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } { LoginBLL bll = new LoginBLL(); tblLogin user = new tblLogin(); txtUserID.Text = generateID(); user.ID = txtUserID.Text; user.FullName = txtFullName.Text; user.Age = txtDoB.Text; user.Address = txtAddress.Text; user.Contact = txtContact.Text; user.Username = txtUser.Text; user.Password = txtPass.Text; bool result = bll.AddUserDAL(user); if (result == true) { MessageBox.Show("Add new User successful!", "Success", MessageBoxButtons.OK); FrmStaffManage_Load(sender, e); } else { MessageBox.Show("Can't Add User", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }