Merge pull request #8 from syncfusion/Update-Nuget-Version
Added validation to Expense description..
This commit is contained in:
Коммит
3e3a351361
|
@ -20,11 +20,12 @@ namespace ExpenseAnalysis
|
|||
|
||||
public class AddTransactionDetail
|
||||
{
|
||||
|
||||
public double Spent { get; set; }
|
||||
|
||||
public CategoryPicker Category { get; set; }
|
||||
|
||||
[Display(Name = "Expense Description")]
|
||||
[Required(AllowEmptyStrings = false, ErrorMessage = "Description should not be empty")]
|
||||
public string ExpenseDescription { get; set; }
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
|
|
@ -8,6 +8,8 @@ namespace ExpenseAnalysis
|
|||
{
|
||||
public TransactionPage TransactionPage;
|
||||
|
||||
bool isDescriptionValid;
|
||||
|
||||
public AddTransactionsPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
@ -15,20 +17,24 @@ namespace ExpenseAnalysis
|
|||
|
||||
private void DoneButton_Clicked(object sender, EventArgs e)
|
||||
{
|
||||
var newTransaction = ((ExpenseViewModel)BindingContext).SingleTransaction;
|
||||
if (newTransaction.Spent != 0)
|
||||
{
|
||||
var transaction = new TransactionDetail
|
||||
{
|
||||
Category = newTransaction.Category.ToString(),
|
||||
Date = newTransaction.Date,
|
||||
Spent = newTransaction.Spent,
|
||||
Name = newTransaction.ExpenseDescription
|
||||
};
|
||||
((ExpenseViewModel)BindingContext).AddTransaction(transaction);
|
||||
TransactionPage.CanNotify = true;
|
||||
isDescriptionValid = dataForm.Validate("ExpenseDescription");
|
||||
if (isDescriptionValid)
|
||||
{
|
||||
var newTransaction = ((ExpenseViewModel)BindingContext).SingleTransaction;
|
||||
if (newTransaction.Spent != 0)
|
||||
{
|
||||
var transaction = new TransactionDetail
|
||||
{
|
||||
Category = newTransaction.Category.ToString(),
|
||||
Date = newTransaction.Date,
|
||||
Spent = newTransaction.Spent,
|
||||
Name = newTransaction.ExpenseDescription
|
||||
};
|
||||
((ExpenseViewModel)BindingContext).AddTransaction(transaction);
|
||||
TransactionPage.CanNotify = true;
|
||||
}
|
||||
Navigation.PopToRootAsync();
|
||||
}
|
||||
Navigation.PopToRootAsync();
|
||||
}
|
||||
|
||||
private void DataForm_AutoGeneratingDataFormItem(object sender, AutoGeneratingDataFormItemEventArgs e)
|
||||
|
|
Загрузка…
Ссылка в новой задаче