public void UpdateOperation(Finance finance) { string updateQuery = DBHelper.UpdateQueryTemplate; _db.Update<Finance>(finance, updateQuery); }
protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e) { base.OnNavigatingFrom(e); bool isDateCorrect = false; try { DateTime dt = DateTime.Parse(FDate.Text); isDateCorrect = true; } // try catch(FormatException) { isDateCorrect = false; } // else catch(ArgumentNullException) { isDateCorrect = false; } // else if (Explain.Text == null || Price.Text == null || Quant.Text == null || !isDateCorrect) { if (e.IsCancelable) { MessageBoxResult res = MessageBox.Show("точно хотите уйти? Изменения не будут сохранены!", "Заполнены не все поля", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { e.Cancel = true; return; } // if user really want`s get out } // if } // if else { Finance f = new Finance { Explain = this.Explain.Text, Price = Decimal.Parse(this.Price.Text), Quantity = int.Parse(this.Quant.Text), Type = (bool)this.IsIncome.IsChecked, FinanceDate = FDate.Text, }; if (!isUpdate) { App.ViewModel.InsertOperation(f); } // if else { f.IdFinance = this.originalId; App.ViewModel.UpdateOperation(f); } // else } // else }
public void InsertOperation(Finance finance) { string insertQuery = DBHelper.InsertQueryTemplate; _db.Insert<Finance>(finance, insertQuery); }
private void SetFinanceParameters(Finance finance) { Explain.Text = finance.Explain; Price.Text = finance.Price.ToString(); Quant.Text = finance.Quantity.ToString(); IsIncome.IsChecked = finance.Type; IsExpend.IsChecked = !finance.Type; FDate.Text = finance.FinanceDate; originalId = finance.IdFinance; }