public Customer GetCustomer(string phone)
        {
            Customer customer;

            string query = Utility.ReadSQLQueryFromFile("GetCustomer.txt");

            SQLQuery sQLQuery = new SQLQuery(query);

            sQLQuery.AddParameter("@phone", phone, SqlDbType.VarChar);

            SQLQueryResult sQLQueryResult = SQLDatabaseConnector.QueryDatabase(sQLQuery);

            if (sQLQueryResult.code == 0 && sQLQueryResult.dataTable.Rows.Count > 0)
            {
                DataRow dataRow = sQLQueryResult.dataTable.Rows[0];

                customer = CustomerFactory.Instance().CreateCustomer((int)dataRow["CustomerID"], (string)dataRow["Name"], (string)dataRow["Adress"], (string)dataRow["Phone"], (string)dataRow["Email"], (bool)dataRow["Active"], (int)dataRow["cvr"]);

                return(customer);
            }
            else
            {
                throw new NoCustomerFoundException("", sQLQueryResult.exception);
            }
        }
        public void UpdateCustomerTestMethod()
        {
            Customer        customer        = CustomerFactory.Instance().CreateCustomer("hans", "Vejvej", "654", "*****@*****.**", true, 0);
            CustomerManager customerManager = new CustomerManager();
            string          updateCustomer  = customerManager.UpdateCustomer(customer);

            Assert.AreEqual("Kunde rettet", updateCustomer);
        }
Beispiel #3
0
        public RoutingDataModel CreateInitialSimulationDataModel(bool allowDropNodes, Simulation.Simulation simulation)
        {
            var numberCustomers = simulation.Params.NumberInitialRequests;
            var numberVehicles  = simulation.Params.VehicleNumber;

            Console.WriteLine(this.ToString() + "Creating new random DataModel for " + numberVehicles + " Vehicles and " + numberCustomers + " Customers, AllowDropNodes: " + allowDropNodes);
GenerateNewDataModelLabel:
            List <Vehicle> dataModelVehicles   = new List <Vehicle>();
            List <long> startDepotsArrivalTime = new List <long>(numberVehicles);

            //Creates two available vehicles to be able to perform flexible routing for the pdtwdatamodel
            for (int i = 0; i < numberVehicles; i++)
            {
                var vehicle = new Vehicle(simulation.Params.VehicleSpeed, simulation.Params.VehicleCapacity, simulation.Context.Depot, simulation.Context.Depot);
                dataModelVehicles.Add(vehicle);
                startDepotsArrivalTime.Add(0);//startDepotArrival time  = 0 for all the vehicles
            }

            var         customersToBeServed = new List <Customer>();
            List <Stop> excludedStops       = new List <Stop>();

            foreach (var vehicle in dataModelVehicles)
            {
                if (!excludedStops.Contains(vehicle.StartStop))
                {
                    excludedStops.Add(vehicle.StartStop);
                }

                if (!excludedStops.Contains(vehicle.EndStop))
                {
                    excludedStops.Add(vehicle.EndStop);
                }
            }

            for (int i = 0; i < numberCustomers; i++) //generate 5 customers with random timeWindows and random pickup and delivery stops
            {
                var requestTime      = 0;
                var pickupTimeWindow = new int[] { requestTime, simulation.Params.SimulationTimeWindow[1] };                                                                                           //the customer pickup time will be between the current request time and the end of simulation time
                var customer         = CustomerFactory.Instance().CreateRandomCustomer(simulation.Context.Stops, excludedStops, requestTime, pickupTimeWindow, false, simulation.Params.VehicleSpeed); //Generates a random static customer
                customersToBeServed.Add(customer);
            }
            var indexManager = new DataModelIndexManager(dataModelVehicles, customersToBeServed, startDepotsArrivalTime);

            var routingDataModel = new RoutingDataModel(indexManager, simulation.Params.MaximumRelativeCustomerRideTime, simulation.Params.MaximumAllowedDeliveryDelay);
            var solver           = new RoutingSolver(routingDataModel, allowDropNodes);
            RoutingSearchParameters searchParameters = operations_research_constraint_solver.DefaultRoutingSearchParameters();

            searchParameters.LocalSearchMetaheuristic = LocalSearchMetaheuristic.Types.Value.Automatic;
            searchParameters.SolutionLimit            = 1; //until it finds 1 solution
            var solution = solver.TryGetSolution(searchParameters);

            if (solution == null)
            {
                goto GenerateNewDataModelLabel;
            }
            return(routingDataModel);
        }
        public void CreateCustomerTestMethod()
        {
            Customer customer = CustomerFactory.Instance().CreateCustomer("hans", "Vejvej", random.Next(1000000, 10000000).ToString(), "*****@*****.**", true, 0);

            CustomerManager customerManager = new CustomerManager();

            customerManager.CreateCustomer(customer);
            Assert.AreNotEqual(0, customer.customerID);
        }
        public void DeleteCustomerTestMethod()
        {
            Customer customer = CustomerFactory.Instance().CreateCustomer("hans", "Vejvej", "654", "*****@*****.**", true, 0);

            CustomerManager customerManager = new CustomerManager();

            string deleteCustomer = customerManager.DeleteCustomer(customer);

            Assert.AreEqual("Kunde gjort inaktiv", deleteCustomer);
        }
