예제 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Match.Model.T_Match_Apply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Match_Apply(");
            strSql.Append("SID,CID,ATime,TID,AGroup)");
            strSql.Append(" values (");
            strSql.Append("@SID,@CID,@ATime,@TID,@AGroup)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SID",    SqlDbType.Int,       4),
                new SqlParameter("@CID",    SqlDbType.Int,       4),
                new SqlParameter("@ATime",  SqlDbType.DateTime),
                new SqlParameter("@TID",    SqlDbType.Int,       4),
                new SqlParameter("@AGroup", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SID;
            parameters[1].Value = model.CID;
            parameters[2].Value = model.ATime;
            parameters[3].Value = model.TID;
            parameters[4].Value = model.AGroup;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Match.Model.T_Match_Apply DataRowToModel(DataRow row)
 {
     Match.Model.T_Match_Apply model = new Match.Model.T_Match_Apply();
     if (row != null)
     {
         if (row["AID"] != null && row["AID"].ToString() != "")
         {
             model.AID = int.Parse(row["AID"].ToString());
         }
         if (row["SID"] != null && row["SID"].ToString() != "")
         {
             model.SID = int.Parse(row["SID"].ToString());
         }
         if (row["CID"] != null && row["CID"].ToString() != "")
         {
             model.CID = int.Parse(row["CID"].ToString());
         }
         if (row["ATime"] != null && row["ATime"].ToString() != "")
         {
             model.ATime = DateTime.Parse(row["ATime"].ToString());
         }
         if (row["TID"] != null && row["TID"].ToString() != "")
         {
             model.TID = int.Parse(row["TID"].ToString());
         }
         if (row["AGroup"] != null && row["AGroup"].ToString() != "")
         {
             model.AGroup = int.Parse(row["AGroup"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Match.Model.T_Match_Apply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Match_Apply set ");
            strSql.Append("SID=@SID,");
            strSql.Append("CID=@CID,");
            strSql.Append("ATime=@ATime,");
            strSql.Append("TID=@TID,");
            strSql.Append("AGroup=@AGroup");
            strSql.Append(" where AID=@AID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SID",    SqlDbType.Int,       4),
                new SqlParameter("@CID",    SqlDbType.Int,       4),
                new SqlParameter("@ATime",  SqlDbType.DateTime),
                new SqlParameter("@TID",    SqlDbType.Int,       4),
                new SqlParameter("@AGroup", SqlDbType.Int,       4),
                new SqlParameter("@AID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.SID;
            parameters[1].Value = model.CID;
            parameters[2].Value = model.ATime;
            parameters[3].Value = model.TID;
            parameters[4].Value = model.AGroup;
            parameters[5].Value = model.AID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Match.Model.T_Match_Apply GetModel(int AID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AID,SID,CID,ATime,TID,AGroup from T_Match_Apply ");
            strSql.Append(" where AID=@AID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AID", SqlDbType.Int, 4)
            };
            parameters[0].Value = AID;

            Match.Model.T_Match_Apply model = new Match.Model.T_Match_Apply();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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