您的位置:首页 > 其它

登录窗体验证账号密码

2014-10-14 16:38 176 查看
主窗体:frmMain,登录窗体:frmLogin

Program.cs代码:

static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
frmLogin f = new frmLogin();
f.ShowDialog();
if (f.DialogResult == DialogResult.OK)
{
Application.Run(new frmMain());
}

}
}

登录窗体代码:

public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
}

private void btnOK_Click(object sender, EventArgs e)
{
string sql="select count(*) from t_User where zh='"+txtZH.Text.Trim()+"' and mm='"+txtMM.Text.Trim()+"'";
int n = (int)DbHelper.executeScalar(sql);
if (n != 0)
{
DialogResult = DialogResult.OK;
this.Close();
this.Dispose();
}
else
{
MessageBox.Show("账号或密码错误!","提示:");
}
}

private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