Exemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MZZ.Model.tb_activity DataRowToModel(DataRow row)
 {
     MZZ.Model.tb_activity model=new MZZ.Model.tb_activity();
     if (row != null)
     {
         if(row["activity_id"]!=null && row["activity_id"].ToString()!="")
         {
             model.activity_id=int.Parse(row["activity_id"].ToString());
         }
         if(row["activity_hyid"]!=null && row["activity_hyid"].ToString()!="")
         {
             model.activity_hyid=int.Parse(row["activity_hyid"].ToString());
         }
         if(row["activity_openid"]!=null)
         {
             model.activity_openid=row["activity_openid"].ToString();
         }
         if(row["activity_reason"]!=null)
         {
             model.activity_reason=row["activity_reason"].ToString();
         }
         if(row["activity_num"]!=null && row["activity_num"].ToString()!="")
         {
             model.activity_num=int.Parse(row["activity_num"].ToString());
         }
         if(row["activity_calculate"]!=null && row["activity_calculate"].ToString()!="")
         {
             model.activity_calculate=int.Parse(row["activity_calculate"].ToString());
         }
         if(row["activity_state"]!=null && row["activity_state"].ToString()!="")
         {
             model.activity_state=int.Parse(row["activity_state"].ToString());
         }
         if(row["activity_times"]!=null && row["activity_times"].ToString()!="")
         {
             model.activity_times=DateTime.Parse(row["activity_times"].ToString());
         }
     }
     return model;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MZZ.Model.tb_activity GetModel(int activity_id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select activity_id,activity_hyid,activity_openid,activity_reason,activity_num,activity_calculate,activity_state,activity_times from tb_activity ");
            strSql.Append(" where activity_id=@activity_id");
            MySqlParameter[] parameters = {
                    new MySqlParameter("@activity_id", MySqlDbType.Int32)
            };
            parameters[0].Value = activity_id;

            MZZ.Model.tb_activity model=new MZZ.Model.tb_activity();
            DataSet ds=DbHelperMySQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }