Example #1
0
File: admin.cs Project: uwitec/shop
        /// <summary>
        /// 添加新管理员
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static bool AddNewAdmin(admininfo data)
        {
            SqlParameter[] parms = new SqlParameter[5];
            parms[0] = new SqlParameter("@adminname", SqlDbType.VarChar, 20);
            parms[0].Value = data.adminname;
            parms[1] = new SqlParameter("@adminpwd", SqlDbType.VarChar, 50);
            parms[1].Value = data.adminpwd;
            parms[2] = new SqlParameter("@adddate", SqlDbType.DateTime);
            parms[2].Value = data.adddate;
            parms[3] = new SqlParameter("@updatedate", SqlDbType.DateTime);
            parms[3].Value = data.updatedate;
            parms[4] = new SqlParameter("@roleid",SqlDbType.Int);
            parms[4].Value = data.roleid;

            string sql = "INSERT INTO SysAdmin (adminname,adminpwd,adddate,updatedate,roleid) " +
                        "values (@adminname,@adminpwd,@adddate,@updatedate,@roleid)";

            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
            return result > 0;
        }
Example #2
0
File: admin.cs Project: uwitec/shop
        /// <summary>
        /// 修改登录密码
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static bool updatepwd(admininfo item)
        {
            SqlParameter[] parms = new SqlParameter[2];
            parms[0] = new SqlParameter("@npwd", SqlDbType.VarChar, 50);
            parms[0].Value = item.adminpwd;
            parms[1] = new SqlParameter("@AdminID",SqlDbType.Int);
            parms[1].Value = item.adminid;

            string sql = "UPDATE SysAdmin SET adminpwd=@npwd WHERE adminid=@adminid";
            int result = 0;
            try
            {
                result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms);
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
            return result > 0;
        }
Example #3
0
File: admin.cs Project: uwitec/shop
        public static List<admininfo> getAdminListPage(pageinfo item)
        {
            List<admininfo> adminlist = new List<admininfo>();

            try
            {
                DataTable dt = pagehelper.getpagedt(item);
                if (dt != null)
                {
                    foreach (DataRow reader in dt.Rows)
                    {
                        admininfo data = new admininfo();
                        data.adminid = TypeParse.DbObjToInt(reader["adminid"], 0);
                        data.adminname = TypeParse.DbObjToString(reader["adminname"], "");
                        data.adddate = TypeParse.DbObjToDateTime(reader["adddate"], DateTime.Now);
                        data.updatedate = TypeParse.DbObjToDateTime(reader["updatedate"], DateTime.Now);
                        adminlist.Add(data);
                    }
                }

                return adminlist;
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
        }
Example #4
0
File: admin.cs Project: uwitec/shop
        /// <summary>
        /// 得到管理员信息列表
        /// </summary>
        /// <param name="pdata"></param>
        /// <returns></returns>
        public static List<admininfo> getAdminList()
        {
            List<admininfo> adminlist = new List<admininfo>();
            string sql = "SELECT adminid,adminname,roleid,adddate,updatedate FROM SysAdmin";

            try
            {
                DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql).Tables[0];
                if (dt != null)
                {
                    foreach (DataRow reader in dt.Rows)
                    {
                        admininfo data = new admininfo();
                        data.adminid = TypeParse.DbObjToInt(reader["adminid"], 0);
                        data.adminname = TypeParse.DbObjToString(reader["adminname"], "");
                        data.adddate = TypeParse.DbObjToDateTime(reader["adddate"], DateTime.Now);
                        data.updatedate = TypeParse.DbObjToDateTime(reader["updatedate"], DateTime.Now);
                        adminlist.Add(data);
                    }
                }

                return adminlist;
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
        }
Example #5
0
File: admin.cs Project: uwitec/shop
        /// <summary>
        /// 读取系统管理员信息
        /// </summary>
        /// <param name="adminid"></param>
        /// <returns></returns>
        public static admininfo getAdminInfo(int adminid)
        {
            SqlParameter[] parms = new SqlParameter[1];
            parms[0] = new SqlParameter("@adminid", SqlDbType.Int);
            parms[0].Value = adminid;

            admininfo data = new admininfo();
            string sql = "SELECT adminid,adminname,roleid,adddate,updatedate FROM SysAdmin WHERE  adminid=@adminid";

            try
            {
                SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms);
                if (reader.Read())
                {
                    data.adminid = TypeParse.DbObjToInt(reader["adminid"], 0);
                    data.adminname = TypeParse.DbObjToString(reader["adminname"], "");
                    data.adddate = TypeParse.DbObjToDateTime(reader["adddate"], DateTime.Now);
                    data.updatedate = TypeParse.DbObjToDateTime(reader["updatedate"], DateTime.Now);
                    reader.Close();
                    reader.Dispose();
                }
                return data;
            }
            catch (Exception E)
            {
                throw new Exception(E.Message);
            }
            finally
            { }
        }