Exemplo n.º 1
0
 public Maticsoft.Model.Members.Users GetUserIdByDepartmentID(string DepartmentID)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select UserID FROM Accounts_Users ");
     builder.Append(" where DepartmentID=@DepartmentID");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@DepartmentID", SqlDbType.NVarChar, 15) };
     cmdParms[0].Value = DepartmentID;
     Maticsoft.Model.Members.Users users = new Maticsoft.Model.Members.Users();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["UserID"] != null) && (set.Tables[0].Rows[0]["UserID"].ToString() != ""))
     {
         users.UserID = int.Parse(set.Tables[0].Rows[0]["UserID"].ToString());
     }
     return users;
 }
Exemplo n.º 2
0
 public List<Maticsoft.Model.Members.Users> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Members.Users> list = new List<Maticsoft.Model.Members.Users>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Members.Users item = new Maticsoft.Model.Members.Users();
             if ((dt.Rows[i]["UserID"] != null) && (dt.Rows[i]["UserID"].ToString() != ""))
             {
                 item.UserID = int.Parse(dt.Rows[i]["UserID"].ToString());
             }
             if ((dt.Rows[i]["UserName"] != null) && (dt.Rows[i]["UserName"].ToString() != ""))
             {
                 item.UserName = dt.Rows[i]["UserName"].ToString();
             }
             if ((dt.Rows[i]["Password"] != null) && (dt.Rows[i]["Password"].ToString() != ""))
             {
                 item.Password = (byte[]) dt.Rows[i]["Password"];
             }
             if ((dt.Rows[i]["TrueName"] != null) && (dt.Rows[i]["TrueName"].ToString() != ""))
             {
                 item.TrueName = dt.Rows[i]["TrueName"].ToString();
             }
             if ((dt.Rows[i]["Sex"] != null) && (dt.Rows[i]["Sex"].ToString() != ""))
             {
                 item.Sex = dt.Rows[i]["Sex"].ToString();
             }
             if ((dt.Rows[i]["Phone"] != null) && (dt.Rows[i]["Phone"].ToString() != ""))
             {
                 item.Phone = dt.Rows[i]["Phone"].ToString();
             }
             if ((dt.Rows[i]["Email"] != null) && (dt.Rows[i]["Email"].ToString() != ""))
             {
                 item.Email = dt.Rows[i]["Email"].ToString();
             }
             if ((dt.Rows[i]["EmployeeID"] != null) && (dt.Rows[i]["EmployeeID"].ToString() != ""))
             {
                 item.EmployeeID = new int?(int.Parse(dt.Rows[i]["EmployeeID"].ToString()));
             }
             if ((dt.Rows[i]["DepartmentID"] != null) && (dt.Rows[i]["DepartmentID"].ToString() != ""))
             {
                 item.DepartmentID = dt.Rows[i]["DepartmentID"].ToString();
             }
             if ((dt.Rows[i]["Activity"] != null) && (dt.Rows[i]["Activity"].ToString() != ""))
             {
                 if ((dt.Rows[i]["Activity"].ToString() == "1") || (dt.Rows[i]["Activity"].ToString().ToLower() == "true"))
                 {
                     item.Activity = true;
                 }
                 else
                 {
                     item.Activity = false;
                 }
             }
             if ((dt.Rows[i]["UserType"] != null) && (dt.Rows[i]["UserType"].ToString() != ""))
             {
                 item.UserType = dt.Rows[i]["UserType"].ToString();
             }
             if ((dt.Rows[i]["Style"] != null) && (dt.Rows[i]["Style"].ToString() != ""))
             {
                 item.Style = new int?(int.Parse(dt.Rows[i]["Style"].ToString()));
             }
             if ((dt.Rows[i]["User_iCreator"] != null) && (dt.Rows[i]["User_iCreator"].ToString() != ""))
             {
                 item.User_iCreator = new int?(int.Parse(dt.Rows[i]["User_iCreator"].ToString()));
             }
             if ((dt.Rows[i]["User_dateCreate"] != null) && (dt.Rows[i]["User_dateCreate"].ToString() != ""))
             {
                 item.User_dateCreate = new DateTime?(DateTime.Parse(dt.Rows[i]["User_dateCreate"].ToString()));
             }
             if ((dt.Rows[i]["User_dateValid"] != null) && (dt.Rows[i]["User_dateValid"].ToString() != ""))
             {
                 item.User_dateValid = new DateTime?(DateTime.Parse(dt.Rows[i]["User_dateValid"].ToString()));
             }
             if ((dt.Rows[i]["User_dateExpire"] != null) && (dt.Rows[i]["User_dateExpire"].ToString() != ""))
             {
                 item.User_dateExpire = new DateTime?(DateTime.Parse(dt.Rows[i]["User_dateExpire"].ToString()));
             }
             if ((dt.Rows[i]["User_iApprover"] != null) && (dt.Rows[i]["User_iApprover"].ToString() != ""))
             {
                 item.User_iApprover = new int?(int.Parse(dt.Rows[i]["User_iApprover"].ToString()));
             }
             if ((dt.Rows[i]["User_dateApprove"] != null) && (dt.Rows[i]["User_dateApprove"].ToString() != ""))
             {
                 item.User_dateApprove = new DateTime?(DateTime.Parse(dt.Rows[i]["User_dateApprove"].ToString()));
             }
             if ((dt.Rows[i]["User_iApproveState"] != null) && (dt.Rows[i]["User_iApproveState"].ToString() != ""))
             {
                 item.User_iApproveState = new int?(int.Parse(dt.Rows[i]["User_iApproveState"].ToString()));
             }
             if ((dt.Rows[i]["User_cLang"] != null) && (dt.Rows[i]["User_cLang"].ToString() != ""))
             {
                 item.User_cLang = dt.Rows[i]["User_cLang"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }
Exemplo n.º 3
0
 public Maticsoft.Model.Members.Users GetModel(int UserID)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 UserID,UserName,NickName,Password,TrueName,Sex,Phone,Email,EmployeeID,DepartmentID,Activity,UserType,Style,User_iCreator,User_dateCreate,User_dateValid,User_dateExpire,User_iApprover,User_dateApprove,User_iApproveState,User_cLang from Accounts_Users ");
     builder.Append(" where UserID=@UserID");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@UserID", SqlDbType.Int, 4) };
     cmdParms[0].Value = UserID;
     Maticsoft.Model.Members.Users users = new Maticsoft.Model.Members.Users();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["UserID"] != null) && (set.Tables[0].Rows[0]["UserID"].ToString() != ""))
     {
         users.UserID = int.Parse(set.Tables[0].Rows[0]["UserID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["UserName"] != null) && (set.Tables[0].Rows[0]["UserName"].ToString() != ""))
     {
         users.UserName = set.Tables[0].Rows[0]["UserName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Password"] != null) && (set.Tables[0].Rows[0]["Password"].ToString() != ""))
     {
         users.Password = (byte[]) set.Tables[0].Rows[0]["Password"];
     }
     if ((set.Tables[0].Rows[0]["TrueName"] != null) && (set.Tables[0].Rows[0]["TrueName"].ToString() != ""))
     {
         users.TrueName = set.Tables[0].Rows[0]["TrueName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["NickName"] != null) && (set.Tables[0].Rows[0]["NickName"].ToString() != ""))
     {
         users.NickName = set.Tables[0].Rows[0]["NickName"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Sex"] != null) && (set.Tables[0].Rows[0]["Sex"].ToString() != ""))
     {
         users.Sex = set.Tables[0].Rows[0]["Sex"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Phone"] != null) && (set.Tables[0].Rows[0]["Phone"].ToString() != ""))
     {
         users.Phone = set.Tables[0].Rows[0]["Phone"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Email"] != null) && (set.Tables[0].Rows[0]["Email"].ToString() != ""))
     {
         users.Email = set.Tables[0].Rows[0]["Email"].ToString();
     }
     if ((set.Tables[0].Rows[0]["EmployeeID"] != null) && (set.Tables[0].Rows[0]["EmployeeID"].ToString() != ""))
     {
         users.EmployeeID = new int?(int.Parse(set.Tables[0].Rows[0]["EmployeeID"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["DepartmentID"] != null) && (set.Tables[0].Rows[0]["DepartmentID"].ToString() != ""))
     {
         users.DepartmentID = set.Tables[0].Rows[0]["DepartmentID"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Activity"] != null) && (set.Tables[0].Rows[0]["Activity"].ToString() != ""))
     {
         if ((set.Tables[0].Rows[0]["Activity"].ToString() == "1") || (set.Tables[0].Rows[0]["Activity"].ToString().ToLower() == "true"))
         {
             users.Activity = true;
         }
         else
         {
             users.Activity = false;
         }
     }
     if ((set.Tables[0].Rows[0]["UserType"] != null) && (set.Tables[0].Rows[0]["UserType"].ToString() != ""))
     {
         users.UserType = set.Tables[0].Rows[0]["UserType"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Style"] != null) && (set.Tables[0].Rows[0]["Style"].ToString() != ""))
     {
         users.Style = new int?(int.Parse(set.Tables[0].Rows[0]["Style"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_iCreator"] != null) && (set.Tables[0].Rows[0]["User_iCreator"].ToString() != ""))
     {
         users.User_iCreator = new int?(int.Parse(set.Tables[0].Rows[0]["User_iCreator"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_dateCreate"] != null) && (set.Tables[0].Rows[0]["User_dateCreate"].ToString() != ""))
     {
         users.User_dateCreate = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["User_dateCreate"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_dateValid"] != null) && (set.Tables[0].Rows[0]["User_dateValid"].ToString() != ""))
     {
         users.User_dateValid = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["User_dateValid"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_dateExpire"] != null) && (set.Tables[0].Rows[0]["User_dateExpire"].ToString() != ""))
     {
         users.User_dateExpire = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["User_dateExpire"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_iApprover"] != null) && (set.Tables[0].Rows[0]["User_iApprover"].ToString() != ""))
     {
         users.User_iApprover = new int?(int.Parse(set.Tables[0].Rows[0]["User_iApprover"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_dateApprove"] != null) && (set.Tables[0].Rows[0]["User_dateApprove"].ToString() != ""))
     {
         users.User_dateApprove = new DateTime?(DateTime.Parse(set.Tables[0].Rows[0]["User_dateApprove"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_iApproveState"] != null) && (set.Tables[0].Rows[0]["User_iApproveState"].ToString() != ""))
     {
         users.User_iApproveState = new int?(int.Parse(set.Tables[0].Rows[0]["User_iApproveState"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["User_cLang"] != null) && (set.Tables[0].Rows[0]["User_cLang"].ToString() != ""))
     {
         users.User_cLang = set.Tables[0].Rows[0]["User_cLang"].ToString();
     }
     return users;
 }
Exemplo n.º 4
0
 private bool CreateUser(out string errorMsg)
 {
     try
     {
         Maticsoft.Model.Members.Users users;
         errorMsg = "";
         users = new Maticsoft.Model.Members.Users {
             Activity = true,
             DepartmentID = "",
             EmployeeID = -1,
             Email = this.txtEmail.Text.Trim(),
             UserName = users.NickName = this.txtUserName.Text.Trim(),
             Password = AccountsPrincipal.EncryptPassword(this.txtPassword.Text),
             UserType = "AA",
             Style = 1,
             User_dateCreate = new DateTime?(DateTime.Now)
         };
         if (!this.AddUser(users))
         {
             errorMsg = "创建管理员帐号失败";
             return false;
         }
         UsersExp model = new UsersExp {
             UserID = 1,
             BirthdayVisible = 0,
             BirthdayIndexVisible = false,
             Gravatar = "/Upload/User/Gravatar/1",
             ConstellationVisible = 0,
             ConstellationIndexVisible = false,
             NativePlaceVisible = 0,
             NativePlaceIndexVisible = false,
             RegionId = 0,
             AddressVisible = 0,
             AddressIndexVisible = false,
             BodilyFormVisible = 0,
             BodilyFormIndexVisible = false,
             BloodTypeVisible = 0,
             BloodTypeIndexVisible = false,
             MarriagedVisible = 0,
             MarriagedIndexVisible = false,
             PersonalStatusVisible = 0,
             PersonalStatusIndexVisible = false,
             LastAccessIP = "",
             LastAccessTime = new DateTime?(DateTime.Now),
             LastLoginTime = DateTime.Now,
             LastPostTime = new DateTime?(DateTime.Now)
         };
         if (!this.AddUserExp(model))
         {
             errorMsg = "创建管理员帐号扩展数据添加失败";
             return false;
         }
         if (!this.AddUserRoles(1, 1))
         {
             errorMsg = "创建管理员角色数据失败";
             return false;
         }
         return true;
     }
     catch (Exception exception)
     {
         errorMsg = exception.Message;
         return false;
     }
 }