Ejemplo n.º 1
0
 public StoreRoute(MainForn origin)
 {
     this.origin = origin;
     ShowOrigin  = true;
     ShowWarning = true;
     InitializeComponent();
     StoreAdministrator.Start();
     ReadImages();
 }
Ejemplo n.º 2
0
 public Simulation(MainForn origin)
 {
     this.origin = origin;
     ShowOrigin  = true;
     InitializeComponent();
     StoreAdministrator.Start();
     ReadImages();
     button2.Enabled = false;
     vegcount        = 0;
     sodcount        = 0;
     bredcount       = 0;
 }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
            Dictionary <int, int> inventory = StoreAdministrator.InventoryTomorrow();

            //Chain
            ProductHandler veg   = new VegetableTrucks((int)vegetablecount.Value);
            ProductHandler soda  = new SodaTrucks((int)sodacount.Value);
            ProductHandler bread = new BreadTrucks((int)breadcount.Value);

            veg.SetSuccessor(soda);
            soda.SetSuccessor(bread);

            var simulationInv = veg.ProcessRequest(inventory);

            int validate = 0;

            foreach (var keyValuePair in inventory)
            {
                if (keyValuePair.Value > 0)
                {
                    AppendText(richTextBox1, Color.Red, "The demand of product with ID " + keyValuePair.Key.ToString() + " cannot be supplied with " + keyValuePair.Value.ToString() + " products missing \n");
                }

                else if (keyValuePair.Value == 0)
                {
                    AppendText(richTextBox1, Color.LightGreen, "The demand of product with ID " + keyValuePair.Key.ToString() + " can be supplied " + "\n");
                    validate++;
                }

                else
                {
                    AppendText(richTextBox1, Color.Green, "The demand of product with ID " + keyValuePair.Key.ToString() + " can be supplied with " + (keyValuePair.Value * -1).ToString() + " products left over \n");
                    validate++;
                }
            }
            //meaning the three products can be sent
            button2.Enabled = validate >= 3;
        }
Ejemplo n.º 4
0
        private void ReadImages( )
        {
            ClientAPI adapter    = new ClientAPI();
            string    folderPath = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName, @"Images\");

            foreach (string path in Directory.EnumerateFiles(folderPath, "*.jpg"))
            {
                Image QR = Image.FromFile(path);

                Store converted = adapter.Decode(QR);
                QR.Dispose();

                if (converted != null)
                {
                    converted.LastOrderPath = path;
                    StoreAdministrator.StoreListToday.Add(converted);
                }
            }
            //decide route
            StoreAdministrator.UpdateDeliverToday();
            //show datagrid
            ShowTable();
        }