예제 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if(System.IO.File.Exists("C:\\ProgramData\\YT\\FileHandle\\user.dat"))
     {
         MessageBox.Show("已存在注册用户!请登录");
         Close();
         return;
     }
     if(string.IsNullOrEmpty(textBox1.Text))
     {
         MessageBox.Show("请输入正确的用户名!");
         return;
     }
     if(string.IsNullOrEmpty(textBox2.Text))
     {
         MessageBox.Show("密码不能为空!");
         return;
     }
     if(textBox3.Text!=textBox2.Text)
     {
         MessageBox.Show("两次输入的密码不一致!");
         return;
     }
     ui = new UserInfo(textBox1.Text, textBox2.Text);
     UserInfo.Save(ui, "user.dat");
     MessageBox.Show("注册成功!");
     DialogResult = DialogResult.OK;
     Close();
 }
예제 #2
0
 /// <summary>
 /// 保存信息
 /// </summary>
 /// <param name="ui"></param>
 /// <param name="path"></param>
 public static void Save(UserInfo ui,string path)
 {
     ui.Serialize(path);
 }