예제 #1
0
        //通过对象修改表数据
        public bool reGoods(Goodss goods)
        {
            string temp = "update goodss set ";

            temp += "goodsId=\"";
            temp += goods.goodsId;
            temp += "\",goodsName=\"";
            temp += goods.goodsName;
            temp += "\",price=";
            temp += goods.price;
            temp += ",type=";
            temp += goods.type;
            temp += ",color=\"";
            temp += goods.color;
            temp += "\",tatse=\"";
            temp += goods.tatse;
            temp += "\",size=";
            temp += goods.size;
            temp += ",batching=\"";
            temp += goods.batching;
            temp += "\",introduce=\"";
            temp += goods.introduce;
            temp += "\",toBadTime=\"";
            temp += goods.toBadTime;
            temp += "\",flag=";
            temp += goods.flag;
            temp += " where goodsId=\"";
            temp += goods.goodsId;
            temp += "\"";
            WriteSqlSentence(temp);
            bool vo = mysql.ExecuteNonQuery();

            //select();
            return(vo);
        }
예제 #2
0
        //通过对象添加数据
        public bool addGoods(Goodss goods)
        {
            string temp = "insert into goodss values (\"";

            temp += goods.goodsId;
            temp += "\",\"";
            temp += goods.goodsName;
            temp += "\",";
            temp += goods.price;
            temp += ",";
            temp += goods.type;
            temp += ",\"";
            temp += goods.color;
            temp += "\",\"";
            temp += goods.tatse;
            temp += "\",";
            temp += goods.size;
            temp += ",\"";
            temp += goods.batching;
            temp += "\",\"";
            temp += goods.introduce;
            temp += "\",\"";
            temp += goods.toBadTime;
            temp += "\",";
            temp += goods.flag;
            temp += ")";
            WriteSqlSentence(temp);
            bool vo = mysql.ExecuteNonQuery();

            //select();
            return(vo);
        }
예제 #3
0
        private void selectGoodss()
        {
            //查询商品表
            string sqlStr = "select * from goodss";

            WriteSqlSentence(sqlStr);
            goodss.Clear();
            DataTable goodsTable = mysql.ExecuteQuery();

            for (int i = 0; i < goodsTable.Rows.Count; i++)
            {
                Goodss temp = new Goodss();
                temp.goodsId   = goodsTable.Rows[i]["goodsId"].ToString();
                temp.goodsName = goodsTable.Rows[i]["goodsName"].ToString();
                temp.price     = (double)goodsTable.Rows[i]["price"];
                temp.type      = (int)goodsTable.Rows[i]["type"];
                temp.color     = goodsTable.Rows[i]["color"].ToString();
                temp.tatse     = goodsTable.Rows[i]["tatse"].ToString();
                temp.size      = (int)goodsTable.Rows[i]["size"];
                temp.batching  = goodsTable.Rows[i]["batching"].ToString();
                temp.introduce = goodsTable.Rows[i]["introduce"].ToString();
                temp.toBadTime = goodsTable.Rows[i]["toBadTime"].ToString();
                temp.flag      = (int)goodsTable.Rows[i]["flag"];
                goodss.Add(temp);
            }
        }
예제 #4
0
        public Goodss selectGoodsFromName(string goodsName)
        {
            string sqlStr = "select * from goodss where goodsName = '" + goodsName + "'";

            WriteSqlSentence(sqlStr);
            DataTable goodsTable = mysql.ExecuteQuery();

            if (goodsTable.Rows.Count < 1)
            {
                return(null);
            }
            Goodss temp = new Goodss();

            temp.goodsId   = goodsTable.Rows[0]["goodsId"].ToString();
            temp.goodsName = goodsTable.Rows[0]["goodsName"].ToString();
            temp.price     = (double)goodsTable.Rows[0]["price"];
            temp.type      = (int)goodsTable.Rows[0]["type"];
            temp.color     = goodsTable.Rows[0]["color"].ToString();
            temp.tatse     = goodsTable.Rows[0]["tatse"].ToString();
            temp.size      = (int)goodsTable.Rows[0]["size"];
            temp.batching  = goodsTable.Rows[0]["batching"].ToString();
            temp.introduce = goodsTable.Rows[0]["introduce"].ToString();
            temp.toBadTime = goodsTable.Rows[0]["toBadTime"].ToString();
            temp.flag      = (int)goodsTable.Rows[0]["flag"];
            return(temp);
        }
예제 #5
0
 public void copy(Goodss temp)
 {
     this.goodsId   = temp.goodsId;
     this.goodsName = temp.goodsName;
     this.price     = temp.price;
     this.type      = temp.type;
     this.color     = temp.color;
     this.tatse     = temp.tatse;
     this.size      = temp.size;
     this.batching  = temp.batching;
     this.introduce = temp.introduce;
     this.toBadTime = temp.toBadTime;
     this.flag      = temp.flag;
 }
예제 #6
0
        //查询并返回承载数据的对象
        public Goodss selectGoods(string goodsId)
        {
            Goodss temp = new Goodss();

            foreach (Goodss i in goodss)
            {
                if (i.goodsId == goodsId)
                {
                    temp.copy(i);
                    return(temp);
                }
            }
            return(null);
        }