{/// <summary> /// 查询买家评论表 /// </summary> /// <returns></returns> public static List <ModelComment> select() { string sql = "select * from Comment"; SqlDataReader sdr = DBhelp.slelect(sql); List <ModelComment> list = new List <ModelComment>(); if (sdr.HasRows) { while (sdr.Read()) { ModelComment model = new ModelComment(); model.commentid = Convert.ToInt32(sdr["commentid"]); model.commentcontent = sdr["commentcontent"].ToString(); model.commenttime = sdr["commenttime"].ToString();/*Convert.ToDateTime(sdr[""]).ToString("yyyy-MM-dd");*/ model.Sproductid = Convert.ToInt32(sdr["Sproductid"]); list.Add(model); } } return(list); }
/// <summary> /// 查询所有数据 /// </summary> /// <returns></returns> public static List <loginModel> select(string name, string id) { //创建连接字符串 string sql = "select * from cc,leixing where cc.id=leixing.ccid and zt=0 "; List <SqlParameter> sqlpar = new List <SqlParameter>() { }; if (string.IsNullOrEmpty(name)) { sql += " and cc.name=@name"; sqlpar.Add(new SqlParameter("@name", name)); } if (string.IsNullOrEmpty(name)) { sql += " and leixing.name=@id"; sqlpar.Add(new SqlParameter("@id", id)); } //方法调用 SqlDataReader sdr = DBhelp.slelect(sql, sqlpar.ToArray()); //创建list方便存储数据 List <loginModel> list = new List <loginModel>(); //判断sqldatareader是否存在数据 if (sdr.HasRows) { ///遍历下一条 while (sdr.Read()) { loginModel model = new loginModel(); //循环存储进入model model.id = Convert.ToInt32(sdr["id"]); model.name = sdr["name"].ToString(); model.pwd = sdr["pow"].ToString(); //将每一个model添加到集合里 list.Add(model); } } //返回list集合 return(list); }
//查询整表 public static List <ModelSproduct> SproductList() { string sql = "select * from Sproduct"; SqlDataReader reader = DBhelp.slelect(sql); //判断有没有读到数据,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); }
/// <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); }
/// <summary> /// 查询供应商商品表 /// </summary> /// <returns></returns> public static List <ModelProviderProduct> select() { string sql = "select * from ProviderProduct "; //此处是多条件查询(根据商品名来进行模糊查询) //string sql = "select * from ProviderProduct where Providername like''%'+@Providername+'%'''"; SqlDataReader sdr = DBhelp.slelect(sql); List <ModelProviderProduct> list = new List <ModelProviderProduct>(); if (sdr.HasRows) { while (sdr.Read()) { ModelProviderProduct model = new ModelProviderProduct(); model.Productid = Convert.ToInt32(sdr["Productid"]); model.Productname = sdr["Productname"].ToString(); model.Productcontent = sdr["Productcontent"].ToString(); model.Productprice = Convert.ToDouble(sdr["Productprice"]); model.Productimg = sdr["Productimg"].ToString(); model.Userid = Convert.ToInt32(sdr["Userid"]); list.Add(model); } } return(list); }