/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XHD.Model.shop_purchase_order DataRowToModel(DataRow row)
 {
     XHD.Model.shop_purchase_order model = new XHD.Model.shop_purchase_order();
     if (row != null)
     {
         //model.oid=row["oid"].ToString();
         if (row["purchase_sn"] != null)
         {
             model.purchase_sn = row["purchase_sn"].ToString();
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = int.Parse(row["add_time"].ToString());
         }
         if (row["admin_id"] != null)
         {
             model.admin_id = row["admin_id"].ToString();
         }
         if (row["p_status"] != null && row["p_status"].ToString() != "")
         {
             model.p_status = int.Parse(row["p_status"].ToString());
         }
         if (row["last_update_time"] != null && row["last_update_time"].ToString() != "")
         {
             model.last_update_time = int.Parse(row["last_update_time"].ToString());
         }
         if (row["arrive_time"] != null && row["arrive_time"].ToString() != "")
         {
             model.arrive_time = int.Parse(row["arrive_time"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XHD.Model.shop_purchase_order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update shop_purchase_order set ");
            strSql.Append("purchase_sn=@purchase_sn,");
            strSql.Append("add_time=@add_time,");
            strSql.Append("admin_id=@admin_id,");
            strSql.Append("p_status=@p_status,");
            strSql.Append("last_update_time=@last_update_time,");
            strSql.Append("arrive_time=@arrive_time");
            strSql.Append(" where oid=@oid ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@purchase_sn",      MySqlDbType.VarChar, 30),
                new MySqlParameter("@add_time",         MySqlDbType.Int32,   11),
                new MySqlParameter("@admin_id",         MySqlDbType.VarChar, 12),
                new MySqlParameter("@p_status",         MySqlDbType.Int32,    2),
                new MySqlParameter("@last_update_time", MySqlDbType.Int32,   11),
                new MySqlParameter("@arrive_time",      MySqlDbType.Int32,   11),
                new MySqlParameter("@oid",              MySqlDbType.Int32, 8)
            };
            parameters[0].Value = model.purchase_sn;
            parameters[1].Value = model.add_time;
            parameters[2].Value = model.admin_id;
            parameters[3].Value = model.p_status;
            parameters[4].Value = model.last_update_time;
            parameters[5].Value = model.arrive_time;
            parameters[6].Value = model.oid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XHD.Model.shop_purchase_order model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into shop_purchase_order(");
            strSql.Append("oid,purchase_sn,add_time,admin_id,p_status,last_update_time,arrive_time)");
            strSql.Append(" values (");
            strSql.Append("@oid,@purchase_sn,@add_time,@admin_id,@p_status,@last_update_time,@arrive_time)");
            strSql.Append(";select @@IDENTITY");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@oid",              MySqlDbType.Int32,    8),
                new MySqlParameter("@purchase_sn",      MySqlDbType.VarChar, 30),
                new MySqlParameter("@add_time",         MySqlDbType.Int32,   11),
                new MySqlParameter("@admin_id",         MySqlDbType.VarChar, 12),
                new MySqlParameter("@p_status",         MySqlDbType.Int32,    2),
                new MySqlParameter("@last_update_time", MySqlDbType.Int32,   11),
                new MySqlParameter("@arrive_time",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.oid;
            parameters[1].Value = model.purchase_sn;
            parameters[2].Value = model.add_time;
            parameters[3].Value = model.admin_id;
            parameters[4].Value = model.p_status;
            parameters[5].Value = model.last_update_time;
            parameters[6].Value = model.arrive_time;

            object obj = Shop_DbHelperMySQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public XHD.Model.shop_purchase_order GetModel(int oid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select oid,purchase_sn,add_time,admin_id,p_status,last_update_time,arrive_time from shop_purchase_order ");
            strSql.Append(" where oid=@oid ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@oid", MySqlDbType.Int32, 8)
            };
            parameters[0].Value = oid;

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

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