//登陆 public ActionResult LoginBtn() { //TODO:corporation string result = "fail"; string msg = string.Empty; string company = Request["company"]; string userName = Request["userName"]; string userPwd = Request["pwd"]; //string userRole = Request["role"]; //string result = ""; if (!Net.CheckConn()) { return(Json(new { result = result, msg = "无法连接到服务器!请检查网络情况。" })); } try { if (userName == null || userPwd == null) { result = "fail"; msg = "用户名或密码不能为空"; //return Content("Null"); } else { //TODO:1.4 //得到公司 string pwd = Md5.MD5(userPwd); //角色Stuff_LoginType and Stuff_LoginType='" + userRole + "' //HR_Stuff = instanceHR_Stuff.GetModel(string.Format(" and Stuff_UserName='******' and Stuff_Password='******'",userName,pwd)); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Stuff_UserName", userName); dic.Add("Stuff_Password", pwd); HR_Stuff = instanceHR_Stuff.GetModel(string.Format("AND Stuff_UserName=@Stuff_UserName AND Stuff_Password=@Stuff_Password"), dic); if (HR_Stuff == null) { result = "fail"; msg = "用户名或密码不正确 "; } else { //用户名 this.SetSession <string>("UserName", HR_Stuff.Stuff_Name); //员工编码 this.SetSession <string>("UserId", HR_Stuff.Stuff_Code); //员工登录名 this.SetSession <string>("LoginName", HR_Stuff.Stuff_UserName); //登录IP this.SetSession <string>("IP", HttpContext.Request.UserHostAddress); //部门信息 HR_Department = instanceHR_Department.GetModel(" and Dept_Code='" + HR_Stuff.Stuff_DepCode + "'"); if (HR_Department != null) { //部门id this.SetSession <string>("DeptId", HR_Department.Dept_Code.ToString()); //部门名称 this.SetSession <string>("DeptName", HR_Department.Dept_Name); //用户角色 this.SetSession <string>("UserRole", HR_Stuff.Stuff_LoginType); //DODO:hao HR_Department fagTemp = instanceHR_Department.GetModel(" and Dept_Code='" + HR_Department.Dept_PCode.ToString() + "'"); while (!string.IsNullOrEmpty(fagTemp.Dept_PCode)) { fagTemp = instanceHR_Department.GetModel(" and Dept_Code='" + fagTemp.Dept_PCode + "'"); } string companyUser = fagTemp.Dept_Name.ToString(); //公司编码 string companyCode = fagTemp.Dept_Code.ToString(); //this.SetSession<string>("Company", company); this.SetSession <string>("CompanyCode", companyCode); //部门编码 this.SetSession <string>("DeptCode", HR_Department.Dept_Code); //TODO:得到公司问题 //companyCode=new BLL.Bll_HR_Department().GetCompanyName("" + HR_Department.Dept_Code + ""); this.SetSession <string>("Company", companyUser); result = "success"; msg = ""; } else { result = "fail"; msg = "用户信息配置错误"; } } } } catch (System.Exception ex) { result = "fail"; msg = "网络连接不通,请重试"; //CommLog.Error(ex.Message); //PlateLog.Write("连接异常:", PlateLog.LogMessageType.Error,ex); } //写入登录日志 //Bll_Comm.LoginLog(userName,msg); return(Json(new { result = result, msg = msg })); }
//登陆 public ActionResult LoginBtn() { //TODO:corporation string result = "fail"; string msg = string.Empty; string company = Request["company"]; string userName = Request["userName"]; string userPwd = Request["pwd"]; //string userRole = Request["role"]; //string result = ""; if (!Net.CheckConn()) { return(Json(new { result = result, msg = "无法连接到服务器!请检查网络情况。" })); } try { if (userName == null || userPwd == null) { result = "fail"; msg = "用户名或密码不能为空"; //return Content("Null"); } else { Session.RemoveAll(); Session.Clear(); //TODO:1.4 //得到公司 // string pwd = Md5.MD5(userPwd.Replace('\'', '"')); string pwd = userPwd; //角色Stuff_LoginType and Stuff_LoginType='" + userRole + "' HR_Stuff = instanceHR_Stuff.GetModel(" and Emp_LoginID='" + userName.Replace('\'', '"') + "' and Emp_LoginPwd='" + pwd + "'"); if (HR_Stuff == null) { result = "fail"; msg = "用户名或密码不正确 "; } else { //用户名 this.SetSession <string>("UserName", HR_Stuff.Emp_Name); //员工编码 this.SetSession <string>("UserId", HR_Stuff.Emp_Code); //员工登录名 this.SetSession <string>("LoginName", HR_Stuff.Emp_LoginID); //登录IP this.SetSession <string>("IP", HttpContext.Request.UserHostAddress); //部门信息 Bse_Department = instanceDepartment.GetModel(" and Dept_Code='" + HR_Stuff.Emp_Dept_Code + "'"); if (Bse_Department != null) { //部门id this.SetSession <string>("DeptId", Bse_Department.Dept_Code.ToString()); //部门名称 this.SetSession <string>("DeptName", Bse_Department.Dept_Name); //用户角色//hack this.SetSession <string>("UserRole", ""); //DODO:hao //Bse_Department fagTemp = instanceBse_Department.GetModel(" and Dept_Code='" + Bse_Department.Dept_PCode.ToString() + "'"); //while (!string.IsNullOrEmpty(fagTemp.Dept_PCode)) //{ // fagTemp = instanceBse_Department.GetModel(" and Dept_Code='" + fagTemp.Dept_PCode + "'"); //} //string companyUser = fagTemp.Dept_Name.ToString(); ////公司编码 //string companyCode = fagTemp.Dept_Code.ToString(); ////this.SetSession<string>("Company", company); //this.SetSession<string>("CompanyCode", companyCode); //部门编码 // this.SetSession<string>("DeptCode", Bse_Department.Dept_Code); //TODO:得到公司问题 //companyCode=new BLL.Bll_Bse_Department().GetCompanyName("" + Bse_Department.Dept_Code + ""); //this.SetSession<string>("Company", companyUser); result = "success"; msg = ""; } else { result = "fail"; msg = "用户信息配置错误"; } } } } catch (System.Exception ex) { result = "fail"; // msg = "网络连接不通,请重试"; msg = ex.Message; // PlateLog.Write("连接异常:", PlateLog.LogMessageType.Error,ex); } //QX.Log.PlateLog.WriteOp //写入登录日志 Bll_Comm.LoginLog(userName, msg); return(Json(new { result = result, msg = msg })); }