コード例 #1
0
        private List <TreatmentType> GetTreatmentTypeList(SQLQueryResult sQLQueryResult)
        {
            List <TreatmentType> treatmentTypes = new List <TreatmentType>();

            for (int i = 0; i < sQLQueryResult.dataTable.Rows.Count; i++)
            {
                int treatmentTypeID;

                if (sQLQueryResult.dataTable.Rows[i].IsNull("TreatmentTypeID"))
                {
                    treatmentTypeID = -1;
                }
                else
                {
                    treatmentTypeID = (int)sQLQueryResult.dataTable.Rows[i]["TreatmentTypeID"];
                }

                string name = (string)sQLQueryResult.dataTable.Rows[i]["Name"];

                treatmentTypes.Add(TreatmentTypeFactory.Instance().CreateTreatmentType(treatmentTypeID, name));
            }
            return(treatmentTypes);
        }
コード例 #2
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);
        }