async void MainInfoSaveButton_Clicked(object sender, EventArgs e) { int CurrentAdId = CrossSettings.Current.GetValueOrDefault("CurrentAdId", 0); if (CurrentAdId.Equals(0)) { await Navigation.PushModalAsync(new NavigationPage(new MainPage())); } var AdVM = AdSQLiteH.GetById(CurrentAdId); AdVM.VIN = VINEntry.Text; AdVM.Mark = MarkPicker.Items[MarkPicker.SelectedIndex]; AdVM.Model = ModelPicker.Items[ModelPicker.SelectedIndex]; AdVM.Year = YearPicker.Items[YearPicker.SelectedIndex]; AdVM.Mileage = Convert.ToDouble(MileageEntry.Text); AdVM.Kuzov = KuzovPicker.Items[KuzovPicker.SelectedIndex]; AdVM.Color = ColorPicker.Items[ColorPicker.SelectedIndex]; AdVM.SteeringWheel = GetterRB(SteeringWheelRB); AdSQLiteH.SaveItem(AdVM); await DisplayAlert("", "Общая информация успешно сохранена", "OK"); await Navigation.PushModalAsync(new NavigationPage(new AdPage())); return; }
public DvigTransEditPage() { InitializeComponent(); int CurrentAdId = CrossSettings.Current.GetValueOrDefault("CurrentAdId", 0); if (CurrentAdId.Equals(0)) { Navigation.PushModalAsync(new NavigationPage(new MainPage())); } var AdVM = AdSQLiteH.GetById(CurrentAdId); VolumeEntry.Text = AdVM.Volume.ToString(); PowerEntry.Text = AdVM.Power.ToString(); foreach (var DvigType in DvigTypeSQLiteH.GetItems()) { DvigTypePicker.Items.Add(DvigType.Value); } DvigTypePicker.SelectedIndex = DvigTypePicker.Items.IndexOf(AdVM.DvigType); foreach (var KPP in KPPSQLiteH.GetItems()) { KPPPicker.Items.Add(KPP.Value); } KPPPicker.SelectedIndex = KPPPicker.Items.IndexOf(AdVM.KPP); foreach (var DriveUnit in DriveUnitSQLiteH.GetItems()) { DriveUnitPicker.Items.Add(DriveUnit.Value); } DriveUnitPicker.SelectedIndex = DriveUnitPicker.Items.IndexOf(AdVM.DriveUnit); }
public MainInfoEditPage() { InitializeComponent(); int CurrentAdId = CrossSettings.Current.GetValueOrDefault("CurrentAdId", 0); if (CurrentAdId.Equals(0)) { Navigation.PushModalAsync(new NavigationPage(new MainPage())); } var AdVM = AdSQLiteH.GetById(CurrentAdId); VINEntry.Text = AdVM.VIN; MileageEntry.Text = AdVM.Mileage.ToString(); SetterRB(SteeringWheelRB, AdVM.SteeringWheel); foreach (var Mark in MarkSQLiteH.GetItems()) { MarkPicker.Items.Add(Mark.Value); } MarkPicker.SelectedIndex = MarkPicker.Items.IndexOf(AdVM.Mark); foreach (var Model in ModelSQLiteH.GetItems()) { ModelPicker.Items.Add(Model.Value); } ModelPicker.SelectedIndex = ModelPicker.Items.IndexOf(AdVM.Model); foreach (var Kuzov in KuzovSQLiteH.GetItems()) { KuzovPicker.Items.Add(Kuzov.Value); } KuzovPicker.SelectedIndex = KuzovPicker.Items.IndexOf(AdVM.Kuzov); foreach (var Year in YearSQLiteH.GetItems()) { YearPicker.Items.Add(Year.Value); } YearPicker.SelectedIndex = YearPicker.Items.IndexOf(AdVM.Year); foreach (var Color in ColorSQLiteH.GetItems()) { ColorPicker.Items.Add(Color.Value); } ColorPicker.SelectedIndex = ColorPicker.Items.IndexOf(AdVM.Color); }
async void DvigTransSaveButton_Clicked(object sender, EventArgs e) { int CurrentAdId = CrossSettings.Current.GetValueOrDefault("CurrentAdId", 0); if (CurrentAdId.Equals(0)) { await Navigation.PushModalAsync(new NavigationPage(new MainPage())); } var AdVM = AdSQLiteH.GetById(CurrentAdId); AdVM.DvigType = DvigTypePicker.Items[DvigTypePicker.SelectedIndex]; AdVM.KPP = KPPPicker.Items[KPPPicker.SelectedIndex]; AdVM.DriveUnit = DriveUnitPicker.Items[DriveUnitPicker.SelectedIndex]; AdVM.Volume = Convert.ToDouble(VolumeEntry.Text); AdVM.Power = Convert.ToDouble(PowerEntry.Text); AdSQLiteH.SaveItem(AdVM); await DisplayAlert("", "Двигатель и трансмиссия успешно сохранена", "OK"); await Navigation.PushModalAsync(new NavigationPage(new AdPage())); return; }
async void AddAd_OnClicked(object sender, EventArgs e) { string AdDataJson = CrossSettings.Current.GetValueOrDefault("AdData", null); if (String.IsNullOrEmpty(AdDataJson)) { await DisplayAlert("Предупреждение", "Не удалось создать объявление", "ОК"); return; } var adVM = JsonConvert.DeserializeObject <AdViewModel>(AdDataJson); DvigTypeErrorLabel.Text = ""; KPPErrorLabel.Text = ""; DriveUnitErrorLabel.Text = ""; VolumeErrorLabel.Text = ""; PowerErrorLabel.Text = ""; if (DvigTypePicker.SelectedIndex.Equals(-1)) { DvigTypeErrorLabel.Text = "Выберите тип двигателя"; return; } else { adVM.DvigType = DvigTypePicker.Items[DvigTypePicker.SelectedIndex]; } if (KPPPicker.SelectedIndex.Equals(-1)) { KPPErrorLabel.Text = "Выберите КПП"; return; } else { adVM.KPP = KPPPicker.Items[KPPPicker.SelectedIndex]; } if (DriveUnitPicker.SelectedIndex.Equals(-1)) { DriveUnitErrorLabel.Text = "Выберите привод"; return; } else { adVM.DriveUnit = DriveUnitPicker.Items[DriveUnitPicker.SelectedIndex]; } if (String.IsNullOrEmpty(VolumeEntry.Text)) { VolumeErrorLabel.Text = "Введите объем"; return; } else { adVM.Volume = Convert.ToDouble(VolumeEntry.Text); } if (String.IsNullOrEmpty(PowerEntry.Text)) { PowerErrorLabel.Text = "Введите мощность"; return; } else if (PowerEntry.Text.Length < 2 || PowerEntry.Text.Length > 6) { PowerErrorLabel.Text = "Мощность должна содержать от 2 до 6 символов"; return; } else { adVM.Power = Convert.ToDouble(PowerEntry.Text); } CrossSettings.Current.AddOrUpdateValue("AdData", ""); string curUserVM_json = CrossSettings.Current.GetValueOrDefault("current_user", null); int curUserVMId = JsonConvert.DeserializeObject <UserViewModel>(curUserVM_json).Id; adVM.UserId = curUserVMId; adVM.Created_at = DateTime.Now; int CurrentAdId = AdSQLiteH.SaveItem(adVM); KomplektnostSQLiteH.SaveItem(KomplektnostSQLiteH.GetDefaultKomplektnostVM(CurrentAdId)); KomplektacyaSQLiteH.SaveItem(KomplektacyaSQLiteH.GetDefaultKomplektacyaVM(CurrentAdId)); CrossSettings.Current.AddOrUpdateValue("CurrentAdId", CurrentAdId); await Navigation.PushModalAsync(new NavigationPage(new AdPage())); }