Beispiel #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;
            }
        }
Beispiel #7
0
        private List <Animal> GetAnimalList(SQLQueryResult sQLQueryResult)
        {
            List <Animal> animals = new List <Animal>();

            for (int i = 0; i < sQLQueryResult.dataTable.Rows.Count; i++)
            {
                Employee employee = null;
                if (sQLQueryResult.dataTable.Rows[i].IsNull("EmployeeID"))
                {
                }
                else
                {
                    string titleName = (string)sQLQueryResult.dataTable.Rows[i]["TitleName"];
                    int    titleID   = (int)sQLQueryResult.dataTable.Rows[i]["TitleID"];
                    Title  title     = TitleFactory.Instance().CreateTitle(titleName, titleID);

                    string employeeName   = (string)sQLQueryResult.dataTable.Rows[i]["EmployeeName"];
                    int    employeeID     = (int)sQLQueryResult.dataTable.Rows[i]["EmployeeID"];
                    bool   employeeActive = (bool)sQLQueryResult.dataTable.Rows[i]["EmployeeActive"];

                    employee = EmployeeFactory.Instance().CreateEmployee(employeeID, employeeName, employeeActive, title);
                }
                int      CustomerID     = (int)sQLQueryResult.dataTable.Rows[i]["CustomerID"];
                string   customerName   = (string)sQLQueryResult.dataTable.Rows[i]["customername"];
                string   customeradress = (string)sQLQueryResult.dataTable.Rows[i]["Adress"];
                string   customerphone  = (string)sQLQueryResult.dataTable.Rows[i]["Phone"];
                string   customeremail  = (string)sQLQueryResult.dataTable.Rows[i]["Email"];
                bool     customeractive = (bool)sQLQueryResult.dataTable.Rows[i]["Active"];
                Customer customer       = CustomerFactory.Instance().CreateCustomer(CustomerID, customerName, customeradress, customerphone, customeremail, customeractive, 0);
                int      animalID       = (int)sQLQueryResult.dataTable.Rows[i]["AnimalID"];
                string   name           = (string)sQLQueryResult.dataTable.Rows[i]["Name"];
                DateTime birthday       = (DateTime)sQLQueryResult.dataTable.Rows[i]["BirthYear"];
                int      speciesID      = (int)sQLQueryResult.dataTable.Rows[i]["Speciesid"];
                string   speciesName    = (string)sQLQueryResult.dataTable.Rows[i]["SpeciesName"];
                Species  species        = SpeciesFactory.Instance().CreateSpecies(speciesID, speciesName);
                double   weight         = Convert.ToDouble((decimal)sQLQueryResult.dataTable.Rows[i]["Weight"]);
                bool     gender         = (bool)sQLQueryResult.dataTable.Rows[i]["Gender"];
                bool     active         = (bool)sQLQueryResult.dataTable.Rows[i]["Active"];

                animals.Add(AnimalFactory.Instance().CreateAnimal(customer, animalID, name, birthday, species, weight, gender, employee, true));
            }
            return(animals);
        }
