コード例 #1
0
        private void ExpenseAddButton_Click(object sender, RoutedEventArgs e)
        {
            string memberName  = MemberComboBox.SelectedItem as string;
            string description = ExpenseDesTextBox.Text;

            //ExpenseDesTextBox.Text
            if (string.IsNullOrEmpty(memberName))
            {
                ShowErrorDialog("Chọn thành viên thực hiện khoản chi");
            }
            else if (string.IsNullOrEmpty(description))
            {
                ShowErrorDialog("Điền thông tin khoản chi           ");
            }
            else
            {
                string ct   = ExpenseCostTextBox.Text.Replace(" ", string.Empty);
                double cost = 0;
                if (double.TryParse(ct, out cost) && cost > 0)
                {
                    MbExpense expense = new MbExpense()
                    {
                        MemberName  = memberName,
                        Description = description,
                        Cost        = cost
                    };
                    Expenses.Add(expense);
                }
                else
                {
                    ShowErrorDialog("Chi phí là một số lớn hơn không    ");
                }
            }
        }
コード例 #2
0
        private void ExpenseRemoveButton_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;

            if (button != null)
            {
                MbExpense expense = button.DataContext as MbExpense;
                Expenses.Remove(expense);
            }
        }