示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(WK.Model.bus_order_dish model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into bus_order_dish(");
            strSql.Append("order_id,dish_id,total_original_price,total_discount_price,unit_original_price,unit_discount_price,count,size_list,is_delete,remark,create_by,create_date,update_by,update_date)");
            strSql.Append(" values (");
            strSql.Append("@order_id,@dish_id,@total_original_price,@total_discount_price,@unit_original_price,@unit_discount_price,@count,@size_list,@is_delete,@remark,@create_by,@create_date,@update_by,@update_date)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@order_id",             MySqlDbType.Int32,      11),
                new MySqlParameter("@dish_id",              MySqlDbType.Int32,      11),
                new MySqlParameter("@total_original_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@total_discount_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@unit_original_price",  MySqlDbType.Decimal,    10),
                new MySqlParameter("@unit_discount_price",  MySqlDbType.Decimal,    10),
                new MySqlParameter("@count",                MySqlDbType.Int32,      11),
                new MySqlParameter("@size_list",            MySqlDbType.Text),
                new MySqlParameter("@is_delete",            MySqlDbType.Int32,      11),
                new MySqlParameter("@remark",               MySqlDbType.VarChar,   500),
                new MySqlParameter("@create_by",            MySqlDbType.Int32,      11),
                new MySqlParameter("@create_date",          MySqlDbType.DateTime),
                new MySqlParameter("@update_by",            MySqlDbType.Int32,      11),
                new MySqlParameter("@update_date",          MySqlDbType.DateTime)
            };
            parameters[0].Value  = model.order_id;
            parameters[1].Value  = model.dish_id;
            parameters[2].Value  = model.total_original_price;
            parameters[3].Value  = model.total_discount_price;
            parameters[4].Value  = model.unit_original_price;
            parameters[5].Value  = model.unit_discount_price;
            parameters[6].Value  = model.count;
            parameters[7].Value  = model.size_list;
            parameters[8].Value  = model.is_delete;
            parameters[9].Value  = model.remark;
            parameters[10].Value = model.create_by;
            parameters[11].Value = model.create_date;
            parameters[12].Value = model.update_by;
            parameters[13].Value = model.update_date;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WK.Model.bus_order_dish GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,order_id,dish_id,total_original_price,total_discount_price,unit_original_price,unit_discount_price,count,size_list,is_delete,remark,create_by,create_date,update_by,update_date from bus_order_dish ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WK.Model.bus_order_dish DataRowToModel(DataRow row)
 {
     WK.Model.bus_order_dish model = new WK.Model.bus_order_dish();
     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["dish_id"] != null && row["dish_id"].ToString() != "")
         {
             model.dish_id = int.Parse(row["dish_id"].ToString());
         }
         if (row["total_original_price"] != null && row["total_original_price"].ToString() != "")
         {
             model.total_original_price = decimal.Parse(row["total_original_price"].ToString());
         }
         if (row["total_discount_price"] != null && row["total_discount_price"].ToString() != "")
         {
             model.total_discount_price = decimal.Parse(row["total_discount_price"].ToString());
         }
         if (row["unit_original_price"] != null && row["unit_original_price"].ToString() != "")
         {
             model.unit_original_price = decimal.Parse(row["unit_original_price"].ToString());
         }
         if (row["unit_discount_price"] != null && row["unit_discount_price"].ToString() != "")
         {
             model.unit_discount_price = decimal.Parse(row["unit_discount_price"].ToString());
         }
         if (row["count"] != null && row["count"].ToString() != "")
         {
             model.count = int.Parse(row["count"].ToString());
         }
         if (row["size_list"] != null)
         {
             model.size_list = row["size_list"].ToString();
         }
         if (row["is_delete"] != null && row["is_delete"].ToString() != "")
         {
             model.is_delete = int.Parse(row["is_delete"].ToString());
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
         if (row["create_by"] != null && row["create_by"].ToString() != "")
         {
             model.create_by = int.Parse(row["create_by"].ToString());
         }
         if (row["create_date"] != null && row["create_date"].ToString() != "")
         {
             model.create_date = DateTime.Parse(row["create_date"].ToString());
         }
         if (row["update_by"] != null && row["update_by"].ToString() != "")
         {
             model.update_by = int.Parse(row["update_by"].ToString());
         }
         if (row["update_date"] != null && row["update_date"].ToString() != "")
         {
             model.update_date = DateTime.Parse(row["update_date"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WK.Model.bus_order_dish model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update bus_order_dish set ");
            strSql.Append("order_id=@order_id,");
            strSql.Append("dish_id=@dish_id,");
            strSql.Append("total_original_price=@total_original_price,");
            strSql.Append("total_discount_price=@total_discount_price,");
            strSql.Append("unit_original_price=@unit_original_price,");
            strSql.Append("unit_discount_price=@unit_discount_price,");
            strSql.Append("count=@count,");
            strSql.Append("size_list=@size_list,");
            strSql.Append("is_delete=@is_delete,");
            strSql.Append("remark=@remark,");
            strSql.Append("create_by=@create_by,");
            strSql.Append("create_date=@create_date,");
            strSql.Append("update_by=@update_by,");
            strSql.Append("update_date=@update_date");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@order_id",             MySqlDbType.Int32,      11),
                new MySqlParameter("@dish_id",              MySqlDbType.Int32,      11),
                new MySqlParameter("@total_original_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@total_discount_price", MySqlDbType.Decimal,    10),
                new MySqlParameter("@unit_original_price",  MySqlDbType.Decimal,    10),
                new MySqlParameter("@unit_discount_price",  MySqlDbType.Decimal,    10),
                new MySqlParameter("@count",                MySqlDbType.Int32,      11),
                new MySqlParameter("@size_list",            MySqlDbType.Text),
                new MySqlParameter("@is_delete",            MySqlDbType.Int32,      11),
                new MySqlParameter("@remark",               MySqlDbType.VarChar,   500),
                new MySqlParameter("@create_by",            MySqlDbType.Int32,      11),
                new MySqlParameter("@create_date",          MySqlDbType.DateTime),
                new MySqlParameter("@update_by",            MySqlDbType.Int32,      11),
                new MySqlParameter("@update_date",          MySqlDbType.DateTime),
                new MySqlParameter("@id",                   MySqlDbType.Int32, 11)
            };
            parameters[0].Value  = model.order_id;
            parameters[1].Value  = model.dish_id;
            parameters[2].Value  = model.total_original_price;
            parameters[3].Value  = model.total_discount_price;
            parameters[4].Value  = model.unit_original_price;
            parameters[5].Value  = model.unit_discount_price;
            parameters[6].Value  = model.count;
            parameters[7].Value  = model.size_list;
            parameters[8].Value  = model.is_delete;
            parameters[9].Value  = model.remark;
            parameters[10].Value = model.create_by;
            parameters[11].Value = model.create_date;
            parameters[12].Value = model.update_by;
            parameters[13].Value = model.update_date;
            parameters[14].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }