Esempio n. 1
0
        //Remove a Client or Session depending on form type
        private void BTNremove_Click(object sender, EventArgs e)
        {
            if (formType == 1 && !(LBdata.SelectedItem == null))
            {
                var result2 = listClients.Where(cl =>
                                                (cl.firstName + " " + cl.lastName) == LBdata.SelectedItem.ToString()).FirstOrDefault();

                if (result2 != null)
                {
                    ClientModal clientForm = new ClientModal(result2);
                    clientForm.ShowDialog();
                    formRefresh();
                    return;
                }
            }
            else if (formType == 1)
            {
                MessageBox.Show("No client selected! Please add or select one", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (formType == 2 && !(LBdata.SelectedItem == null))
            {
                if (LBdata.SelectedItem != null)
                {
                    int remove = LBdata.SelectedIndex + 1;
                    db.DeleteWorkoutSession(client.client_uno, remove);
                    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();
                }
            }
            else if (formType == 2)
            {
                MessageBox.Show("No Session selected! Please add or select one", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            clearForm();
        }
Esempio n. 2
0
        //Adds a Client or Session depending on form type
        private void BTNadd_Click(object sender, EventArgs e)
        {
            if (formType == 1)
            {
                Client      client     = new Client(this.trainer.trainer_uno);
                ClientModal clientForm = new ClientModal(client);
                clientForm.ShowDialog();
                formRefresh();
            }
            if (formType == 2)
            {
                Session session = new Session();
                session.client_code = client.client_uno;
                int seshNum = LBdata.SelectedIndex + 1;
                if ((LBdata.SelectedItem == null))
                {
                    seshNum = this.client.sessCount + 1;
                }
                SessionModal sessionForm = new SessionModal(session, seshNum);
                if (sessionForm.ShowDialog() == DialogResult.OK)
                {
                    formRefresh();
                    this.client.sessCount = seshNum;
                    listSessions.Add(session);
                    List <String> columnData = new List <String>();

                    for (int i = 0; i < this.client.sessCount; i++)
                    {
                        columnData.Add("Session " + (i + 1));
                    }

                    LBdata.DataSource   = columnData;
                    this.LBLprofit.Text = (trainer.rate * client.sessCount).ToString();
                }
            }
            clearForm();
        }