Пример #1
0
 //更新一条记录
 public void Update(Voucher item)
 {
     int index = this._data.FindIndex(c => c.ID == item.ID);
     this._data[index].Account = item.Account;
     this._data[index].Account1 = item.Account1;
     this._data[index].Account2 = item.Account2;
     this._data[index].Category = item.Category;
     this._data[index].Desc = item.Desc;
     this._data[index].DT = item.DT;
     this._data[index].Money = item.Money;
     this._data[index].Store = item.Store;
     this._data[index].Type = item.Type;
 }
Пример #2
0
        public Edit2()
        {
            InitializeComponent();

            Common.BuildListPicker(this.listPickerIncome, 2);
            Common.BuildListPicker(this.listAccountIn);

            id = PhoneApplicationService.Current.State["id"].ToString();
            item = Common.GetRecordById(id);

            moneyBefore = item.Money;
            accountBefore = item.Account;

            listPickerIncome.SelectedItem = item.Category;
            listAccountIn.SelectedItem = item.Account;
            DatePickerIncome.Value = item.DT;
            textBox_Income.Text = item.Money.ToString();
            textBox_IncomeDesc.Text = item.Desc;
        }
Пример #3
0
        public Edit3()
        {
            InitializeComponent();

            Common.BuildListPicker(this.listTransIn);
            Common.BuildListPicker(this.listTransOut);

            id = PhoneApplicationService.Current.State["id"].ToString();
            item = Common.GetRecordById(id);

            moneyBefore = item.Money;
            account1Before = item.Account1;
            account2Before = item.Account2;

            listTransOut.SelectedItem = item.Account1;
            listTransIn.SelectedItem = item.Account2;
            DatePickerTrans.Value = item.DT;
            textBox_Trans.Text = item.Money.ToString();
            textBox_TransDesc.Text = item.Desc;
        }
Пример #4
0
        public Edit1()
        {
            InitializeComponent();
                      
            Common.BuildListPicker(this.listPickerExpenses, 1);
            Common.BuildListPicker(this.listAccountOut);
            Common.BuildStoreList(this.listStoreOut);

            id = PhoneApplicationService.Current.State["id"].ToString();
            item = Common.GetRecordById(id);

            moneyBefore = item.Money;
            accountBefore = item.Account;

            listPickerExpenses.SelectedItem = item.Category;
            listAccountOut.SelectedItem = item.Account;
            listStoreOut.SelectedItem = item.Store;
            DatePickerExpenses.Value = item.DT;
            textBox_Expenses.Text = item.Money.ToString();
            textBox_ExpensesDesc.Text = item.Desc;
        }
Пример #5
0
 private void MenuFlyoutItem_Click_1(object sender, RoutedEventArgs e)
 {
     n = (dynamic)((MenuFlyoutItem)sender).DataContext;
     DataTransferManager.ShowShareUI();
 }
Пример #6
0
 // 移除一条记录
 public void Remove(Voucher item)
 {
     this._data.Remove(item);
 }
Пример #7
0
 // 添加一条记账记录
 public void AddNew(Voucher item)
 {
     item.ID = Guid.NewGuid();
     this._data.Add(item);
 }
