using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ocean; namespace demo.UI { public delegate void LoginSuccess(string username); public partial class FormUser : Form { public LoginSuccess LoginSuccessHandle; public string _user = "OP"; public FormUser() { InitializeComponent(); } public FormUser(LoginSuccess loginSuccess) { InitializeComponent(); LoginSuccessHandle = loginSuccess; } private void FormUser_Load(object sender, EventArgs e) { textBox1.Text = _user; } private void button1_Click(object sender, EventArgs e) { if (user.login(textBox1.Text.ToString(), textBox2.Text.ToString()) != 0) { MessageBox.Show("Login Fail"); return; } if(LoginSuccessHandle!=null) { LoginSuccessHandle(user.cur_user()); } var.setstring("user", user.cur_user()); this.DialogResult = DialogResult.OK; this.Close(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } }