📄 formaccountmanage.cs
字号:
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();
}
}
/// <summary>
///打印
/// </summary>
private void toolStripButton_Print_Click(object sender, EventArgs e)
{
string pathOfPrintFile = "";
this.Print(pathOfPrintFile);
}
/// <summary>
/// 导入
/// </summary>
private void toolStripButton_DataInput_Click(object sender, EventArgs e)
{
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.openFileDialog1.FileName;
StreamReader sr = new StreamReader(path, Encoding.Default);
XmlSerializer xml = new XmlSerializer(typeof(AccountCollection));
AccountCollection accColl = null;
try
{
accColl = (AccountCollection)xml.Deserialize(sr);
}
catch (Exception ex)
{
MessageBox.Show("被损坏的数据文件或不合法的数据格式,无法导入!!\n:" + ex.Message);
return;
}
finally
{
if(sr == null)
{
sr.Close();
}
}
File.Copy(path, this.user.PathOfDataFile_Account,true);
if (accColl != null)
{
this.user.AccountMagr.AccoutList = accColl;
}
this.FormAccountManage_Load(null, null);
}
}
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripButton_DataOutput_Click(object sender, EventArgs e)
{
if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
{
string path = this.saveFileDialog1.FileName;
try
{
File.Copy(this.user.PathOfDataFile_Account, path);
}
catch(Exception ex)
{
MessageBox.Show("转存时发生异常:\n" + ex.Message);
}
}
}
/// <summary>
/// 退出
/// </summary>
private void toolStripButton_Exit_Click(object sender, EventArgs e)
{
this.Close();
}
#region right click
private void ToolStripMenuItem_AddNew_Click(object sender, EventArgs e)
{
this.toolStripSplitButton_Add.PerformClick();
}
private void ToolStripMenuItem_Statistic_Click(object sender, EventArgs e)
{
this.toolStripButton_Statistic.PerformClick();
}
private void ToolStripMenuItem_Print_Click(object sender, EventArgs e)
{
this.toolStripButton_Print.PerformClick();
}
private void ToolStripMenuItem_Import_Click(object sender, EventArgs e)
{
this.toolStripButton_DataInput.PerformClick();
}
private void ToolStripMenuItem_Output_Click(object sender, EventArgs e)
{
this.toolStripButton_DataOutput.PerformClick();
}
private void ToolStripMenuItem_Modify_Click(object sender, EventArgs e)
{
this.toolStripButton_Modify.PerformClick();
}
private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
{
this.toolStripButton_Del.PerformClick();
}
#endregion
private void textBox_Select_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
this.buttonSelect.PerformClick();
}
}
//筛选
private void buttonSelect_Click(object sender, EventArgs e)
{
string pattern = this.textBox_Select.Text.Trim();
if (string.IsNullOrEmpty(pattern))
{
return;
}
ListViewGroup groupSelected = new ListViewGroup("groupSelected", "筛选结果: " + pattern);
ListViewGroup groupOther = new ListViewGroup("groupOther","其它");
this.listView1.Groups.Clear();
this.listView1.Groups.Add(groupSelected);
this.listView1.Groups.Add(groupOther);
for (int i = 0; i < this.listView1.Items.Count; i++)
{
ListViewItem lvi =(ListViewItem) this.listView1.Items[i];
this.listView1.Items[i].Remove();
string source = "";
for (int j = 0; j < lvi.SubItems.Count; j++)
{
source += lvi.SubItems[j].Text;
}
if (source.ToString().Contains(pattern))
{
groupSelected.Items.Add(lvi);
}
else
{
groupOther.Items.Add(lvi);
}
this.listView1.Items.Add(lvi);
}
}
private void button_CancelSelect_Click(object sender, EventArgs e)
{
this.listView1.Groups.Clear();
}
//统计
private void toolStripButton_Statistic_Click(object sender, EventArgs e)
{
MessageBox.Show("\n 开源版本,不提供该功能\n ");
return;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -