コード例 #1
0
        /// <summary>
        ///修改帐户信息
        /// </summary>
        private void toolStripButton_Modify_Click(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count == 0)
            {
                return;
            }


            FormAddAccount faa  = new FormAddAccount();
            Account        acc  = new Account();
            ListViewItem   item = this.listView1.SelectedItems[0];

            faa.textBox_UserName.Text         = item.SubItems[1].Text;
            faa.textBox_BankbookNum.Text      = item.SubItems[2].Text;
            faa.textBox_cardNum.Text          = item.SubItems[3].Text;
            faa.dateTimePicker_StartDate.Text = item.SubItems[4].Text;
            faa.textBox_BankName.Text         = item.SubItems[5].Text;
            faa.textBox_MoneyType.Text        = item.SubItems[6].Text;
            faa.textBox_AccountType.Text      = item.SubItems[7].Text;
            faa.textBox_IniBalance.Text       = item.SubItems[8].Text;
            faa.textBox_RemainBalance.Text    = item.SubItems[9].Text;
            faa.textBox_Reamrk.Text           = item.SubItems[10].Text;

            if (faa.ShowDialog() == DialogResult.OK)
            {
                acc.IniBlance    = double.Parse(faa.textBox_IniBalance.Text);
                acc.MoneyType    = faa.textBox_MoneyType.Text;
                acc.OwnerName    = faa.textBox_UserName.Text;
                acc.RemainBlance = double.Parse(faa.textBox_RemainBalance.Text);
                acc.Remark       = faa.textBox_Reamrk.Text;
                acc.StartDate    = faa.dateTimePicker_StartDate.Value;
                acc.AccountType  = faa.textBox_AccountType.Text;
                acc.BankbookNum  = faa.textBox_BankbookNum.Text;
                acc.BankName     = faa.textBox_BankName.Text;
                acc.CardNum      = faa.textBox_cardNum.Text;


                this.accountManager.AccoutList.Add(acc);

                string[] its = new string[] {
                    (this.listView1.SelectedIndices[0] + 1).ToString(),
                    acc.OwnerName.ToString(),
                    acc.BankbookNum.ToString(),
                    acc.CardNum.ToString(),
                    acc.StartDate.ToString(),
                    acc.BankName.ToString(),
                    acc.MoneyType.ToString(),
                    acc.AccountType.ToString(),
                    acc.IniBlance.ToString(),
                    acc.RemainBlance.ToString(),
                    acc.Remark.ToString()
                };
                ListViewItem lvi = new ListViewItem(its);

                this.listView1.Items[this.listView1.SelectedIndices[0]] = lvi;

                this.SaveListViewToFile();
            }
        }
コード例 #2
0
        /// <summary>
        /// //添加帐户
        /// </summary>
        private void toolStripSplitButton_Add_Click(object sender, EventArgs e)
        {
            FormAddAccount faa = new FormAddAccount();
            Account        acc = new Account();

            if (faa.ShowDialog(this) == DialogResult.OK)
            {
                acc.IniBlance    = double.Parse(faa.textBox_IniBalance.Text);
                acc.MoneyType    = faa.textBox_MoneyType.Text;
                acc.OwnerName    = faa.textBox_UserName.Text;
                acc.RemainBlance = double.Parse(faa.textBox_RemainBalance.Text);
                acc.Remark       = faa.textBox_Reamrk.Text;
                acc.StartDate    = faa.dateTimePicker_StartDate.Value;
                acc.AccountType  = faa.textBox_AccountType.Text;
                acc.BankbookNum  = faa.textBox_BankbookNum.Text;
                acc.BankName     = faa.textBox_BankName.Text;
                acc.CardNum      = faa.textBox_cardNum.Text;


                this.accountManager.AccoutList.Add(acc);

                string[] items = new string[] {
                    (this.listView1.Items.Count + 1).ToString(),
                    acc.OwnerName.ToString(),
                    acc.BankbookNum.ToString(),
                    acc.CardNum.ToString(),
                    acc.StartDate.ToString(),
                    acc.BankName.ToString(),
                    acc.MoneyType.ToString(),
                    acc.AccountType.ToString(),
                    acc.IniBlance.ToString(),
                    acc.RemainBlance.ToString(),
                    acc.Remark.ToString()
                };
                ListViewItem lvi = new ListViewItem(items);
                this.listView1.Items.Add(lvi);

                this.SaveListViewToFile();
            }
        }