accountmanager.cs
来自「个人理财系统 毕业论文 本软件是简单实用的公共软件。考虑到系统的构架简单」· CS 代码 · 共 94 行
CS
94 行
using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Windows.Forms;
namespace Financial
{
/// <summary>
/// 帐户管理器类型
/// </summary>
public class AccountManager
{
private AccountCollection accountList = new AccountCollection();
/// <summary>
/// 获取或设置帐户列表
/// </summary>
public AccountCollection AccoutList
{
get
{
return this.accountList;
}
set
{
this.accountList = value;
}
}
/// <summary>
/// 将帐户管理数据保存到文件
/// </summary>
/// <param name="pathOfDataFile">数据文件路径</param>
public bool SaveDataToFile(string pathOfDataFile)
{
StreamWriter sw = new StreamWriter(pathOfDataFile,false,Encoding.Default);
XmlSerializer xml = new XmlSerializer(typeof(AccountCollection));
try
{
xml.Serialize(sw, this.accountList);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return false;
}
finally
{
if (sw != null)
{
sw.Close();
}
}
return true;
}
/// <summary>
/// 重文件读取帐户信息
/// </summary>
/// <param name="pathOfDataFile">数据文件路径</param>
public bool LoadDataFromFile(string pathOfDataFile)
{
StreamReader sr = new StreamReader(pathOfDataFile,Encoding.Default);
XmlSerializer xml = new XmlSerializer(typeof(AccountCollection));
try
{
this.accountList = (AccountCollection)xml.Deserialize(sr);
}
catch //(Exception ex)
{
//MessageBox.Show(ex.ToString());
return false;
}
finally
{
if (sr != null)
{
sr.Close();
}
}
return true;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?