Ejemplo n.º 1
0
Archivo: Main.cs Proyecto: xiy/suprmrkt
 public void ModelChanged(object sender, ModelChangedEventArgs e)
 {
     switch ((MainActions)e.ActionReference)
     {
         case MainActions.RunSimulation:
             break;
         case MainActions.NewSimulation:
             break;
         case MainActions.LoadSimulation:
             break;
         case MainActions.ViewResults:
             break;
         case MainActions.Logout:
             break;
         case MainActions.GetCustomerTypes:
             this.cmbCustomersCustomerTypes.Items.Clear();
             // this.cmbPricingCustomerTypes.Items.Clear();
             // this.cmbActivityCustomerTypes.Items.Clear();
             this.cmbCustomersCustomerTypes.Items.AddRange((string[])e.Params["Customer Types"]);
             // this.cmbPricingCustomerTypes.Items.AddRange((string[])e.Params["Customer Types"]);
             // this.cmbActivityCustomerTypes.Items.AddRange((string[])e.Params["Customer Types"]);
             break;
         case MainActions.GetStaffTypes:
             this.comboBox1.Items.Clear();
             this.comboBox1.Items.AddRange((string[])e.Params["Staff Types"]);
             break;
         case MainActions.GetPromotionTypes:
             break;
         case MainActions.Quit:
             break;
         default:
             break;
     }
 }
Ejemplo n.º 2
0
 public void ModelChanged(object sender, ModelChangedEventArgs e)
 {
     switch ((LoginActions)e.ActionReference)
     {
         case LoginActions.Login:
             if (e.Params.ContainsKey("Fail"))
             {
                 this.labelValidationError.Text = e.Params["Fail"].ToString();
                 this.labelValidationError.Visible = true;
             }
             break;
         case LoginActions.Quit:
             break;
         default:
             break;
     }
 }
Ejemplo n.º 3
0
 public void ButtonActionHandler(object sender, EventArgs e)
 {
     Control sendingControl = (Control)sender;
     switch ((MainActions)sendingControl.Tag)
     {
         case MainActions.RunSimulation:
             Simulator s = new Simulator();
             s.Run();
             break;
         case MainActions.GetCustomerTypes:
             string[] ctypes = Customer.Instance.GetCustomerTypes();
             ModelChangedEventArgs cm = new ModelChangedEventArgs();
             cm.ActionReference = MainActions.GetCustomerTypes;
             cm.Params.Add("Customer Types", ctypes);
             RaiseModelChange(this, cm);
             return;
         case MainActions.GetStaffTypes:
             SQLiteResult result = SQLiteController.Instance.Query("SELECT Type FROM staff");
             List<string> types = new List<string>();
             for (int i = 0; i < result.Rows.Count; i++)
             {
                 types.Add(result.Rows[i]["Type"].ToString());
             }
             string[] stypes = types.ToArray();
             ModelChangedEventArgs sm = new ModelChangedEventArgs();
             sm.ActionReference = MainActions.GetStaffTypes;
             sm.Params.Add("Staff Types", stypes);
             RaiseModelChange(this, sm);
             return;
         case MainActions.NewSimulation:
             break;
         case MainActions.LoadSimulation:
             break;
         case MainActions.ViewResults:
             break;
         case MainActions.Logout:
             break;
         case MainActions.Quit:
             break;
         default:
             break;
     }
 }
Ejemplo n.º 4
0
 public void RaiseModelChange(object sender, ModelChangedEventArgs e)
 {
     if (ModelChanged != null)
         ModelChanged(sender, e);
 }
Ejemplo n.º 5
0
 private void AuthenticateUser(string username, string password)
 {
     switch (username)
     {
         case "Advanced":
             string checkPassword = User.Instance.GetPasswordForUser(UserType.Advanced);
             if (checkPassword == password) {
                 Main mainForm = new Main();
                 mainForm.Show();
                 Application.OpenForms["Login"].Hide();
             }
             else if (checkPassword == string.Empty || checkPassword != password)
             {
                 // notify view!
                 ModelChangedEventArgs m = new ModelChangedEventArgs();
                 m.ActionReference = LoginActions.Login;
                 m.Params.Add("Fail", "Password was invalid!");
                 RaiseModelChange(this, m);
             }
             break;
         default:
             break;
     }
 }