Пример #8
0
 //保存收支项
 private bool SaveVoucher()
 {
     
     try
     {
         if (pivot.SelectedIndex == 1)
         {//收入
             if (this.textBox_Income.Text.Trim() == "")
             {
                 MessageBox.Show("金额不能为空!");
                 return false;
             }
             else
             {
                 //一条记账记录的对象
                 Voucher voucher = new Voucher
                 {
                     Money = double.Parse(this.textBox_Income.Text),
                     Desc = this.textBox_IncomeDesc.Text,
                     DT = DateTime.Parse(this.DatePickerIncome.Value.Value.ToString("yyyy/MM/dd")),
                     Category = listPickerIncome.SelectedItem.ToString(),
                     Type = 2,
                     Account = listAccountIn.SelectedItem.ToString()
                 };
                 //添加一条记录
                 App.voucherHelper.AddNew(voucher);
                 App.accountHelper.UpdateBalanceIn(voucher.Account, voucher.Money);
             }
         }
         else if (pivot.SelectedIndex == 0)
         {//支出
             if (this.textBox_Expenses.Text.Trim() == "")
             {
                 MessageBox.Show("金额不能为空!");
                 return false;
             }
             else
             {
                 //一条记账记录的对象
                 Voucher voucher = new Voucher
                 {
                     Money = double.Parse(this.textBox_Expenses.Text),
                     Desc = this.textBox_ExpensesDesc.Text,
                     DT = DateTime.Parse(this.DatePickerExpenses.Value.Value.ToString("yyyy/MM/dd")),
                     Category = listPickerExpenses.SelectedItem.ToString(),
                     Type = 1,
                     Account = listAccountOut.SelectedItem.ToString(),
                     Store = listStoreOut.SelectedItem.ToString()
                 };
                 //添加一条记录
                 App.voucherHelper.AddNew(voucher);
                 App.accountHelper.UpdateBalanceOut(voucher.Account, voucher.Money);
             }
         }
         else
         {//转账
             if (this.textBox_Trans.Text.Trim() == "")
             {
                 MessageBox.Show("金额不能为空!");
                 return false;
             }
             else
             {
                 //一条记账记录的对象
                 Voucher voucher = new Voucher
                 {
                     Money = double.Parse(this.textBox_Trans.Text),
                     Desc = this.textBox_TransDesc.Text,
                     DT = DateTime.Parse(this.DatePickerTrans.Value.Value.ToString("yyyy/MM/dd")),
                     Type = 3,
                     Account1 = listTransOut.SelectedItem.ToString(),
                     Account2 = listTransIn.SelectedItem.ToString()
                 };
                 //添加一条记录
                 App.voucherHelper.AddNew(voucher);
                 App.accountHelper.UpdateBalanceTrans(voucher.Account1, voucher.Account2, voucher.Money);
             }
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message);
         return false;
     }
     ToastPrompt tp = new ToastPrompt();
     SolidColorBrush brush = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
     tp.Foreground = brush;
     tp.Background = pivot.Foreground;
     tp.Message = "保存成功";
     tp.Show();
     return true;
 }
Пример #9
0
        // 保存记账数据
        private async Task <bool> SaveVoucher()
        {
            string erro = "";

            try
            {
                if (pivot.SelectedIndex == 0)
                {//收入
                    if (this.textBox_Income.Text.Trim() == "")
                    {
                        await new MessageDialog("金额不能为空").ShowAsync();
                        return(false);
                    }
                    else
                    {
                        //一条记账记录的对象
                        Voucher voucher = new Voucher
                        {
                            Money    = double.Parse(this.textBox_Income.Text),
                            Desc     = this.textBox_IncomeDesc.Text,
                            DT       = DatePickerIncome.Date.Date.Add(TimePickerIncome.Time),
                            Category = listPickerIncome.SelectedItem.ToString(),
                            Type     = 0
                        };
                        //添加一条记录
                        App.voucherHelper.AddNew(voucher);
                    }
                }
                else
                {//支出
                    if (this.textBox_Expenses.Text.Trim() == "")
                    {
                        await new MessageDialog("金额不能为空").ShowAsync();
                        return(false);
                    }
                    else
                    {
                        //一条记账记录的对象
                        Voucher voucher = new Voucher
                        {
                            Money    = double.Parse(this.textBox_Expenses.Text),
                            Desc     = this.textBox_ExpensesDesc.Text,
                            DT       = DatePickerExpenses.Date.Date.Add(TimePickerExpenses.Time),
                            Category = listPickerExpenses.SelectedItem.ToString(),
                            Type     = 1
                        };
                        //添加一条记录
                        App.voucherHelper.AddNew(voucher);
                    }
                }
            }
            catch (Exception ee)
            {
                erro = ee.Message;
            }
            if (erro != "")
            {
                await new MessageDialog(erro).ShowAsync();
                return(false);
            }
            else
            {
                // 保存数据
                App.voucherHelper.SaveToFile();
                await new MessageDialog("保存成功").ShowAsync();
                return(true);
            }
        }
Пример #10
0
 // 移除一条记录
 public void Remove(Voucher item)
 {
     _data.Remove(item);
 }