예제 #1
0
        //模糊查询
        public static List <ModelSproduct> sproducts(string Sproductname = "", string Sproductcontent = "")
        {
            SqlParameter[] sqlp = new SqlParameter[] {
                new SqlParameter("@Sproductname", Sproductname),
                new SqlParameter("@Sproductcontent", Sproductcontent)
            };
            SqlDataReader reader = DBhelp.slelectProc("Sproduct_sel", sqlp);
            //判断有没有读到数据,hasRows有没有行数据
            List <ModelSproduct> sproducts = new List <ModelSproduct>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    //读取第一条数据
                    ModelSproduct model = new ModelSproduct();
                    model.Sproductid      = int.Parse(reader["Sproductid"].ToString());
                    model.Sproductname    = reader["Sproductname"].ToString();
                    model.Sproductcontent = reader["Sproductcontent"].ToString();
                    model.Sproductprice   = double.Parse(reader["Sproductprice"].ToString());
                    model.Sproductimg     = reader["Sproductimg"].ToString();
                    sproducts.Add(model);
                }
            }
            return(sproducts);
        }
예제 #2
0
        /// <summary>
        /// 根据用户名字、等级、级别进行查询
        /// </summary>
        /// <param name="Username"></param>
        /// <param name="Usergrade"></param>
        /// <param name="UsersState"></param>
        /// <returns></returns>
        public static List <ModelUsers> UsersList(string Username = "", int Usergrade = 0, int UsersState = -1)
        {
            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@Username", Username),
                new SqlParameter("@Usergrade", Usergrade),
                new SqlParameter("@UsersState", UsersState),
            };
            SqlDataReader     sdr  = DBhelp.slelectProc("UsersList", sqlpar);
            List <ModelUsers> list = new List <ModelUsers>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelUsers model = new ModelUsers();
                    model.Userid       = Convert.ToInt32(sdr["Userid"]);
                    model.Userbalance  = Convert.ToDouble(sdr["Userbalance"]);
                    model.ClassTypes   = Convert.ToString(sdr["ClassTypes"]);
                    model.Username     = Convert.ToString(sdr["Username"]);
                    model.Userpassword = Convert.ToString(sdr["Userpassword"]);
                    model.usersState   = Convert.ToInt32(sdr["UsersState"]);
                    list.Add(model);
                }
            }
            return(list);
        }
예제 #3
0
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public static List <ModelUsers> UserspagingGet(int pageIndex, int pageSize, out int totalCount)
        {
            //初始化输出参数
            totalCount = 0;
            SqlParameter[] sqlParameters = new SqlParameter[] {
                new SqlParameter("@pageindex", pageIndex),
                new SqlParameter("@pagesize", pageSize),
                new SqlParameter("@docount", totalCount)
            };
            //sqlParameters[2].Direction = ParameterDirection.Output;
            SqlDataReader     sdr  = DBhelp.slelectProc("Userspaging", sqlParameters);
            List <ModelUsers> list = new List <ModelUsers>();

            //判断有没有数据
            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelUsers model = new ModelUsers();
                    model.Userid       = Convert.ToInt32(sdr["Userid"]);
                    model.Userbalance  = Convert.ToDouble(sdr["Userbalance"]);
                    model.ClassTypes   = Convert.ToString(sdr["ClassTypes"]);
                    model.Username     = Convert.ToString(sdr["Username"]);
                    model.Userpassword = Convert.ToString(sdr["Userpassword"]);
                    model.usersState   = Convert.ToInt32(sdr["UsersState"]);
                    list.Add(model);
                }
            }
            //totalCount = Convert.ToInt32(sqlParameters[2].Value);
            //返回结果list
            return(list);
        }
