Exemplo n.º 1
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     //listAppliances = model.getAllAppliances();
     appliancesModel = new AppliancesViewModel();
     try
     {
         appliances = appliancesModel.getAllAppliances();
         if (appliances != null)
         {
             foreach (var ap in appliances)
             {
                 listView.Items.Add(ap.NUMBER_OF_ITEMS + "# " + ap.APPLIANCE_NAME + "(s) WATTS:" + ap.WATTS);
             }
         }
         else
         {
             messageBox("No appliances in the database");
         }
     }
     catch (Exception ex)
     {
         messageBox("error " + ex.Message);
     }
     //listView.ItemsSource = listAppliances;
     base.OnNavigatedTo(e);
 }
Exemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            appliance          = new AppliancesViewModel();
            appliances         = appliance.getAllAppliances();
            txtTotalUnits.Text = "0";
            String totUnits = txtTotalUnits.Text;

            TotalUnits = Convert.ToInt32(totUnits);



            try
            {
                if (appliances != null)
                {
                    names  = new string[appliances.Count];
                    watts  = new int[appliances.Count];
                    number = new int[appliances.Count];
                    hours  = new int[appliances.Count];
                    IDS    = new int[appliances.Count];
                    foreach (var a in appliances)
                    {
                        IDS[count]    = a.ID;
                        names[count]  = a.APPLIANCE_NAME;
                        watts[count]  = a.WATTS;
                        number[count] = a.NUMBER_OF_ITEMS;

                        totalWatts  += watts[count];
                        totalNumber += number[count];
                        totalHours  += hours[count];
                        count++;
                    }
                    ckIron.Content       = IDS[0];
                    ckKettle.Content     = IDS[1];
                    ckFridge.Content     = IDS[2];
                    ckTelevision.Content = IDS[3];
                    ckRadio.Content      = IDS[4];
                    ckMicrowave.Content  = IDS[5];
                    ckToast.Content      = IDS[6];
                    ckDeskTop.Content    = IDS[7];

                    lblIron.Text   = names[0]; txtWattsIron.Text = watts[0] + ""; txtNumberIrons.Text = number[0] + ""; txtHoursIron.Text = 0 + "";
                    lblKettle.Text = names[1]; txtWattsKettle.Text = watts[1] + ""; txtNumberKettle.Text = number[1] + ""; txtHoursKettle.Text = 0 + "";
                    lblFridge.Text = names[2]; txtWattsFridge.Text = watts[2] + ""; txtNumberFridge.Text = number[2] + ""; txtHoursFridge.Text = 0 + "";
                    lblTv.Text     = names[3]; txtWattsTV.Text = watts[3] + ""; txtNumberTV.Text = number[3] + ""; txtHoursTV.Text = 0 + "";
                    //lblTv.Text = names[4]; txtWattsTV.Text = watts[3] + ""; txtNumberTV.Text = number[3] + ""; txtHoursTV.Text = 0 + "";
                    lblRadio.Text     = names[4]; txtWattsRadio.Text = watts[4] + ""; txtNumberRadio.Text = number[4] + ""; txtHoursRadio.Text = 0 + "";
                    lblMicrowave.Text = names[5]; txtWattsMicrowave.Text = watts[5] + ""; txtNumberMicrowave.Text = number[5] + ""; txtHoursMicrowave.Text = 0 + "";
                    lblToast.Text     = names[6]; txtWattsToast.Text = watts[6] + ""; txtNumberToast.Text = number[6] + ""; txtHoursToast.Text = 0 + "";
                    lblDeskTop.Text   = names[7]; txtWattsDesktop.Text = watts[7] + ""; txtNumberDesktop.Text = number[7] + ""; txtHoursDesktop.Text = 0 + "";
                }
                else
                {
                    messageBox("no data in the table");
                }
            }
            catch (Exception ex)
            {
                messageBox("error " + ex.Message);
            }

            base.OnNavigatedTo(e);
        }