Exemple #1
0
        private void btnAddRoute_Click(object sender, EventArgs e)
        {
            Route route = new Route();

            route.id            = int.Parse(tbox_addRoute_id.Text);
            route.startingPoint = (Location)cmb_addRoute_startingPoint.SelectedItem;
            route.destination   = (Location)cmb_addRoute_destination.SelectedItem;
            route.distance      = double.Parse(tbox_addRoute_distance.Text);
            route.driver        = (Worker)cmb_addRoute_driver.SelectedItem;
            route.vehicle       = (Vehicle)cmb_addRoute_Vehicle.SelectedItem;
            route.startDate     = dtp_addRoute_startDate.Value;
            route.finished      = false;


            try
            {
                DeliveryHolder.routes.Add(route);
                DeliveryClient.InsertRoute(route);

                clearTab(tabPageRoutes);
                tbox_addRoute_id.Text = DeliveryHolder.routes.Count == 0 ? "1" :
                                        (DeliveryHolder.routes.Count + 1).ToString();

                WorkerHolder.avaliableWorkers    = WorkerClient.GetAavalibleWorkers();
                DeliveryHolder.avaliableVehicles = DeliveryClient.GetAvalibleVehicles();

                setupRouteCmb();
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to add route");
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        private void btnAddRouteTab_Click(object sender, EventArgs e)
        {
            tabControlPartners.SelectedTab = tabControlPartners.TabPages[1];
            btnAddRoute.Visible            = true;
            btnSaveRoute.Visible           = false;
            btnSearchRoute.Visible         = false;

            try
            {
                WorkerHolder.avaliableWorkers    = WorkerClient.GetAavalibleWorkers();
                DeliveryHolder.avaliableVehicles = DeliveryClient.GetAvalibleVehicles();
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to get avaliable vehicles or workers");
            }


            clearTab(tabPageRoutes);
            tbox_addRoute_id.Text = DeliveryHolder.routes.Count == 0 ? "1" :
                                    (DeliveryHolder.routes.Count + 1).ToString();
            setupRouteCmb();
        }