예제 #4
0
        /// <summary>
        /// 查询申请表
        /// </summary>
        /// <returns></returns>
        public static List <ModelApprove> ApproveList(int state = 0)
        {
            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@ApproveState", state)
            };
            SqlDataReader       sdr  = DBhelp.slelectProc("ApproveList", sqlpar);
            List <ModelApprove> list = new List <ModelApprove>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelApprove model = new ModelApprove()
                    {
                        ApproveContent = sdr["ApproveContent"].ToString(),
                        ApproveID      = Convert.ToInt32(sdr["ApproveID"]),
                        ClassTypes     = sdr["ClassTypes"].ToString(),
                        ApproveLevel   = Convert.ToInt32(sdr["ApproveLevel"]),
                        ApproveTime    = Convert.ToDateTime(sdr["ApproveTime"]),
                        Username       = sdr["Username"].ToString(),
                        Userid         = Convert.ToInt32(sdr["Userid"]),
                    };

                    list.Add(model);
                }
            }
            return(list);
        }
예제 #5
0
        /// <summary>
        /// 查询公告
        /// </summary>
        /// <returns></returns>
        public static List <ModelNotice> NoticeList(int NoticeState = 0)
        {
            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@NoticeState", NoticeState)
            };
            SqlDataReader      sdr  = DBhelp.slelectProc("NoticeList", sqlpar);
            List <ModelNotice> list = new List <ModelNotice>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelNotice model = new ModelNotice();
                    model.NoticeContent = sdr["NoticeContent"].ToString();
                    model.NoticeID      = Convert.ToInt32(sdr["NoticeID"]);
                    model.NoticeTime    = Convert.ToDateTime(sdr["NoticeTime"]).ToString("yyyy-MM-dd");
                    model.NoticeTitle   = sdr["NoticeTitle"].ToString();
                    model.gradeid       = Convert.ToInt32(sdr["gradeid"]);
                    model.NoticeState   = Convert.ToInt32(sdr["NoticeState"]);
                    list.Add(model);
                }
            }
            return(list);
        }
예제 #6
0
        /// <summary>
        /// 查询等级类别
        /// </summary>
        /// <returns></returns>
        public static List <ModelGrade> gradeList()
        {
            SqlDataReader     sdr  = DBhelp.slelectProc("gradeList");
            List <ModelGrade> list = new List <ModelGrade>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelGrade model = new ModelGrade();
                    model.gradeId    = Convert.ToInt32(sdr["gradeId"]);
                    model.ClassTypes = Convert.ToString(sdr["ClassTypes"]);
                    list.Add(model);
                }
            }
            return(list);
        }
예제 #7
0
        /// <summary>
        /// 查询销量(计数)
        /// </summary>
        /// <returns></returns>
        public static List <ModelSproductCount> SproductTOP()
        {
            SqlDataReader             sdr  = DBhelp.slelectProc("ListTop");
            List <ModelSproductCount> list = new List <ModelSproductCount>();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    ModelSproductCount model = new ModelSproductCount();
                    model.value = sdr["value"].ToString();
                    model.name  = sdr["Sproductname"].ToString();
                    list.Add(model);
                }
            }
            return(list);
        }
예제 #8
0
        /// <summary>
        /// 根据ID查询表信息
        /// </summary>
        /// <param name="Userid"></param>
        /// <returns></returns>
        public static ModelUsers  UsersloginID(int Userid)
        {
            SqlParameter[] sqlpar = new SqlParameter[]
            {
                new SqlParameter("@Userid", Userid),
            };
            SqlDataReader sdr   = DBhelp.slelectProc("UsersloginID", sqlpar);
            ModelUsers    model = new ModelUsers();

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    model.Userid          = Convert.ToInt32(sdr["Userid"]);
                    model.Userbalance     = Convert.ToDouble(sdr["Userbalance"]);
                    model.Usergrade       = Convert.ToInt32(sdr["Usergrade"]);
                    model.Username        = Convert.ToString(sdr["Username"]);
                    model.Userpassword    = Convert.ToString(sdr["Userpassword"]);
                    model.UsersStateSting = Convert.ToString(sdr["UsersState"]);
                }
            }
            return(model);
        }