Beispiel #8
0
        public void AddAllDynamicRequestEvents()
        {
            List <Stop> excludedStops = new List <Stop>();

            excludedStops.Add(Context.Depot);
            for (int hour = (int)TimeSpan.FromSeconds(Params.SimulationTimeWindow[0]).TotalHours; hour < (int)TimeSpan.FromSeconds(Params.SimulationTimeWindow[1]).TotalHours; hour++)
            {
                var hourInSeconds = TimeSpan.FromHours(hour).TotalSeconds;
                for (int i = 0; i < Params.NumberDynamicRequestsPerHour; i++)
                {
                    var maxHourTime          = (int)hourInSeconds + (60 * 60) - 1;
                    var requestTime          = RandomNumberGenerator.Random.Next((int)hourInSeconds, (int)maxHourTime);
                    var pickupTimeWindow     = new int[] { requestTime, maxHourTime };
                    var customer             = CustomerFactory.Instance().CreateRandomCustomer(Context.Stops, excludedStops, requestTime, pickupTimeWindow, true, Params.VehicleSpeed); //Generates a random dynamic customer
                    var customerRequestEvent = EventGenerator.Instance().GenerateCustomerRequestEvent(requestTime, customer);                                                           //Generates a pickup and delivery customer request (dynamic)
                    AddEvent(customerRequestEvent);
                }
            }
        }
Beispiel #9
0
        public Animal GetAnimal(int animalID)
        {
            string query = Utility.ReadSQLQueryFromFile("GetAnimal.txt");

            SQLQuery sQLQuery = new SQLQuery(query);

            sQLQuery.AddParameter("@animalid", animalID.ToString(), SqlDbType.Int);

            SQLQueryResult sQLQueryResult = SQLDatabaseConnector.QueryDatabase(sQLQuery);

            DataRow dataRow = sQLQueryResult.dataTable.Rows[0];

            int      CustomerID     = (int)sQLQueryResult.dataTable.Rows[0]["CustomerID"];
            string   customerName   = (string)sQLQueryResult.dataTable.Rows[0]["customername"];
            string   customeradress = (string)sQLQueryResult.dataTable.Rows[0]["Adress"];
            string   customerphone  = (string)sQLQueryResult.dataTable.Rows[0]["Phone"];
            string   customeremail  = (string)sQLQueryResult.dataTable.Rows[0]["Email"];
            bool     customeractive = (bool)sQLQueryResult.dataTable.Rows[0]["Active"];
            Customer customer       = CustomerFactory.Instance().CreateCustomer(CustomerID, customerName, customeradress, customerphone, customeremail, customeractive, 0);

            string speciesName = sQLQueryResult.dataTable.Rows[0]["SpeciesName"].ToString();

            int speciesID = (int)sQLQueryResult.dataTable.Rows[0]["SpeciesID"];

            Species species = SpeciesFactory.Instance().CreateSpecies(speciesID, speciesName);

            string name = sQLQueryResult.dataTable.Rows[0]["SpeciesName"].ToString();

            int employeeID = (int)sQLQueryResult.dataTable.Rows[0]["EmployeeID"];

            Employee employee = EmployeeFactory.Instance().GetEmployee(employeeID, name);

            Animal animal = new Animal(customer, (int)dataRow["AnimalID"], (string)dataRow["Name"], (DateTime)dataRow["BirthYear"], species, (double)dataRow["Weight"], (bool)dataRow["Gender"], employee, (bool)dataRow["Active"]);

            return(animal);
        }
