Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(XHD.Model.scm_spe_order_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into scm_spe_order_goods(");
            strSql.Append("id,order_id,order_goodsid,order_goodssn,goods_num,goods_price)");
            strSql.Append(" values (");
            strSql.Append("@id,@order_id,@order_goodsid,@order_goodssn,@goods_num,@goods_price)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id",            MySqlDbType.Int32,   11),
                new MySqlParameter("@order_id",      MySqlDbType.Int32,   11),
                new MySqlParameter("@order_goodsid", MySqlDbType.Int32,   11),
                new MySqlParameter("@order_goodssn", MySqlDbType.VarChar, 60),
                new MySqlParameter("@goods_num",     MySqlDbType.Int32,   11),
                new MySqlParameter("@goods_price",   MySqlDbType.Decimal, 10)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.order_id;
            parameters[2].Value = model.order_goodsid;
            parameters[3].Value = model.order_goodssn;
            parameters[4].Value = model.goods_num;
            parameters[5].Value = model.goods_price;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.scm_spe_order_goods DataRowToModel(DataRow row)
 {
     XHD.Model.scm_spe_order_goods model = new XHD.Model.scm_spe_order_goods();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["order_id"] != null && row["order_id"].ToString() != "")
         {
             model.order_id = int.Parse(row["order_id"].ToString());
         }
         if (row["order_goodsid"] != null && row["order_goodsid"].ToString() != "")
         {
             model.order_goodsid = int.Parse(row["order_goodsid"].ToString());
         }
         if (row["order_goodssn"] != null)
         {
             model.order_goodssn = row["order_goodssn"].ToString();
         }
         if (row["goods_num"] != null && row["goods_num"].ToString() != "")
         {
             model.goods_num = int.Parse(row["goods_num"].ToString());
         }
         if (row["goods_price"] != null && row["goods_price"].ToString() != "")
         {
             model.goods_price = decimal.Parse(row["goods_price"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XHD.Model.scm_spe_order_goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update scm_spe_order_goods set ");
            strSql.Append("order_id=@order_id,");
            strSql.Append("order_goodsid=@order_goodsid,");
            strSql.Append("order_goodssn=@order_goodssn,");
            strSql.Append("goods_num=@goods_num,");
            strSql.Append("goods_price=@goods_price");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@order_id",      MySqlDbType.Int32,   11),
                new MySqlParameter("@order_goodsid", MySqlDbType.Int32,   11),
                new MySqlParameter("@order_goodssn", MySqlDbType.VarChar, 60),
                new MySqlParameter("@goods_num",     MySqlDbType.Int32,   11),
                new MySqlParameter("@goods_price",   MySqlDbType.Decimal, 10),
                new MySqlParameter("@id",            MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.order_id;
            parameters[1].Value = model.order_goodsid;
            parameters[2].Value = model.order_goodssn;
            parameters[3].Value = model.goods_num;
            parameters[4].Value = model.goods_price;
            parameters[5].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        public XHD.Model.scm_spe_order_goods GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,order_id,order_goodsid,order_goodssn,goods_num,goods_price ");
            strSql.Append(" FROM scm_spe_order_goods ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }

            XHD.Model.scm_spe_order_goods model = new XHD.Model.scm_spe_order_goods();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XHD.Model.scm_spe_order_goods GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,order_id,order_goodsid,order_goodssn,goods_num,goods_price from scm_spe_order_goods ");
            strSql.Append(" where id=@id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = id;

            XHD.Model.scm_spe_order_goods model = new XHD.Model.scm_spe_order_goods();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }