Пример #1
0
        public MySqlCommand GetAddCommand(OrderInfo obj)
        {
            MySqlCommand cmd = new MySqlCommand();

            string sql="insert into testdb.order_info(order_number,name) values(?order_number, ?name)";
            cmd.CommandText = sql;
            cmd.Parameters.Add(new MySqlParameter("?order_number", SqlDataUtil.ToDBNullValue(obj.Order_Number)));
            cmd.Parameters.Add(new MySqlParameter("?name", SqlDataUtil.ToDBNullValue(obj.Name)));

            return cmd;
        }
Пример #2
0
        public MySqlCommand GetUpdateCommand(OrderInfo obj)
        {
            MySqlCommand cmd = new MySqlCommand();

            string sql="update testdb.order_info set  order_number=?order_number,name=?name where  id=?id ";
            cmd.CommandText = sql;
            cmd.Parameters.Add(new MySqlParameter("?id", SqlDataUtil.ToDBNullValue(obj.Id)));
            cmd.Parameters.Add(new MySqlParameter("?order_number", SqlDataUtil.ToDBNullValue(obj.Order_Number)));
            cmd.Parameters.Add(new MySqlParameter("?name", SqlDataUtil.ToDBNullValue(obj.Name)));

            return cmd;
        }
Пример #3
0
 public static int Add(OrderInfo obj)
 {
     return helper.Add(obj);
 }
Пример #4
0
 public OrderInfo FindByKey(int id)
 {
     MySqlCommand cmd = GetFindCommand(id);
     DataSet dataSet = SqlUtil.ExecuteQuery(cmd);
     if (dataSet.Tables[0].Rows.Count < 1)
     {
         return null;
     }
     DataRow dr = dataSet.Tables[0].Rows[0];
     OrderInfo obj = new OrderInfo();
     DataUtil.DataRowToObject(dr,obj);
     return obj;
 }
Пример #5
0
 public int Update(OrderInfo obj)
 {
     MySqlCommand cmd = GetUpdateCommand(obj);
     return (int)SqlUtil.ExecuteNonQuery(cmd);
 }