private void btnLogin_Click(object sender, EventArgs e)
{
if (this.Text.Trim() != "")
{
if (txtPassWord.Text != "")
{
SqlCommand command = CustomDataProvide.GetCommand(
"select * from UserInfo where UserID='" + combUserID.Text.Trim() +
"'and Password='" + txtPassWord.Text.Trim() + "'");
SqlDataReader dr;
try
{
command.Connection.Open();
dr = command.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
Logintimes = 0;
Main main = new Main();
Main.LoginUser.UserID = dr.GetString(0);
Main.LoginUser .UserName = dr.GetString(1);
Main.LoginUser .Password = dr.GetString(2);
Main.LoginUser .Isadmin = dr.GetBoolean(3);
Main.LoginUser.Day = (Week )dr.GetInt32(4);
this.Hide();
main.Show();
dr.Close();
command.Connection.Close();
command.Dispose(); }
else
{ Logintimes++;
if (Logintimes == 3)
{ MessageBox.Show("对不起,你登录的次数
已经超过三次!", "警告!");
Application.Exit();
}
if (BookInfoM.ClassCodes.DataValidate.IDExist("select
UserID from UserInfo where UserID='" + combUserID.Text.Trim().ToString()
+ "'") == true)
{ MessageBox.Show("密码不正确", "警告!");
txtPassWord.Text = ""; }
else
{ MessageBox.Show("此用户ID不存在,请查
证后登录", "提示");
combUserID.Text = "";
txtPassWord.Text = "";
} } }
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
} }
else
{ MessageBox.Show("密码不能为空", "提示"); } }
else
{ MessageBox.Show("用户ID不能为空", "提示"); } }
private void btnExit_Click(object sender, EventArgs e)
{
if (MessageBox.Show("你确认要退出该程序吗?",
"提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.Yes)
Application.Exit();
} }
上一页 [1] [2] [3] [4] [5] [6] [7] [8] 下一页