コード例 #1
0
ファイル: Address.cs プロジェクト: DimitarMihov/hematite-team
        public static Address LoadAddressInformation(string[] lines, ref int index)
        {
            Address address = new Address();

            var assembly = Assembly.GetExecutingAssembly();

            var userType = assembly.GetType("GarageManagementSystem.Address");

            int propertiesCount = Service.PropertiesCount(address); // Get the number of properties

            for (int i = 0; i < propertiesCount; i++, index++)
            {
                var property = userType.GetProperty(lines[index]);
                index++;

                if (lines[index] != "-")
                {
                    Type t = Nullable.GetUnderlyingType(property.PropertyType) ?? property.PropertyType;
                    object safeValue = (lines[index] == null) ? null : Convert.ChangeType(lines[index], t, null);
                    property.SetValue(address, safeValue, null);
                }
            }

            index--;

            return address;
        }
コード例 #2
0
ファイル: Person.cs プロジェクト: DimitarMihov/hematite-team
 protected Person(string name, Address address, string phone, string email, string comment)
     : this(phone, comment)
 {
     this.Name = name;
     this.Address = address;
     this.Email = email;
 }
コード例 #3
0
ファイル: Address.cs プロジェクト: DimitarMihov/hematite-team
        public static string SaveAddressInformation(Address address)
        {
            StringBuilder builder = new StringBuilder();

            var assembly = Assembly.GetExecutingAssembly();

            var ownerProperties = assembly.GetType("GarageManagementSystem.Address").GetProperties();

            foreach (var property in ownerProperties)
            {
                builder.AppendLine(property.Name);
                try
                {
                    builder.AppendLine(property.GetValue(address, null).ToString());
                }
                catch (NullReferenceException)
                {
                    builder.AppendLine("-");
                }
            }

            return builder.ToString();
        }
コード例 #4
0
ファイル: Owner.cs プロジェクト: DimitarMihov/hematite-team
 public Owner(string name, Address address, string phone, string email, string comment)
     : base(name, address, phone, email, comment)
 {
 }
コード例 #5
0
        private static void LoadHardCodeInformation()
        {
            // Owners
            Address owner1Address = new Address("Sofia", "2000", "Geo Milev", "ul. Ivan Vazov", 2, "no comment");
            Owner owner1 = new Owner("Ivan Peshev", owner1Address, "0883442233", "*****@*****.**", "no comment");

            Address owner2Address = new Address("Plovdiv", "1800", "j.k. Zapad", "ul. Opulchenska", 132, "no comment");
            Owner owner2 = new Owner("Georgi Georgiev", owner2Address, "0883412333", "*****@*****.**", "no comment");

            // Parts
            List<Part> parts = new List<Part>(){ 
                new Part(1234, "Wheel", 50.00m, new List<VehicleInformation>(){ 
                    new VehicleInformation("Peugeot", "106", 1999, FuelType.Diesel, Gearbox.Automatic),
                    new VehicleInformation("BMW", "5", 2002, FuelType.Electric, Gearbox.SemiAutomatic),
                    new VehicleInformation("Mercedes", "SLK", 2010, FuelType.Electric, Gearbox.SemiAutomatic)
                    } )
            };

            // Repairs
            List<Repair> repairsCar1 = new List<Repair>();
            repairsCar1.Add(new Repair("Change wheels", 48, parts));

            List<Repair> repairsCar2 = new List<Repair>();
            repairsCar2.Add(new Repair("Change front wheels", 48, parts));

            // Vehicles
            Service.AutoShopInstance.AddVehicle(new Vehicle("Peugeot", "106", 1999, 80, 30000,
                FuelType.Diesel, Gearbox.Automatic, owner1, "red", "very good", "CA 1234 AC", repairsCar1, Status.Accepted));

            Service.AutoShopInstance.AddVehicle(new Vehicle("BMW", "5", 2002, 80, 350000, FuelType.Electric, Gearbox.SemiAutomatic,
                owner2, "red", "no comments", "PA 8750 HA", repairsCar2, Status.Accepted));

            Service.AutoShopInstance.AddVehicle(new Vehicle("Mercedes", "SLK", 2010, 140, 110000, FuelType.Electric, Gearbox.SemiAutomatic,
                owner2, "red", "no comments", "A 8993 MM", repairsCar2, Status.Accepted));

            // Distributors
            Address distributor1Address = new Address("Sofia", "2000", "j.k. Studentski grad", "ul. Vladishka", 23, "no comment");
            Address distributor2Address = new Address("Sofia", "2000", "Obelq", "ul. Hristo Smirnenski", 55, "no comment");
            Address distributor3Address = new Address("Sofia", "2000", "j.k. Dianabat", "ul. G.M.Dimitrov", 111, "no comment");

            Service.AutoShopInstance.AddDistributor(new Distributor("MotoPfohe Ltd", distributor1Address, "089 901 5632", "*****@*****.**", "no comment", parts));
            Service.AutoShopInstance.AddDistributor(new Distributor("BetterCars Ltd", distributor2Address, "089 598 8915", "*****@*****.**", "no comment", parts));
            Service.AutoShopInstance.AddDistributor(new Distributor("PartsForPeople Ltd", distributor3Address, "088 991 5987", "*****@*****.**", "no comment", parts));

            // Employees
            Address employee1Address = new Address("Sofia", "2000", "j.k. Mladost 1", "ul. Aleksander Batemberg", 39, "no comment");
            Address employee2Address = new Address("Sofia", "2000", "j.k. Lulin", "ul. Todor Kableshkov", 24, "no comment");

            Service.AutoShopInstance.AddEmployee(new Employee(
                "Marin Ivanov", employee1Address, "0883442233", "*****@*****.**", "no comment", 500, Position.Accountant));
            Service.AutoShopInstance.AddEmployee(new Employee(
                "Kiril Manolov", employee2Address, "0883212233", "*****@*****.**", "no comment", 300, Position.JunorMechanic));
        }
コード例 #6
0
 public Distributor(string name, Address address, string phone, string email, string comment, List<Part> parts)
     : base(name, address, phone, email, comment)
 {
     this.Parts = parts;
 }
コード例 #7
0
 public Employee(string name, Address address, string phone, string email, string comment, decimal salary, Position position)
     : base(name, address, phone, email, comment)
 {
     this.Salary = salary;
     this.Position = position;
 }