Beispiel #10
0
        private List <Prescription> GetAllPrescriptionList(SQLQueryResult sQLQueryResult)
        {
            List <Prescription> prescriptions = new List <Prescription>();

            for (int i = 0; i < sQLQueryResult.dataTable.Rows.Count; i++)
            {
                int      prescriptionID;
                Employee employee;
                Animal   animal;
                Item     item;
                Title    title;

                if (sQLQueryResult.dataTable.Rows[i].IsNull("EmployeeID"))
                {
                    employee = null;
                }
                else
                {
                    int    employeeID = (int)sQLQueryResult.dataTable.Rows[i]["EmployeeID"];
                    string name       = (string)sQLQueryResult.dataTable.Rows[i]["Employeename"];
                    int    titleID    = (int)sQLQueryResult.dataTable.Rows[i]["TitleID"];
                    string titleName  = (string)sQLQueryResult.dataTable.Rows[i]["TitleName"];

                    title    = TitleFactory.Instance().CreateTitle(titleName, titleID);
                    employee = EmployeeFactory.Instance().CreateEmployee(employeeID, name, true, title);
                }

                if (sQLQueryResult.dataTable.Rows[i].IsNull("AnimalID"))
                {
                    animal = null;
                }
                else
                {
                    int      customerID     = (int)sQLQueryResult.dataTable.Rows[i]["CustomerID"];
                    string   nameCustomer   = (string)sQLQueryResult.dataTable.Rows[i]["CustomerName"];
                    string   address        = (string)sQLQueryResult.dataTable.Rows[i]["Adress"];
                    string   phone          = (string)sQLQueryResult.dataTable.Rows[i]["Phone"];
                    string   email          = (string)sQLQueryResult.dataTable.Rows[i]["Email"];
                    bool     activeCustomer = (bool)sQLQueryResult.dataTable.Rows[i]["CustomerActive"];
                    int      cvr            = 0;
                    string   name           = (string)sQLQueryResult.dataTable.Rows[i]["AnimalName"];
                    DateTime birthYear      = (DateTime)sQLQueryResult.dataTable.Rows[i]["BirthYear"];
                    int      speciesID      = (int)sQLQueryResult.dataTable.Rows[i]["SpeciesID"];
                    string   nameSpecies    = (string)sQLQueryResult.dataTable.Rows[i]["SpeciesName"];
                    double   weight         = Convert.ToDouble((decimal)sQLQueryResult.dataTable.Rows[i]["Weight"]);
                    bool     gender         = (bool)sQLQueryResult.dataTable.Rows[i]["Gender"];
                    bool     activeAnimal   = (bool)sQLQueryResult.dataTable.Rows[i]["AnimalActive"];

                    Species  species  = SpeciesFactory.Instance().CreateSpecies(speciesID, nameSpecies);
                    Customer customer = CustomerFactory.Instance().CreateCustomer(customerID, nameCustomer, address, phone, email, activeCustomer, cvr);

                    animal = AnimalFactory.Instance().CreateAnimal(customer, name, birthYear, species, weight, gender, employee, activeAnimal);
                }

                if (sQLQueryResult.dataTable.Rows[i].IsNull("ItemID"))
                {
                    item = null;
                }
                else
                {
                    int     itemID       = (int)sQLQueryResult.dataTable.Rows[i]["ItemID"];
                    string  name         = (string)sQLQueryResult.dataTable.Rows[i]["ItemName"];
                    decimal price        = (decimal)sQLQueryResult.dataTable.Rows[i]["ItemPrice"];
                    decimal costPrice    = (decimal)sQLQueryResult.dataTable.Rows[i]["CostPrice"];
                    int     amountItem   = (int)sQLQueryResult.dataTable.Rows[i]["ItemAmount"];
                    bool    prescription = (bool)sQLQueryResult.dataTable.Rows[i]["Prescription"];
                    bool    treatment    = (bool)sQLQueryResult.dataTable.Rows[i]["ItemTreatment"];
                    bool    itemActive   = (bool)sQLQueryResult.dataTable.Rows[i]["ItemActive"];

                    item = ItemFactory.Instance().CreateItem(itemID, name, amountItem, price, costPrice, prescription, treatment, itemActive);
                }

                int      amount          = (int)sQLQueryResult.dataTable.Rows[i]["Amount"];
                DateTime prescriptionDay = (DateTime)sQLQueryResult.dataTable.Rows[i]["PrescriptionDay"];
                bool     payed           = (bool)sQLQueryResult.dataTable.Rows[i]["Payed"];
                prescriptionID = (int)sQLQueryResult.dataTable.Rows[i]["PrescriptionID"];

                prescriptions.Add(PrescriptionFactory.Instance().CreatePrescription(prescriptionID, amount, prescriptionDay, payed, employee, animal, item));
            }
            return(prescriptions);
        }
