Пример #1
0
        public static List <FavoriteModel> GetListByUid(int uid, int pageSize, int pageIndex, out int totalcount)
        {
            int    start = (pageIndex - 1) * pageSize;
            string sql   = string.Format("select * from odnshop_favorite where uid={0} order by fid desc limit {1},{2}", uid.ToString(), start, pageSize);

            List <FavoriteModel> list = new List <FavoriteModel>();

            DataTable     dt   = MySqlDbHelper.Query(sql).Tables[0];
            FavoriteModel info = null;

            foreach (DataRow dr in dt.Rows)
            {
                info            = new FavoriteModel();
                info.product    = (ProductModel)SerializeHelper.LoadFromXml(new ProductModel().GetType(), dr["productxml"].ToString());
                info.fid        = Int32.Parse(dr["fid"].ToString());
                info.uid        = Int32.Parse(dr["uid"].ToString());
                info.productid  = Int32.Parse(dr["productid"].ToString());
                info.createtime = DateTime.Parse(dr["createtime"].ToString());

                list.Add(info);
            }

            totalcount = MySqlDbHelper.ExecuteScalar("select count(*) from odnshop_favorite where uid=" + uid);

            return(list);
        }
Пример #2
0
        public static bool IsFavorite(int uid, int productid)
        {
            int favcount = MySqlDbHelper.ExecuteScalar(string.Format("select count(*) from odnshop_favorite where uid={0} and productid={1}", uid, productid));

            if (favcount > 0)
            {
                return(true);
            }

            return(false);
        }
Пример #3
0
        public static DataTable GetList(int pageSize, int pageIndex, string whereSql, string orderBy, out int totalcount)
        {
            int start = (pageIndex - 1) * pageSize;

            string sql = string.Format("select * from odnshop_user {0}{1} limit {2},{3}", whereSql, orderBy, start, pageSize);

            DataTable dt = MySqlDbHelper.Query(sql).Tables[0];

            totalcount = MySqlDbHelper.ExecuteScalar(string.Format("select count(*) from odnshop_user {0}", whereSql));

            return(dt);
        }
Пример #4
0
        public static List <ProductModel> GetList(int pageSize, int pageIndex, string whereSql, string orderBy, out int totalcount)
        {
            int start = (pageIndex - 1) * pageSize;

            string sql = string.Format("select * from odnshop_product {0}{1} limit {2},{3}", whereSql, orderBy, start, pageSize);

            DataTable dt = MySqlDbHelper.Query(sql).Tables[0];

            totalcount = MySqlDbHelper.ExecuteScalar(string.Format("select count(*) from odnshop_product {0}", whereSql));


            List <ProductModel> list = new List <ProductModel>();
            ProductModel        info = null;

            foreach (DataRow dr in dt.Rows)
            {
                info = PopulateModel(dr, new ProductModel());

                list.Add(info);
            }

            return(list);
        }
Пример #5
0
        public static List <OrderModel> GetOrderList(int pageSize, int pageIndex, string whereSql, string orderBy, out int totalcount)
        {
            int start = (pageIndex - 1) * pageSize;

            string sql = string.Format("select * from odnshop_order {0}{1} limit {2},{3}", whereSql, orderBy, start, pageSize);

            DataTable dt = MySqlDbHelper.Query(sql).Tables[0];

            totalcount = MySqlDbHelper.ExecuteScalar(string.Format("select count(*) from odnshop_order {0}", whereSql));

            List <OrderModel> list = new List <OrderModel>();
            OrderModel        info = null;

            foreach (DataRow dr in dt.Rows)
            {
                info               = (OrderModel)SerializeHelper.LoadFromXml(new OrderModel().GetType(), dr["orderxml"].ToString());
                info.orderid       = Int32.Parse(dr["orderid"].ToString());
                info.orderstatus   = Int32.Parse(dr["orderstatus"].ToString());
                info.deliverstatus = Int32.Parse(dr["deliverstatus"].ToString());
                list.Add(info);
            }

            return(list);
        }
Пример #6
0
        public static int GetTotalCount()
        {
            int totalcount = MySqlDbHelper.ExecuteScalar("select count(*) from odnshop_user ");

            return(totalcount);
        }