Ejemplo n.º 1
0
        private void SearchPhoneButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                customer = BossController.Instance().customerController.GetCustomer(PhoneTextBox.Text);
            }
            catch (Exception exception)
            {
                MessageBox.Show(ErrorManager.Instance().GetErrorMessage(exception));
                this.Cursor = Cursors.Default;
                return;
            }

            CustomerNameLabel.Text    = customer.name.ToString();
            CustomerNameLabel.Enabled = true;
            AdressTextBox.Text        = customer.address;
            EmailTextBox.Text         = customer.email;

            sale.SetCustomer(customer);
            LoadeAllUnPaidPrescriptions(customer);
            LoadeAllUnpaidTreatments(customer);

            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 2
0
        private void Button_slet_Click(object sender, EventArgs e)
        {
            var confirm = MessageBox.Show("Fjern dette dyr?", "Bekræft sletning", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.Yes)
            {
                try
                {
                    string message = BossController.Instance().animalController.DeleteAnimal(animal);
                    this.Close();
                    if (message == "ok")
                    {
                        MessageBox.Show("Dyret Slettet");
                        this.Close();
                        customerForm.UpdateDataGridView();
                    }
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        private void button_recept_Click(object sender, EventArgs e)
        {
            Item prescriptionItem = (Item)comboBox_recept.SelectedItem;

            SaleItemForm saleItemForm = new SaleItemForm(prescriptionItem, null, null);

            saleItemForm.RemovePriceOption();

            if (saleItemForm.ShowDialog() == DialogResult.OK)
            {
                int amount = saleItemForm.saleLineItem.amount;

                DateTime prescriptionDay = DateTime.Now;
                bool     payed           = false;
                Employee employee        = treatment.employee;
                Animal   animal          = treatment.animal;
                Item     item            = prescriptionItem;

                Prescription prescription = PrescriptionFactory.Instance().CreatePrescription(amount, prescriptionDay, payed, employee, animal, item);

                try
                {
                    BossController.Instance().animalController.CreatePrescription(prescription);
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }

                MessageBox.Show(prescription.item.name.ToString() + " Udstedet til " + animal.name.ToString());
            }
        }
Ejemplo n.º 4
0
        public void UpdateDataGridView()
        {
            //danner en liste af dyr der hedder animals. Denne liste bliver dannet et sted på animalmanager og der bruges en customer som parameter

            try
            {
                List <Animal> animals = BossController.Instance().animalController.GetManyAnimalByCustomerID(customer);
                customer.AddAnimalList(animals);

                dataGridView_dyr.DataSource = customer.animals;

                dataGridView_dyr.Columns["name"].DataPropertyName = "Name";

                for (int i = 0; i < dataGridView_dyr.RowCount; i++)
                {
                    Species tmpspecies = animals[i].Species;

                    dataGridView_dyr.Rows[i].Cells["speciestype"].Value = tmpspecies.speciesName;
                }
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                return;
            }
        }
Ejemplo n.º 5
0
        private void Button_opret_Click_1(object sender, EventArgs e)
        {
            string AnimalWeight = animal_weight.Text;

            int animalWeight = 0;

            if (CheckEmtyTextBoxes() == false)
            {
                MessageBox.Show("Alle felter skal udfyldes");
                return;
            }

            if (CheckWeightDigit(AnimalWeight) == false)
            {
                if (AnimalWeight.ToString().Length == 8)
                {
                    animalWeight = Convert.ToInt32(animal_weight.Text);
                }
                MessageBox.Show("Vægten må kun bestå af tal");
                return;
            }

            try
            {
                Species  species  = (Species)animal_species.SelectedItem;
                bool     gender   = Convert.ToBoolean(animal_gender.SelectedIndex);
                Employee employee = null;
                if (animal_employee.SelectedIndex != 0)
                {
                    employee = (Employee)animal_employee.SelectedItem;
                }
                animal = AnimalFactory.Instance().CreateAnimal(customer, animal_name.Text.ToString(), (animal_bdate.Value), species, Convert.ToDouble(animal_weight.Text), gender, employee, true);

                animal = BossController.Instance().animalController.CreateAnimal(animal);

                MessageBox.Show("Dyret er oprettet");
                customerForm.UpdateDataGridView();

                AnimalName_Label.Text    = animal.name;
                animalSpecies_label.Text = animal.Species.speciesName.ToString();
                animal_owner.Text        = "Ejer: " + customer.name;
                button_edit.Enabled      = true;
                button_create.Enabled    = false;
                button_delete.Enabled    = true;
                animal_name.Enabled      = false;
                animal_bdate.Enabled     = false;
                animal_species.Enabled   = false;
                animal_gender.Enabled    = false;
                animal_medicalRecords.AutoGenerateColumns = false;
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                return;
            }
        }
Ejemplo n.º 6
0
        private void button_rediger_Click(object sender, EventArgs e)
        {
            var confirm = MessageBox.Show("Er du sikker på du vil redigere denne kunde?", "Bekræft redigering", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.Yes)
            {
                //Tjekker for at se om emailen er gyldig.

                if (CheckForValidEmail(textBox_email.Text.ToString()) == false)
                {
                    MessageBox.Show("Ugyldig E-mailadresse");
                    return;
                }

                if (CheckEmtyTextBoxes() == false)
                {
                    MessageBox.Show("Alle felterne skal være udfyldt");
                    return;
                }

                string name       = textBox_navn.Text.ToString();
                string phone      = textBox_phonenumber.Text.ToString();
                string address    = textBox_adresse.Text.ToString();
                string email      = textBox_email.Text.ToString();
                int    customerID = customer.customerID;
                int    cvr        = 0;
                bool   active     = customer.active;

                Customer tmpcustomer = CustomerFactory.Instance().CreateCustomer(customerID, name, address, phone, email, active, cvr);

                try
                {
                    string message = BossController.Instance().customerController.UpdateCustomer(tmpcustomer);
                    MessageBox.Show(message);
                    label_headline.Text = tmpcustomer.name.ToString();
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 7
0
        private void button_soeg_Click(object sender, EventArgs e)
        {
            this.Cursor                   = Cursors.WaitCursor;
            button_opret.Enabled          = false;
            checkBox_erhverskunde.Checked = false;
            textBox_cvr.Text              = null;

            //går ind på databasen og søger efter en kunde, via det indtastede telefonnummer
            try
            {
                customer = BossController.Instance().customerController.GetCustomer(textBox_phonenumber.Text);
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                this.Cursor = Cursors.Default;
                return;
            }
            //tjekker for at se om kunden er slettet, og i så fald, om den skal reaktiveres
            if (CheckCustomerDeletion() == false)
            {
                this.Cursor = Cursors.Default;
                return;
            }
            //udfylder den relevante data i tekstboksene
            textBox_navn.Text    = customer.name.ToString();
            textBox_adresse.Text = customer.address.ToString();
            textBox_email.Text   = customer.email.ToString();
            label_headline.Text  = customer.name.ToString();
            this.Refresh();

            //tjekker for om der er tale om en foretningskunde
            CheckForBusinesscustomer(customer);

            //updaterer datagridviewet med kundes dyr
            UpdateDataGridView();

            button_rediger.Enabled        = true;
            button_slet.Enabled           = true;
            button_dyr.Enabled            = true;
            label_headline.Text           = customer.name.ToString();
            checkBox_erhverskunde.Enabled = false;
            textBox_cvr.Enabled           = false;
            label_underheader.Text        = "Ret, slet, se dyr eller Tilføj dyr";

            this.Cursor = Cursors.Default;
        }
Ejemplo n.º 8
0
        private void Button_rediger_Click(object sender, EventArgs e)
        {
            string AnimalWeight = animal_weight.Text;

            int animalWeight = 0;

            if (CheckWeightDigit(AnimalWeight) == false)
            {
                if (AnimalWeight.ToString().Length == 8)
                {
                    animalWeight = Convert.ToInt32(animal_weight.Text);
                }
                MessageBox.Show("Vægten må kun bestå af tal");
                return;
            }

            try
            {
                string   name     = animal_name.Text.ToString();
                DateTime birthday = animal_bdate.Value;
                Species  species  = animal.Species;
                double   weight   = Convert.ToDouble(animal_weight.Text);
                bool     gender   = Convert.ToBoolean(animal_gender.SelectedIndex);

                Employee employee = null;
                if (animal_employee.SelectedIndex != 0)
                {
                    employee = (Employee)animal_employee.SelectedItem;
                }

                Animal tmpanimal = new Animal(customer, animal.animalID, name, birthday, species, weight, true, employee, true);

                string message = BossController.Instance().animalController.UpdateAnimal(tmpanimal);
                if (message == "ok")
                {
                    MessageBox.Show("Dyret rettet");
                    customerForm.UpdateDataGridView();
                }
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                return;
            }
        }
Ejemplo n.º 9
0
        private void LoadAllItemsInListBox()
        {
            ItemDataGridView.Columns["ItemName"].DataPropertyName   = "name";
            ItemDataGridView.Columns["itemAmount"].DataPropertyName = "amount";
            ItemDataGridView.Columns["itemPrice"].DataPropertyName  = "price";

            try
            {
                items = BossController.Instance().itemController.GetAllActiveItems();
                items = items.Where(x => x.prescription.Equals(false) && x.treatment.Equals(false)).ToList <Item>();
                ItemDataGridView.DataSource = items;
            }
            catch (Exception exception)
            {
                MessageBox.Show(ErrorManager.Instance().GetErrorMessage(exception));
            }
        }
Ejemplo n.º 10
0
        private void FillDataGridView()
        {
            DateTime startDate, endDate;

            GetTheWeekFromAYearAgo(out startDate, out endDate);

            try
            {
                treatments = BossController.Instance().treatmentController.GetManyTreatmentsForSendingRminders(startDate, endDate);
            }
            catch (Exception exception)
            {
                MessageBox.Show(ErrorManager.Instance().GetErrorMessage(exception));
            }

            RemindersDataGridView.DataSource = treatments;
            EnterDataInDataGridViewCells();
        }
Ejemplo n.º 11
0
        private void EndButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                BossController.Instance().saleController.CreateSale(sale);
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                this.Cursor = Cursors.Default;
                return;
            }
            MessageBox.Show("Salg Oprettet");
            EndButton.Enabled     = false;
            FakturaButton.Enabled = true;
            this.Cursor           = Cursors.Default;
        }
Ejemplo n.º 12
0
        private void button_gem_Click(object sender, EventArgs e)
        {
            string entry = textBox_entry.Text.ToString();

            MedicalRecord medicalRecord = MedicalRecordFactory.Instance().CreateMedicalRecord(entry, treatment.animal, treatment);

            try
            {
                BossController.Instance().animalController.CreateMedicalRecordEntry(medicalRecord);
                UpdateTreatmentStatus(3);
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                return;
            }

            MessageBox.Show("Behandling gemt");
            this.Close();
        }
Ejemplo n.º 13
0
        private void LoadeAllUnPaidPrescriptions(Customer customer)
        {
            try
            {
                prescriptions = BossController.Instance().animalController.GetUnpaidPrescriptionByCustomer(customer);
                UnPaidPrescriptionsDataGridView.DataSource = prescriptions;
            }
            catch (Exception exception)
            {
                MessageBox.Show(ErrorManager.Instance().GetErrorMessage(exception));
            }

            for (int i = 0; i < UnPaidPrescriptionsDataGridView.RowCount; i++)
            {
                Prescription prescription = prescriptions[i];

                UnPaidPrescriptionsDataGridView.Rows[i].Cells["prescriptionName"].Value   = prescription.item.name;
                UnPaidPrescriptionsDataGridView.Rows[i].Cells["prescriptionAmount"].Value = prescription.amount;
                UnPaidPrescriptionsDataGridView.Rows[i].Cells["prescriptionPrice"].Value  = prescription.item.price;
            }
        }
Ejemplo n.º 14
0
        private void LoadeAllUnpaidTreatments(Customer customer)
        {
            try
            {
                treatments = BossController.Instance().treatmentController.GetUnpaidTreatmentsByCustomer(customer);
                UnPaidTreatmentDataGridView.DataSource = treatments;
            }
            catch (Exception exception)
            {
                MessageBox.Show(ErrorManager.Instance().GetErrorMessage(exception));
            }


            for (int i = 0; i < UnPaidTreatmentDataGridView.RowCount; i++)
            {
                Treatment treatment = treatments[i];

                UnPaidTreatmentDataGridView.Rows[i].Cells["treatmentName"].Value  = treatment.item.name;
                UnPaidTreatmentDataGridView.Rows[i].Cells["treatmentDay"].Value   = treatment.endTime;
                UnPaidTreatmentDataGridView.Rows[i].Cells["treatmentPrice"].Value = treatment.item.price;
            }
        }
Ejemplo n.º 15
0
        private void button_slet_Click(object sender, EventArgs e)

        {
            var confirm = MessageBox.Show("Er du sikker på du vil slette denne kunde?", "Bekræft sletning", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.Yes)
            {
                customer = BossController.Instance().customerController.GetCustomer(textBox_phonenumber.Text.ToString());

                try
                {
                    string message = BossController.Instance().customerController.DeleteCustomer(customer);
                    MessageBox.Show(message);
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }
            }
            ResetForm();
        }
Ejemplo n.º 16
0
        private void button_opret_Click(object sender, EventArgs e)
        {
            //  Tjekker for at se om emailen er gyldig.

            if (CheckForValidEmail(textBox_email.Text.ToString()) == false)
            {
                MessageBox.Show("Ugyldig E-mailadresse");
                return;
            }
            if (CheckEmtyTextBoxes() == false)
            {
                MessageBox.Show("Alle felterne skal være udfyldt");
                return;
            }


            // tjekker om cvrnummeret består af tal
            string cvr = textBox_cvr.Text;

            //opretter en ny int og sætter den til 0
            int cvrint = 0;

            if (checkBox_erhverskunde.Checked == true && CheckForCVRdegit(cvr) == false)
            {
                //Hvis ikke cvr-nummeret består af noget bliver det lavet om til inten cvrint som er 0.

                if (cvr.ToString().Length == 8)
                {
                    //hvis cvrboxen er checket af og tallet er i orden erstattes nullet med det nye cvr-nummer
                    cvrint = Convert.ToInt32(textBox_cvr.Text);
                }
                else
                {
                    MessageBox.Show("CVR-nummeret skal bestå af 8 tal.");
                    return;
                }

                MessageBox.Show("CVR-nummer må kun bestå af tal");
                return;
            }
            //Hvis kunden er en erhverskunde og cvr-nummer er gyldigt bliver et cvr sendt over som parameter
            //Dette bliver senere brugt til at oprette en businesscustomer

            if (checkBox_erhverskunde.Checked == true && CheckForCVRdegit(cvr) == true)
            {
                cvrint = Convert.ToInt32(textBox_cvr.Text);
            }



            //Ellers bliver cvr-nummeret bare sendt over som 0, som senere bliver brugt til at oprette en privatecustomer
            customer = CustomerFactory.Instance().CreateCustomer(textBox_navn.Text.ToString(), textBox_adresse.Text.ToString(), textBox_phonenumber.Text.ToString(), textBox_email.Text.ToString(), true, cvrint);

            try
            {
                //her skriver vi den oprettede kunde ind i databasen
                customer = BossController.Instance().customerController.CreateCustomer(customer);

                MessageBox.Show("Kunde oprettet");

                button_dyr.Enabled            = true;
                button_rediger.Enabled        = true;
                button_slet.Enabled           = true;
                button_opret.Enabled          = false;
                label_headline.Text           = textBox_navn.Text.ToString().ToString();
                checkBox_erhverskunde.Enabled = false;
                textBox_cvr.Enabled           = false;
                label_underheader.Text        = "Ret, slet, se dyr eller Tilføj dyr";
            }
            catch (Exception exception)
            {
                string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                MessageBox.Show(errorMessage);
                return;
            }
        }
Ejemplo n.º 17
0
        private void AnimalForm_Load(object sender, EventArgs e)
        {
            LoadeAllItemsInComboBox();
            BossController.Instance().animalController.GetSpecies();
            if (animal != null)
            {
                animal_owner.Text     = "Ejer: " + customer.name;
                AnimalName_Label.Text = animal.name;

                animalSpecies_label.Text = animal.Species.speciesName.ToString();

                animal_name.Text            = animal.name;
                animal_bdate.Text           = Convert.ToString(animal.birthYear);
                animal_species.Text         = Convert.ToString(animal.Species.speciesName);
                animal_weight.Text          = Convert.ToString(animal.weight);
                animal_gender.SelectedIndex = Convert.ToInt32(animal.gender);
                if (animal.Employee != null)
                {
                    animal_employee.Text = Convert.ToString(animal.Employee.name);
                }
                try
                {
                    prescriptions = BossController.Instance().animalController.GetAllPrescriptionByAnimal(animal.animalID);

                    animal.AddPrescriptionList(prescriptions);

                    animal_prescription.DataSource = prescriptions;

                    for (int i = 0; i < prescriptions.Count; i++)
                    {
                        Prescription tmpprescription = prescriptions[i];

                        animal_prescription.Rows[i].Cells["name"].Value   = tmpprescription.item.name;
                        animal_prescription.Rows[i].Cells["date"].Value   = tmpprescription.prescriptionDay;
                        animal_prescription.Rows[i].Cells["amount"].Value = tmpprescription.amount;
                    }
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }
                try
                {
                    medicalRecords = BossController.Instance().animalController.GetAllMedicalRecordByAnimal(animal);

                    animal.AddMedicalRecordEntryList(medicalRecords);

                    animal_medicalRecords.DataSource = medicalRecords;

                    for (int i = 0; i < medicalRecords.Count; i++)
                    {
                        MedicalRecord tmpMedicalRecord = medicalRecords[i];

                        animal_medicalRecords.Rows[i].Cells["title"].Value   = tmpMedicalRecord.treatment.headline;
                        animal_medicalRecords.Rows[i].Cells["MR_date"].Value = tmpMedicalRecord.treatment.startTime;
                    }
                }
                catch (Exception exception)
                {
                    string errorMessage = ErrorManager.Instance().GetErrorMessage(exception);
                    MessageBox.Show(errorMessage);
                    return;
                }
            }
        }