Ejemplo n.º 1
0
        public MainPage()
        {
            TestDrive = new TestDrive();

            BindingContext = this;
            InitializeComponent();

            MessagingCenter.Subscribe <Page>(this, "TestDriveSaved", (sender) =>
            {
                TestDrive = new TestDrive();
                OnPropertyChanged("TestDrive");
            });

            MessagingCenter.Subscribe <Car>(this, "SelectCarFromList", (Car) =>
            {
                TabbedPage tb  = (TabbedPage)Parent;
                tb.CurrentPage = tb.Children.First(page => page == this);

                if (ListView.ItemsSource != null)
                {
                    IEnumerable <Grouping <string, Car> > CarsInList = ListView.ItemsSource.Cast <Grouping <string, Car> >();
                    Car selectedCar       = CarsInList.SelectMany(g => g.ToList()).FirstOrDefault(c => c.Id == Car.Id);
                    ListView.SelectedItem = selectedCar;
                }
            });

            MessagingCenter.Subscribe <Page>(this, "GoToTestDrivePage", (source) =>
            {
                TabbedPage tb  = (TabbedPage)Parent;
                tb.CurrentPage = tb.Children.First(page => page == this);
            });
        }
Ejemplo n.º 2
0
 public int SaveTestDrive(TestDrive item)
 {
     if (item.Id != 0)
     {
         database.Update(item);
         return(item.Id);
     }
     else
     {
         return(database.Insert(item));
     }
 }
Ejemplo n.º 3
0
        async private void Button_Clicked(object sender, EventArgs e)
        {
            App.Database.SaveTestDrive(TestDrive);

            int id = App.Database.GetLastInsertedId();

            TestDrive td = App.Database.GetTestDrive(id);

            System.Diagnostics.Debug
            .WriteLine("Test Drive ID: " + td.Id + " ; CarId: " + td.CarId + " ; FullName: " + td.FullName + " ;Phone:" + td.PhoneNumber + "; Email: " + td.Email + "; Showroom: " + td.Showroom);

            await DisplayAlert("Уведомление", "Ваша запись оформлена!", "Ок");

            MessagingCenter.Send <Page>(this, "TestDriveSaved");
            await Navigation.PopAsync();
        }
Ejemplo n.º 4
0
 public int SaveTestDrive(TestDrive item)
 {
     return(item.Id);
 }
Ejemplo n.º 5
0
        public ConfirmPage(TestDrive td)
        {
            TestDrive = td;

            Title = "Подтверждение записи на тест-драйв";

            Button button = new Button
            {
                VerticalOptions   = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Text         = "Подтвердить",
                AutomationId = "ButtonConfirmSubmit"
            };

            button.Clicked += Button_Clicked;

            List <string> containerStyle = new List <string> {
                "container"
            };
            List <string> labelBigStyle = new List <string> {
                "label-big"
            };

            Content = new StackLayout {
                AutomationId = "ConfirmPageContainer",
                Children     =
                {
                    new StackLayout
                    {
                        StyleClass  = containerStyle,
                        Orientation = StackOrientation.Horizontal,
                        IsVisible   = !string.IsNullOrEmpty(TestDrive.FullName),
                        Children    =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "ФИО:", VerticalTextAlignment = TextAlignment.Center
                            },
                            new Label {
                                Text = TestDrive.FullName, VerticalTextAlignment = TextAlignment.Center
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = !string.IsNullOrEmpty(TestDrive.FullName)
                    },
                    new StackLayout
                    {
                        StyleClass  = containerStyle,
                        Orientation = StackOrientation.Horizontal,
                        IsVisible   = !string.IsNullOrEmpty(TestDrive.PhoneNumber),
                        Children    =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "Телефонный номер:", VerticalTextAlignment = TextAlignment.Center
                            },
                            new Label {
                                Text = TestDrive.PhoneNumber, VerticalTextAlignment = TextAlignment.Center
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = !string.IsNullOrEmpty(TestDrive.PhoneNumber)
                    },
                    new StackLayout
                    {
                        StyleClass  = containerStyle,
                        Orientation = StackOrientation.Horizontal,
                        IsVisible   = !string.IsNullOrEmpty(TestDrive.Email),
                        Children    =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "Электронный адрес:", VerticalTextAlignment = TextAlignment.Center
                            },
                            new Label {
                                Text = TestDrive.Email, VerticalTextAlignment = TextAlignment.Center
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = !string.IsNullOrEmpty(TestDrive.Email)
                    },
                    new StackLayout
                    {
                        StyleClass = containerStyle,
                        IsVisible  = !string.IsNullOrEmpty(TestDrive.Showroom),
                        Children   =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "Адрес салона"
                            },
                            new Label {
                                Text = TestDrive.Showroom
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = !string.IsNullOrEmpty(TestDrive.Showroom)
                    },
                    new StackLayout
                    {
                        StyleClass  = containerStyle,
                        Orientation = StackOrientation.Horizontal,
                        IsVisible   = TestDrive.Car != null,
                        Children    =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "Автомобиль:", VerticalTextAlignment = TextAlignment.Center
                            },
                            new Label {
                                Text = TestDrive.Car?.MainInfo ?? string.Empty, VerticalTextAlignment = TextAlignment.Center
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand, IsVisible = TestDrive.Car != null
                    },
                    new StackLayout
                    {
                        StyleClass  = containerStyle,
                        Orientation = StackOrientation.Horizontal,
                        Children    =
                        {
                            new Label {
                                StyleClass = labelBigStyle, Text = "Дата:", VerticalTextAlignment = TextAlignment.Center
                            },
                            new Label {
                                Text = TestDrive.DateTime.ToString("dd.MM.yyyy HH:mm"), VerticalTextAlignment = TextAlignment.Center
                            },
                        }
                    },
                    new BoxView       {
                        StyleClass = new List <string>{
                            "hr"
                        }, HorizontalOptions = LayoutOptions.FillAndExpand
                    },
                    button,
                }
            };

            Resources.Add(StyleSheet.FromAssemblyResource(IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly, "CarShowroom.styles.css"));
        }