/// <summary> /// 根据部门的ID得到部门的Name /// </summary> /// <param name="OrgID">部门ID</param> /// <returns>部门Name</returns> public static String GetOrgNameByID(String OrgID) { String result = String.Empty; if (String.IsNullOrEmpty(OrgID) == false) { List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("OrgID", OrgID)); JOrgDA da1 = new JOrgDA(); DataRow dr1 = da1.GetFirstDataRow(condition, "OrgName"); if (dr1 != null) { result = dr1[0].ToString(); } } return(result); }
/// <summary> /// 平台用户的登陆方法 /// </summary> /// <param name="userName">用户名</param> /// <param name="PassWord">登录密码</param> /// <param name="Userid">登录成功后,返回的用户ID</param> /// <returns> /// 0--表示用户名不存在 /// 1--表示密码不正确 /// 2--表示账号已停用 /// 3--表示登陆成功 /// </returns> public int Login(String userName, String PassWord, ref String Userid, ref String departNum) { int succ = 0; Userid = userName; departNum = String.Empty; if (String.IsNullOrEmpty(userName) == false && String.IsNullOrEmpty(PassWord) == false) { JUserDA da1 = new JUserDA(); List <SearchField> condition = new List <SearchField>(); SearchField search1 = new SearchField("UserID", userName); SearchField search2 = new SearchField("UserName", userName); condition.Add(search1 | search2); DataRow data1 = da1.GetFirstDataRow(condition, "*"); if (data1 != null) { String password1 = data1["Password"].ToString(); if (PassWord == password1 || JString.MD5(PassWord) == password1) { if (data1["status"].ToString() == "1") { //判断用户所在单位的情况 succ = 3; //修改用户登录时间和登录次数 condition.Clear(); condition.Add(search1 | search2); Dictionary <String, object> dic0 = new Dictionary <string, object>(); dic0["LastLogin"] = DateTime.Now; if (data1["LoginCount"].ToString() != String.Empty) { dic0["LoginCount"] = "$$LoginCount+1"; } else { dic0["LoginCount"] = 1; } da1.EditData(condition, dic0); //设置用户的权限角色(可能需要修改) FrameLib.AuthorityID = data1["AuthorityID"].ToString(); //用户的权限ID FrameLib.UserName = data1["UserName"].ToString(); //用户的UserName FrameLib.AuthorityGroup = data1["AuthorityGroup"].ToString(); //表示用户的类别 FrameLib.DepartID = data1["DepartID"].ToString(); //表示用户所属的部门ID //根据部门的ID设置部门的Num(数据权限用) condition.Clear(); JOrgDA org1 = new JOrgDA(); condition.Add(new SearchField("OrgID", data1["DepartID"].ToString())); DataRow r1 = org1.GetFirstDataRow(condition, "num"); if (r1 != null) { departNum = r1["num"].ToString(); } Userid = data1["userid"].ToString(); //创建用户登录日志 JUserLoginLogDA da2 = new JUserLoginLogDA(); Dictionary <String, object> logdata = new Dictionary <string, object>(); logdata["ID"] = WebFrame.Util.JString.GetUnique32ID(); logdata["UserID"] = data1["UserID"].ToString(); logdata["UserName"] = data1["UserName"].ToString(); logdata["CreateTime"] = DateTime.Now; logdata["AuthorityGroup"] = data1["AuthorityGroup"]; string ip = GetIPAddress(); logdata["Remark"] = ip; da2.NewData(logdata); } else { succ = 2; } } else { succ = 1; } } } return(succ); }