Beispiel #11
0
        private List <Treatment> GetTreatmentList(SQLQueryResult sQLQueryResult)
        {
            List <Treatment> treatments = new List <Treatment>();

            for (int i = 0; i < sQLQueryResult.dataTable.Rows.Count; i++)
            {
                int           treatmentID;
                TreatmentType treatmentType;
                Employee      employee;
                Employee      animalEmployee = null;
                OperationRoom operationRoom;
                Cage          cage;
                Item          item;
                int           animalID;
                Title         title;


                if (sQLQueryResult.dataTable.Rows[i].IsNull("TreatmentID"))
                {
                    treatmentID = -1;
                }
                else
                {
                    treatmentID = (int)sQLQueryResult.dataTable.Rows[i]["TreatmentID"];
                }
                if (sQLQueryResult.dataTable.Rows[i].IsNull("TreatmentTypeID"))
                {
                    treatmentType = null;
                }
                else
                {
                    int    treatmentTypeID   = (int)sQLQueryResult.dataTable.Rows[i]["TreatmentTypeID"];
                    string treatmentTypeName = (string)sQLQueryResult.dataTable.Rows[i]["Name"];

                    TreatmentType newTreatmentType = TreatmentTypeFactory.Instance().CreateTreatmentType(treatmentTypeID, treatmentTypeName);

                    treatmentType = newTreatmentType;
                }
                if (sQLQueryResult.dataTable.Rows[i].IsNull("OperationRoomID"))
                {
                    operationRoom = null;
                }
                else
                {
                    int operationRoomID = (int)sQLQueryResult.dataTable.Rows[i]["OperationRoomID"];

                    operationRoom = OperationRoomFactory.Instance().CreateOperationRoom(operationRoomID);
                }

                if (sQLQueryResult.dataTable.Rows[i].IsNull("CageID"))
                {
                    cage = null;
                }
                else
                {
                    int    cageID      = (int)sQLQueryResult.dataTable.Rows[i]["CageID"];
                    int    speciesID   = (int)sQLQueryResult.dataTable.Rows[i]["SpeciesID"];
                    string speciesName = (string)sQLQueryResult.dataTable.Rows[i]["SpeciesName"];

                    Species species = SpeciesFactory.Instance().CreateSpecies(speciesID, speciesName);

                    cage = CageFactory.Instance().CreateCage(cageID, species);
                }


                if (sQLQueryResult.dataTable.Rows[i].IsNull("ItemID"))
                {
                    item = null;
                }
                else
                {
                    int     itemID       = (int)sQLQueryResult.dataTable.Rows[i]["ItemID"];
                    string  name         = (string)sQLQueryResult.dataTable.Rows[i]["ItemName"];
                    decimal price        = (decimal)sQLQueryResult.dataTable.Rows[i]["Price"];
                    decimal costPrice    = (decimal)sQLQueryResult.dataTable.Rows[i]["CostPrice"];
                    int     amount       = (int)sQLQueryResult.dataTable.Rows[i]["Amount"];
                    bool    prescription = (bool)sQLQueryResult.dataTable.Rows[i]["Prescription"];
                    bool    treatment    = (bool)sQLQueryResult.dataTable.Rows[i]["ItemTreatment"];
                    bool    itemActive   = (bool)sQLQueryResult.dataTable.Rows[i]["ItemActive"];

                    item = ItemFactory.Instance().CreateItem(itemID, name, amount, price, costPrice, prescription, treatment, itemActive);
                }

                if (sQLQueryResult.dataTable.Rows[i].IsNull("EmployeeID"))
                {
                    employee = null;
                }
                else
                {
                    int    employeeID = (int)sQLQueryResult.dataTable.Rows[i]["EmployeeID"];
                    string name       = (string)sQLQueryResult.dataTable.Rows[i]["Employeename"];
                    int    titleID    = (int)sQLQueryResult.dataTable.Rows[i]["TitleID"];
                    string titleName  = (string)sQLQueryResult.dataTable.Rows[i]["TitleName"];

                    title    = TitleFactory.Instance().CreateTitle(titleName, titleID);
                    employee = EmployeeFactory.Instance().CreateEmployee(employeeID, name, true, title);
                }

                animalID = (int)sQLQueryResult.dataTable.Rows[i]["AnimalID"];
                if (!sQLQueryResult.dataTable.Rows[i].IsNull("AnimalEmployeeID"))
                {
                    int    animalTitleID   = (int)sQLQueryResult.dataTable.Rows[i]["AnimalEmployeeTitleID"];
                    string animalTitleName = (string)sQLQueryResult.dataTable.Rows[i]["AnimalEmployeeTitle"];

                    Title animalEmployeeTitle = TitleFactory.Instance().CreateTitle(animalTitleName, animalTitleID);

                    int    animalEmployeeID   = (int)sQLQueryResult.dataTable.Rows[i]["AnimalEmployeeID"];
                    string animalEmployeeName = (string)sQLQueryResult.dataTable.Rows[i]["AnimalEmployeeName"];

                    bool animalEmployeeActive = (bool)sQLQueryResult.dataTable.Rows[i]["AnimalEmployeeActive"];


                    animalEmployee = EmployeeFactory.Instance().CreateEmployee(animalEmployeeID, animalEmployeeName, animalEmployeeActive, animalEmployeeTitle);
                }

                int    animalSpeciesID   = (int)sQLQueryResult.dataTable.Rows[i]["AnimalSpeciesID"];
                string animalSpeciesName = (string)sQLQueryResult.dataTable.Rows[i]["AnimalSpeciesName"];

                Species animalSpecies = SpeciesFactory.Instance().CreateSpecies(animalSpeciesID, animalSpeciesName);

                int    customerID      = (int)sQLQueryResult.dataTable.Rows[i]["CustomerID"];
                string customerName    = (string)sQLQueryResult.dataTable.Rows[i]["CustomerName"];
                string customerAddress = (string)sQLQueryResult.dataTable.Rows[i]["Adress"];
                string customerPhone   = (string)sQLQueryResult.dataTable.Rows[i]["Phone"];
                string customerEmail   = (string)sQLQueryResult.dataTable.Rows[i]["Email"];
                bool   customerActive  = (bool)sQLQueryResult.dataTable.Rows[i]["CustomerActive"];

                Customer customer = CustomerFactory.Instance().CreateCustomer(customerID, customerName, customerAddress, customerPhone, customerEmail, customerActive, 0);


                string   animalName     = (string)sQLQueryResult.dataTable.Rows[i]["AnimalName"];
                DateTime animalBirthday = (DateTime)sQLQueryResult.dataTable.Rows[i]["BirthYear"];
                bool     animalGender   = (bool)sQLQueryResult.dataTable.Rows[i]["Gender"];
                double   animalWeight   = Convert.ToDouble((decimal)sQLQueryResult.dataTable.Rows[i]["Weight"]);
                bool     animalActive   = (bool)sQLQueryResult.dataTable.Rows[i]["AnimalActive"];

                Animal animal = AnimalFactory.Instance().CreateAnimal(customer, animalID, animalName, animalBirthday, animalSpecies, animalWeight, animalGender, animalEmployee, animalActive);

                if (sQLQueryResult.dataTable.Rows[i].IsNull("AnimalID"))
                {
                    animalID = -1;
                }
                else
                {
                    animalID = (int)sQLQueryResult.dataTable.Rows[i]["AnimalID"];
                }
                DateTime startTime = (DateTime)sQLQueryResult.dataTable.Rows[i]["StartTime"];
                DateTime endTime   = (DateTime)sQLQueryResult.dataTable.Rows[i]["EndTime"];
                bool     payed     = (bool)sQLQueryResult.dataTable.Rows[i]["Payed"];
                string   headline  = (string)sQLQueryResult.dataTable.Rows[i]["Headline"];
                bool     active    = (bool)sQLQueryResult.dataTable.Rows[i]["Active"];
                int      status    = (int)sQLQueryResult.dataTable.Rows[i]["Status"];

                treatments.Add(TreatmentFactory.Instance().CreateTreatment(treatmentID, treatmentType, operationRoom, cage, item, startTime, endTime, payed, headline, active, animal, employee, status));
            }
            return(treatments);
        }
Beispiel #12
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;
            }
        }