using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb; //Access的命名空间
using CCWin;
using CCWin.SkinControl;
using CCWin.SkinClass;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;//引用序列化类
namespace quanyuntong
{
public partial class Form1 : CCSkinMain
{
//static public string usmen;//用户名,做用于保存
//static public string uspass;//密码,保存
public Form1()
{
InitializeComponent();//完成窗体的初始化工作
}
//窗体加载
List<User> aalist;//声明一个用户的泛型集合
private void Form1_Load(object sender, EventArgs e)
{
if (File.Exists("userInfo.txt"))//查检文件是否存在,存在是true则花括号内的程序
{
FileStream fs = new FileStream("userInfo.txt", FileMode.Open, FileAccess.Read);
BinaryFormatter bf = new BinaryFormatter();//创建一个序列化和反序列化类的对象
aalist = (List<User>)bf.Deserialize(fs);//调用反序列化方法,从文件userInfo.txt中读取对象信息
for (int i = 0; i < aalist.Count; i++)
{
if (i == 0 && aalist.LoginName != "")
{
this.skinCheckBox1.Checked = true;
this.txt_Pwd.Text = aalist.LoingPassword;
}
this.txt_Name.Text = aalist.LoginName.ToString();
}
fs.Close();//关闭文件流
}
else
{
aalist = new List<User>();
txt_Name.Text = "";
}
}