Exemple #1
0
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.CardGame DataRowToModel(DataRow row)
		{
			Model.CardGame model=new Model.CardGame();
			if (row != null)
			{
				if(row["ID"]!=null && row["ID"].ToString()!="")
				{
					model.ID=int.Parse(row["ID"].ToString());
				}
				if(row["GameID"]!=null && row["GameID"].ToString()!="")
				{
					model.GameID=int.Parse(row["GameID"].ToString());
				}
				if(row["CardName"]!=null)
				{
					model.CardName=row["CardName"].ToString();
				}
				if(row["CardType"]!=null)
				{
					model.CardType=row["CardType"].ToString();
				}
				if(row["Status"]!=null)
				{
					model.Status=row["Status"].ToString();
				}
				if(row["UpdateDate"]!=null && row["UpdateDate"].ToString()!="")
				{
					model.UpdateDate=DateTime.Parse(row["UpdateDate"].ToString());
				}
				if(row["ChanelID"]!=null && row["ChanelID"].ToString()!="")
				{
					model.ChanelID=int.Parse(row["ChanelID"].ToString());
				}
				if(row["ChanelName"]!=null)
				{
					model.ChanelName=row["ChanelName"].ToString();
				}
				if(row["UserID"]!=null && row["UserID"].ToString()!="")
				{
					model.UserID=int.Parse(row["UserID"].ToString());
				}
				if(row["Bak1"]!=null)
				{
					model.Bak1=row["Bak1"].ToString();
				}
				if(row["Bak2"]!=null)
				{
					model.Bak2=row["Bak2"].ToString();
				}
				if(row["Bak3"]!=null)
				{
					model.Bak3=row["Bak3"].ToString();
				}
			}
			return model;
		}
Exemple #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.CardGame GetModelbyChanelID(int ChanelID, int GameID)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 ID,GameID,CardName,CardType,Status,UpdateDate,ChanelID,ChanelName,UserID,Bak1,Bak2,Bak3 from CardGame ");
            strSql.Append(" where ChanelID=@ChanelID and GameID=@GameID");
            SqlParameter[] parameters = {
					new SqlParameter("@ChanelID", SqlDbType.Int,4),
                    new SqlParameter("@GameID", SqlDbType.Int,4)
			};
            parameters[0].Value = ChanelID;
            parameters[1].Value = GameID;
            Model.CardGame model = new Model.CardGame();
            DataSet ds = DbHelper.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }