Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtBox_solarPanelName.Text))
            {
                MessageBox.Show("Pls enter valid name for solar panel.");
                return;
            }
            int power;

            if (!int.TryParse(txtBox_solarPanelPower.Text, out power))
            {
                MessageBox.Show("Please enter valid power.");
                return;
            }

            ShesDbContext context = new ShesDbContext();
            SolarPanel    sp      = new SolarPanel(power, txtBox_solarPanelName.Text);

            context.SolarPanels.Add(sp);
            context.SaveChanges();
            MessageBox.Show("Success");
            txtBox_solarPanelName.Text  = "";
            txtBox_solarPanelPower.Text = "";
            shes.SolarPanels.List.Add(sp);
        }
Ejemplo n.º 2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtBox_BatteryName.Text))
            {
                MessageBox.Show("Pls enter valid name for battery.");
                return;
            }
            int power;

            if (!int.TryParse(txtBox_BatteryPower.Text, out power))
            {
                MessageBox.Show("Please enter valid power.");
                return;
            }
            int capacity = 0;

            if (!int.TryParse(txtBox_BatteryCapacity.Text, out capacity))
            {
                MessageBox.Show("Please enter valid capacity.");
                return;
            }

            Battery       b       = new Battery(power, capacity, txtBox_BatteryName.Text);
            ShesDbContext context = new ShesDbContext();

            context.Battery.Add(b);
            context.SaveChanges();
            MessageBox.Show("Success");
            txtBox_BatteryPower.Text    = "";
            txtBox_BatteryCapacity.Text = "";
            txtBox_BatteryName.Text     = "";
            SHES.Batteries.List.Add(b);
        }
Ejemplo n.º 3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtBox_ConsumerName.Text))
            {
                MessageBox.Show("Pls enter valid name for consumer.");
                return;
            }

            int power;

            if (!int.TryParse(txtBox_ConsumerPower.Text, out power))
            {
                MessageBox.Show("Please enter valid power.");
                return;
            }

            ShesDbContext context = new ShesDbContext();
            Consumer      c       = new Consumer(power, txtBox_ConsumerName.Text);

            context.Consumers.Add(c);
            context.SaveChanges();
            SHES.Consumers.List.Add(c);
            MessageBox.Show("Success");
            txtBox_ConsumerPower.Text = "";
            txtBox_ConsumerName.Text  = "";
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            queues = new SHESToComponentsQueues();
            SHES   = new SHES(queues);
            ShesDbContext dbContext = new ShesDbContext();

            SHES.Batteries.List.AddRange(dbContext.Battery.ToList());
            shes.Consumers.List.AddRange(dbContext.Consumers.ToList());
            shes.SolarPanels.List.AddRange(dbContext.SolarPanels.ToList());

            InitializeComponent();
        }
Ejemplo n.º 5
0
        public SHES()
        {
            CurrentPower = 0;
            Batteries    = new BatteryList();
            Consumers    = new ConsumersList();
            SolarPanels  = new SolarPanelList();
            ShesDbContext context = new ShesDbContext();

            Batteries.List.AddRange(context.Battery.ToList());
            Consumers.List.AddRange(context.Consumers.ToList());
            SolarPanels.List.AddRange(context.SolarPanels.ToList());
            Utility = new Utility(15);
        }