private void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.cboxUserName.Text)) { MessageBox.Show("请输入用户名"); this.cboxUserName.Focus(); return; } if (string.IsNullOrEmpty(this.txtPassword.Text)) { MessageBox.Show("请输入密码"); this.txtPassword.Focus(); return; } if (dal.LoginCheck(this.cboxUserName.Text, Md5.Encrypt(this.txtPassword.Text))) { XmlLoginUserEntity entity = new XmlLoginUserEntity() { UserName = this.cboxUserName.Text, Password = new Encryption().Encrypto(this.txtPassword.Text), CreateTime = DateTime.Now, AutoLogin = this.cboxAutoLogin.Checked ? "1" : "0", RememberPwd = this.cboxRememberPwd.Checked ? "1" : "0" }; if (xml.AddOrEditLoginedUserInfo(entity)) { frmMain main = new frmMain(entity.UserName, Md5.Encrypt(this.txtPassword.Text)); //隐藏当前窗体 this.WindowState = FormWindowState.Minimized; //this.ShowInTaskbar = false; if (main.ShowDialog() == DialogResult.Yes) { this.ShowInTaskbar = true; } else if (main.DialogResult == DialogResult.Cancel) { Application.Exit(); } return; } } }