示例#1
0
        protected void btnRiderRegister_Click(object sender, EventArgs e)
        {
            Boolean isFullTime;

            if (txtRName.Text.Length <= 0)
            {
                lblRNameMsg.Text = "Name cannot be blank";
            }

            if (txtRUserName.Text.Length <= 0)
            {
                lblRUsernameMsg.Text = "Username cannot be blank";
            }

            if (txtRPassword.Text.Length <= 0)
            {
                lblRPasswordMsg.Text = "Password cannot be blank";
            }

            if (chkBoxFullTime.Checked == true)
            {
                isFullTime = true;
            }

            else
            {
                isFullTime = false;
            }

            if (txtRName.Text.Length > 0 && txtRUserName.Text.Length > 0 && txtRPassword.Text.Length > 0)
            {
                UserAccountBLL uBLL          = new UserAccountBLL();
                int            checkUserName = uBLL.DoCheckUserNameExists(txtRUserName.Text);

                //If username exists
                if (checkUserName > 0)
                {
                    alertFailure.Visible = true;
                    lblAlertMsg.Text     = "Username Exists in Database. Please use another username";
                    ClearTextFieldAndMessages();
                }

                else
                {
                    int result = uBLL.DoCreateNewRider(txtRName.Text, txtRUserName.Text, txtRPassword.Text, isFullTime);

                    if (result > 0)
                    {
                        alertSuccess.Visible = true;
                    }

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