//Refreshes Databox private void formRefresh() { if (formType == 1) { this.trainer = db.GetTrainer(trainer.usn); List <String> columnData = new List <String>(); this.listClients = trainer.clients; for (int i = 0; i < trainer.clients.Count; i++) { columnData.Add(trainer.clients[i].firstName + " " + trainer.clients[i].lastName); } LBdata.DataSource = columnData; } if (formType == 2) { string inquiry = client.firstName + " " + client.lastName; this.trainer = db.GetTrainer(trainer.usn); var result2 = listClients.Where(cl => (cl.firstName + " " + cl.lastName) == inquiry).FirstOrDefault(); if (result2 != null) { this.client = result2; List <String> columnData = new List <String>(); client.sessCount = client.sessCount - 1; for (int i = 0; i < client.sessCount; i++) { columnData.Add("Session " + (i + 1)); } LBdata.DataSource = columnData; this.LBLprofit.Text = (trainer.rate * client.sessCount).ToString(); } } }
//Process Form Validates / Authenticates then calls form private void processForm() { if (validateCredentials()) { if (db.AuthenticateUsernameAndPassword(this.TBusername.Text, this.TBpass.Text)) { Trainer trainer = new Trainer(); trainer = db.GetTrainer(this.TBusername.Text); showForm(trainer); } else { //Error Requirement MessageBox.Show("Invalid Username or Password Combination", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }