Ejemplo n.º 1
0
        protected void btn_CreateStaff_Click(object sender, EventArgs e)
        {
            if (txtStaffName.Text.Length <= 0)
            {
                lblStaffNameMsg.Text = "Staff Name Cannot Be Blank";
            }

            if (txtStaffUsername.Text.Length <= 0)
            {
                lblStaffUsernameMsg.Text = "Staff Username Cannot Be Blank";
            }

            if (txtStaffPassword.Text.Length <= 0)
            {
                lblStaffPasswordMsg.Text = "Staff Password Cannot Be Blank";
            }

            if (txtStaffName.Text.Length > 0 && txtStaffUsername.Text.Length > 0 && txtStaffPassword.Text.Length > 0)
            {
                UserAccountBLL uBLL          = new UserAccountBLL();
                int            checkUserName = uBLL.DoCheckUserNameExists(txtStaffUsername.Text);

                if (checkUserName > 0)
                {
                    alertFailure.Visible = true;
                    lblAlertMsg.Text     = "Staff Username has already existed";
                }

                else
                {
                    int result = uBLL.DoCreateNewStaff(txtStaffName.Text, txtStaffUsername.Text, txtStaffPassword.Text, Convert.ToInt32(txtRestId.Text));
                    if (result > 0)
                    {
                        alertSuccess.Visible = true;
                    }

                    else
                    {
                        alertFailure.Visible = true;
                        lblAlertMsg.Text     = "Unable to create a new staff account";
                        ClearTextFieldAndMessages();
                    }
                }
            }
        }