Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Gymnasium_APP.Model.CunsumeTypeModel DataRowToModel(DataRow row)
 {
     Gymnasium_APP.Model.CunsumeTypeModel model=new Gymnasium_APP.Model.CunsumeTypeModel();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["CusType"]!=null)
         {
             model.CusType=row["CusType"].ToString();
         }
         if(row["CusPrice"]!=null && row["CusPrice"].ToString()!="")
         {
             model.CusPrice=decimal.Parse(row["CusPrice"].ToString());
         }
         if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
         {
             model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
         }
     }
     return model;
 }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Gymnasium_APP.Model.CunsumeTypeModel GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,CusType,CusPrice,CreateTime from CunsumeType ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

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