Exemplo n.º 1
0
        public async void LoadParking()
        {
            try
            {
                using (var db = new SPARK.Model.SPARKDbContext())
                {
                    IMobileServiceTable <Azure.Parking> userTableObj = App.MobileService.GetTable <Azure.Parking>();
                    List <Azure.Parking> lista = await App.MobileService.GetTable <Azure.Parking>().ToListAsync();

                    Azure.Parking u = lista.Find(x => x.id == IDparkinga);
                    p                = new Parking();
                    p.Address        = u.Address;
                    p.Name           = u.Name;
                    p.Id             = Convert.ToInt32(u.id);
                    p.Zone           = u.Zone;
                    p.Price          = u.Price;
                    p.CoordX         = u.CoordX;
                    p.CoordY         = u.CoordY;
                    p.Capacity       = u.Capacity;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.WorkingHours   = new KeyValuePair <DateTime, DateTime>(Convert.ToDateTime(u.WorkingFrom), Convert.ToDateTime(u.WorkingTo));
                    p.TodaysProfit   = u.TodaysProfit;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.MonthlyProfit  = u.MonthlyProfit;
                    p.NumTakenSpaces = u.NumTakenSpaces;
                    p.MinCredits     = Convert.ToInt32(u.MinCredits);
                }
            }
            catch (Exception izuzetak)
            {
                var dialog1 = new MessageDialog(izuzetak.Message);
                dialog1.Commands.Add(new UICommand {
                    Label = "Ok"
                });
                await dialog1.ShowAsync();
            }
        }
Exemplo n.º 2
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                using (var db = new SPARK.Model.SPARKDbContext())
                {
                    IMobileServiceTable <Azure.Parking> userTableObj = App.MobileService.GetTable <Azure.Parking>();

                    List <Azure.Parking> lista = await App.MobileService.GetTable <Azure.Parking>().ToListAsync();

                    try
                    {
                        Azure.Parking obj = lista.Find(x => x.id == IDparkinga);
                        obj.Name        = TextBoxName.Text.ToString();
                        obj.WorkingFrom = Convert.ToString(openingTime.Time.Hours) + ":" + Convert.ToString(openingTime.Time.Minutes);
                        obj.WorkingTo   = Convert.ToString(closingTime.Time.Hours) + ":" + Convert.ToString(closingTime.Time.Minutes);

                        try
                        {
                            obj.Capacity = Convert.ToInt32(TextBoxCapacity.Text.ToString());
                        }
                        catch (Exception ee)
                        {
                            throw new IOException("Neispravan kapacitet!");
                        }
                        try
                        {
                            obj.Zone = Convert.ToInt32(TextBoxParkingZone.Text);
                        }
                        catch (Exception ee)
                        {
                            throw new IOException("Neispravna zona!");
                        }
                        try
                        {
                            obj.MinCredits = Convert.ToInt32(TextBoxParkingMinCredits.Text.ToString());
                        }
                        catch (Exception ee)
                        {
                            throw new IOException("Neispravno napisan broj minimalnih kredita!");
                        }
                        try
                        {
                            obj.Price = Convert.ToDouble(TextBoxPrice.Text);
                        }
                        catch (Exception ee)
                        {
                            throw new IOException("Neispravno napisana cijena!");
                        }
                        obj.NumTakenSpaces = 0;
                        obj.TodaysProfit   = 0;
                        obj.MonthlyProfit  = 0;
                        await userTableObj.UpdateAsync(obj);

                        MessageDialog msgDialog = new MessageDialog("Uspješno ste ažurirali parking.");
                        await msgDialog.ShowAsync();
                    }
                    catch (IOException ex)
                    {
                        MessageDialog msgDialogError = new MessageDialog("Error : " + ex.Message);
                        await msgDialogError.ShowAsync();
                    }

                    TextBoxName.Text              = string.Empty;
                    TextBoxParkingZone.Text       = string.Empty;
                    TextBoxPrice.Text             = string.Empty;
                    TextBoxAddress.Text           = string.Empty;
                    TextBoxParkingMinCredits.Text = string.Empty;
                    TextBoxCapacity.Text          = string.Empty;
                }
            }
            catch (Exception izuzetak)
            {
                var dialog1 = new MessageDialog(izuzetak.Message);
                dialog1.Commands.Add(new UICommand {
                    Label = "Ok"
                });
                await dialog1.ShowAsync();
            }
        }