コード例 #1
0
        public StartingForm()
        {
            InitializeComponent();

            try
            {
                //Get all Products
                DataHolders.ProductsHolder.products = ProductClient.GetProducts();

                //Get all connections
                DataHolders.ButtonConnectionHolder.connections      = ButtonsClient.GetButtonConnections();
                DataHolders.UnitProductConnectionHolder.Connections = ButtonsClient
                                                                      .GetUnitPorductConnections();

                //Documents
                DataHolders.DocumentConnectionHolder.documentProductConnections = DocumentClient
                                                                                  .GetAllDocumnetProductConnections();

                //Warehouse
                DataHolders.WarehouseHolder.warehouses = DatabaseManagers.WarehouseClient.GetWarehouses();


                //DatabaseManagers.WarehouseManager.GetWarehouses();
                DataHolders.WarehouseHolder.warehouseProductConnections = DatabaseManagers.WarehouseClient
                                                                          .GetWarehouseProductConnection();

                //workers
                DataHolders.WorkerHolder.workers          = WorkerClient.GetWorkers();
                DataHolders.WorkerHolder.avaliableWorkers = WorkerClient.GetAavalibleWorkers();

                //Delivery
                DataHolders.DeliveryHolder.partners          = DeliveryClient.GetPartners();
                DataHolders.DeliveryHolder.locations         = DeliveryClient.GetLocations();
                DataHolders.DeliveryHolder.vehicles          = DeliveryClient.GetVehicles();
                DataHolders.DeliveryHolder.routes            = DeliveryClient.GetRoutes();
                DataHolders.DeliveryHolder.avaliableVehicles = DeliveryClient.GetAvalibleVehicles();

                //properties
                if (PropertiesClient.GetProperties().Exists((e) => e.name == Enums.PropertyName.distance))
                {
                    DataHolders.PropertiesHolder.distanceUnit = PropertiesClient.GetProperties()
                                                                .Find((e) => e.name == Enums.PropertyName.distance).value;
                }
                if (PropertiesClient.GetProperties().Exists((e) => e.name == Enums.PropertyName.weight))
                {
                    DataHolders.PropertiesHolder.weightUnit = PropertiesClient.GetProperties()
                                                              .Find((e) => e.name == Enums.PropertyName.weight).value;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error connecting to database, initial data couldn't be load");
                Environment.Exit(1);
            }
        }