Example #1
0
 /// <summary>
 /// Handles all button click events sent from the Login form.
 /// </summary>
 /// <param name="sender">The control that sent the Click event.</param>
 /// <param name="e">The EventArgs related to the sending Control.</param>
 public void ButtonActionHandler(ButtonActionEventArgs e)
 {
     switch ((LoginActions)e.Button.Tag)
     {
         case LoginActions.Login:
             string username = e.Params["username"].ToString();
             string password = e.Params["password"].ToString();
             Login loginView = (Login)e.Params["view"];
             //this.View = loginView;
             this.AuthenticateUser(username, password);
             break;
         case LoginActions.Quit:
             Application.Exit();
             break;
         default:
             break;
     }
 }
Example #2
0
        private void ButtonActionHandlerRedirect(object sender, EventArgs e)
        {
            ButtonActionEventArgs baInfo = new ButtonActionEventArgs();
            baInfo.Button = (Button)sender;

            switch ((LoginActions)baInfo.Button.Tag)
            {
                case LoginActions.Login:
                    // Validation checks need to moved from here to the model or controller?
                    if (this.cmbUserType.SelectedItem == null)
                    {
                        errorProvider.SetError(cmbUserType, "No User Type selected!");
                        this.labelValidationError.Visible = true;
                        this.labelValidationError.Text = "No User Type selected!";
                        return;
                    }
                    else if (this.txtPassword.Text == string.Empty)
                    {
                        errorProvider.SetError(txtPassword, "No password entered!");
                        this.labelValidationError.Visible = true;
                        this.labelValidationError.Text = "No password entered!";
                        return;
                    }
                    else
                    {
                        baInfo.Params.Add("username", this.cmbUserType.SelectedItem.ToString());
                        baInfo.Params.Add("password", this.txtPassword.Text);
                        baInfo.Params.Add("view", this);
                        baInfo.TypeOfButton = ButtonActionEventArgs.ButtonType.Button;
                        this.txtPassword.Clear();
                        errorProvider.Clear();
                        labelValidationError.Hide();
                    }
                    break;
                case LoginActions.Quit:
                    Application.Exit();
                    break;
                default:
                    break;
            }

            Controller.ButtonActionHandler(baInfo);
        }
Example #3
0
File: Main.cs Project: xiy/suprmrkt
 /// <summary>
 /// Redirects standard EventHandler driven form events to the custom ButtonClick
 /// handler inside the controller.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonActionHandlerRedirect(object sender, EventArgs e)
 {
     ButtonActionEventArgs baInfo = new ButtonActionEventArgs();
     baInfo.Button = (Button)sender;
     Controller.ButtonActionHandler(sender, baInfo);
 }