private void btnLogin_Click(object sender, EventArgs e) { string jobNum = this.textJobNum.Text; string password = this.textPwb.Text; ConnetionMysql mysql = new ConnetionMysql(); if (jobNum != "" && password != "") { using (mysql.Conn) { mysql.Conn.Open(); string sql = string.Format("select * from users where jobNum='{0}' and password='******'", jobNum, password); mysql.Comd = new MySqlCommand(sql, mysql.Conn); MySqlDataReader data = mysql.Comd.ExecuteReader(); if (data.HasRows) { data.Read(); if (data["password"].Equals(password)) { Manage manage = new Manage(); manage.JobNum = (string)data["jobNum"]; manage.L = this; manage.UserStatus = Convert.ToInt32(data["status"]); manage.JobName = data["name"].ToString(); this.Hide(); manage.Show(); mysql.Conn.Close(); } else { MessageBox.Show("密码错误!"); } } else { MessageBox.Show("用户不存在!"); } /* if (data.HasRows) * { * if (data.Read()) * { * if (data["jobNum"].Equals(jobNum) && data["password"].Equals(password)) * { * if (Convert.ToInt32(data["status"]) == staff) * { * Staff staff = new Staff(jobNum); * staff.Show(); * this.Hide(); * mysql.Conn.Close(); * } * else if (Convert.ToInt32(data["status"]).Equals((int)Enums.manage)) * { * Manage manage = new Manage(); * manage.JobNum = (string)data["jobNum"]; * manage.L = this; * manage.UserStatus = Convert.ToInt32(data["status"]); * this.Hide(); * manage.Show(); * mysql.Conn.Close(); * } * } * } * * }else * { * MessageBox.Show("工号或者密码错误!"); * } * * * } */ } } else { MessageBox.Show("工号或者密码不能为空!"); } }