Esempio n. 1
0
        //插入管理员数据
        public void insertAdminInfo(AdminInfo admin)
        {
            string        sql     = "insert into admins values('" + admin.getname() + "','" + admin.getpw() + "')";
            SQLiteCommand command = new SQLiteCommand(sql, dbConnection);

            command.ExecuteNonQuery();
        }
Esempio n. 2
0
        //按照id查找管理员信息
        public List <AdminInfo> queryAdmins(AdminInfo.type type, string param)
        {
            string sql = "";

            //根据不同的类型编辑sql语句
            switch (type)
            {
            case AdminInfo.type.name:
                sql = "select * from admins where name='" + param + "'";
                break;

            case AdminInfo.type.pw:
                sql = "select * from admins where pw='" + param + "'";
                break;
            }
            SQLiteCommand    command = new SQLiteCommand(sql, dbConnection);
            SQLiteDataReader reader  = command.ExecuteReader();
            //装载加结果的List
            List <AdminInfo> admins = new List <AdminInfo>();

            //读取所有结果
            while (reader.Read())
            {
                AdminInfo admin = new AdminInfo(reader["name"].ToString(), reader["pw"].ToString(), false);
                admins.Add(admin);
            }
            return(admins);
        }
Esempio n. 3
0
        //更新管理员密码(传过来的新密码为密文)
        public void updateAdminPw(string name, string newPw)
        {
            AdminInfo     admin   = new AdminInfo(name, newPw, false);
            string        sql     = "update admins set pw='" + admin.getpw() + "' where name='" + admin.getname() + "'";
            SQLiteCommand command = new SQLiteCommand(sql, dbConnection);

            command.ExecuteNonQuery();
        }
Esempio n. 4
0
        //查询所有管理员数据
        public List <AdminInfo> queryAllAdmin()
        {
            List <AdminInfo> admins  = new List <AdminInfo>();
            string           sql     = "select * from admins order by name";
            SQLiteCommand    command = new SQLiteCommand(sql, dbConnection);
            SQLiteDataReader reader  = command.ExecuteReader();

            while (reader.Read())
            {
                AdminInfo admin = new AdminInfo(reader["name"].ToString(), reader["pw"].ToString(), false);
                admins.Add(admin);
            }
            return(admins);
        }
Esempio n. 5
0
        //插入管理员信息
        private void insertAdmin(string msg)
        {
            string[]  args  = msg.Split('#');
            AdminInfo admin = new AdminInfo(resumeSpecStr(args[0]), resumeSpecStr(args[1]), false);

            //如果管理员已存在则返回已存在消息
            if (mDataManager.isAdminNameExists(resumeSpecStr(args[0])))
            {
                mSocket.Send(Encoding.UTF8.GetBytes(MyProtocol.head_insertAdmin + MyProtocol.body_exists));
                Console.WriteLine("insert denied(exist):" + admin.getname());
                return;
            }
            //插入
            mDataManager.insertAdminInfo(admin);
            //发送成功消息
            mSocket.Send(Encoding.UTF8.GetBytes(MyProtocol.head_insertAdmin + MyProtocol.body_success));
            Console.WriteLine("insert an administrator:" + admin.getname());
        }