示例#1
0
        /// <summary>
        /// 向管理员表中写入该管理员的新密码
        /// </summary>
        /// <param name="username">管理员名</param>
        /// <param name="newpassword">新密码</param>
        public bool ChangePassword(string userId, string newpassword)
        {
            //直接写密码(管理员表)
            bool flag = false;

            using (var dbContext = new LSSDataContext())
            {
                Administor adminstor = new Administor();
                //修改数据库信息最好有一些事务操作
                using (var transaction = dbContext.Database.BeginTransaction())
                {
                    try
                    {
                        adminstor = dbContext.Administor.Where(x => x.Aid == userId).FirstOrDefault();
                        if (adminstor != null)
                        {
                            adminstor.Apassword = newpassword;
                            dbContext.Administor.Update(adminstor);
                            dbContext.SaveChanges();
                            transaction.Commit();
                            flag = true;
                        }
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        return(false);
                    }
                }
                return(flag);
            }
        }
示例#2
0
    private void Start()
    {
        _administor = new Administor();

        var mgr = new TreeNodeDataContainerMgr();

        DirectorySearcher.Serach(string.Format("{0}/Contents", Application.dataPath), ref mgr);
        Mgr <TreeViewMgr>().TreeView.BuildTree(mgr.RootContainer);
        Mgr <TreeViewMgr>().TreeView.ReFreshTree();
    }
示例#3
0
 /// <summary>
 ///
 /// 查询密码
 /// </summary>
 /// <param name="user">工号</param>
 /// <returns>密文密码</returns>
 public string GetPassword(string user)
 {
     using (var context = new LSSDataContext())
     {
         string     str        = null;
         Administor administor = new Administor();
         administor = context.Administor.FirstOrDefault(b => b.Aid == user);
         if (administor != null)
         {
             str = administor.Apassword;
         }
         return(str);
     }
 }