Ejemplo n.º 1
0
        public List<Product> queryProduct()
        {
            List<Product> products = new List<Product>();
            if (OpenDB() != true)
                return null;
            MySqlCommand cmd = new MySqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select pid,pname,pqgp,pimage,pprice,plocation,pdetail,pnumber,pminimum,tid from (tag natural join tp natural join product)";
            try
            {
                MySqlDataReader reader = cmd.ExecuteReader();
                if (!reader.HasRows)
                {
                    Console.WriteLine("未查询到相关信息!");
                    return null;
                }

                //FormatPrint("标签ID", "标志位", "商品名称", "商品位置");
                while (reader.Read())
                {
                    Product product = new Product();
                    product.setPid(reader[0].ToString());
                    product.setPname(reader[1].ToString());
                    product.setPqgp(Convert.ToInt32(reader[2].ToString()));
                    product.setPimage(reader[3].ToString());
                    product.setPprice(Convert.ToDouble(reader[4].ToString()));
                    product.setPlocation(Convert.ToInt32(reader[5].ToString()));
                    product.setPdetail(reader[6].ToString());
                    product.setPnumber(Convert.ToInt32(reader[7].ToString()));
                    product.setPminimum(Convert.ToInt32(reader[8].ToString()));
                    product.setTid(reader[9].ToString());
                    products.Add(product);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("标签查询错误!");
            }
            finally
            {
                conn.Close();

            }
            return products;
        }
Ejemplo n.º 2
0
 public List<TempCheck> querryTempCheck()
 {
     List<TempCheck> products = new List<TempCheck>();
      if (OpenDB() != true)
          return null;
      MySqlCommand cmd = new MySqlCommand();
      cmd.Connection = conn;
      cmd.CommandText = "select pid, count(tid),pminimum from checktemp natural join product group by pid;";
      try
      {
          MySqlDataReader reader = cmd.ExecuteReader();
          if (!reader.HasRows)
          {
              Console.WriteLine("未查询到相关信息!");
              return null;
          }
          //FormatPrint("标签ID", "标志位", "商品名称", "商品位置");
          while (reader.Read())
          {
              Product product = new Product();
              TempCheck tc = new TempCheck();
              tc.setPid(reader[0].ToString());
              tc.setCount(Convert.ToInt32(reader[1].ToString()));
              tc.setMinimum(Convert.ToInt32(reader[2].ToString()));
              tc.setFlag();
              products.Add(tc);
          }
      }
      catch (Exception e)
      {
          Console.WriteLine("标签查询错误!");
      }
      finally
      {
          conn.Close();
      }
      return products;
 }