private void buttonX1_Click(object sender, EventArgs e) { userCode = tbusername.Text.Trim(); passWord = tbpassword.Text.Trim(); /*if (userName == "admin" && passWord == "1") * { * this.Hide(); * frmMain fm = new frmMain(); * fm.Show(); * } * else * {*/ try { if (userCode == "admin" && passWord == "1") { isSuperGm = true; this.Hide(); frmMain fm = new frmMain(); fm.Show(); } else { //数据库连接的建立 conn = Dbconnection.Dblink(); SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "select * from tb_EmpInfo where EmpId ='" + userCode + "' and EmpLoginPwd ='" + passWord.Trim() + "' and Active= 1"; conn.Open(); qlddr = cmd.ExecuteReader(); qlddr.Read(); if (qlddr.HasRows == true) // { if (qlddr["EmpFalg"].ToString() == "1") //管理员 { isGm = true; } userGrpID = qlddr["EmpGroupID"] == null ? -1 : Convert.ToInt16(qlddr["EmpGroupID"]); //if (qlddr["EmpRole"].ToString() == "01")//出入窑 //{ // isCRY = true; //} //if (qlddr["EmpRole"].ToString() == "02")//出入库 //{ // isCrk = true; //} //if (qlddr["EmpRole"].ToString() == "03")//选瓷 //{ // isXc = true; //} curUser.strEmpId = qlddr["EmpId"].ToString(); curUser.strEmpName = qlddr["EmpName"].ToString(); curUser.strEmpDept = qlddr["EmpDept"].ToString(); curUser.strEmpKilnNO = qlddr["EmpKilnNO"].ToString(); curUser.strEmpWorshoId = qlddr["EmpWorshoId"].ToString(); userName = qlddr["EmpName"].ToString(); BaseGroupMenuMethod bgM = new BaseGroupMenuMethod(); menuDict = bgM.getMenuDic(userGrpID); moduleDict = bgM.getmoduleDict(userGrpID); qlddr.Close(); conn.Close(); this.Hide(); frmMain fm = new frmMain(); fm.Show(); string ip = WindowsUtil.IP(); //LogHelper.WriteLog(userName+" "+userCode+" 于 "+ip+" 登录系统"); //Msg msg = new Msg(DateTime.Now, userName + " " + userCode + " 于 " + ip + " 登录系统", MsgType.Information); //Log log = new Log(); //log.Write(DateTime.Now, userName + " " + userCode + " 于 " + ip + " 登录系统", MsgType.Information); LogHelper.WriteLog(userName + " " + userCode + " 于 " + ip + " 登录系统"); } else { MessageBox.Show("用户名或密码错误,请重新输入!", "登录提示", MessageBoxButtons.OK, MessageBoxIcon.Information); tbpassword.Text = ""; //tbusername.Text = ""; tbpassword.Focus(); } conn.Close(); cmd.Dispose(); } } catch (Exception ee) { LogHelper.WriteLog("登录系统出现错误" + ee.ToString()); //MessageBox.Show("此用户已停用或密码错误,请重新输入!", "登录提示"); } }