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

            strSql.Append("insert into T_Match_Competition(");
            strSql.Append("CName,CIntroduce,CAttachment1,CAttachment2,CAttachment3,CStartTime,CEndTime,CApplySTime,CApplyETime,CType,CPublisherID,CPublisherName,CLevel)");
            strSql.Append(" values (");
            strSql.Append("@CName,@CIntroduce,@CAttachment1,@CAttachment2,@CAttachment3,@CStartTime,@CEndTime,@CApplySTime,@CApplyETime,@CType,@CPublisherID,@CPublisherName,@CLevel)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CName",          SqlDbType.VarChar,   100),
                new SqlParameter("@CIntroduce",     SqlDbType.NVarChar,   -1),
                new SqlParameter("@CAttachment1",   SqlDbType.VarChar,   255),
                new SqlParameter("@CAttachment2",   SqlDbType.VarChar,   255),
                new SqlParameter("@CAttachment3",   SqlDbType.VarChar,   255),
                new SqlParameter("@CStartTime",     SqlDbType.DateTime),
                new SqlParameter("@CEndTime",       SqlDbType.DateTime),
                new SqlParameter("@CApplySTime",    SqlDbType.DateTime),
                new SqlParameter("@CApplyETime",    SqlDbType.DateTime),
                new SqlParameter("@CType",          SqlDbType.Int,         4),
                new SqlParameter("@CPublisherID",   SqlDbType.Int,         4),
                new SqlParameter("@CPublisherName", SqlDbType.VarChar,   255),
                new SqlParameter("@CLevel",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.CName;
            parameters[1].Value  = model.CIntroduce;
            parameters[2].Value  = model.CAttachment1;
            parameters[3].Value  = model.CAttachment2;
            parameters[4].Value  = model.CAttachment3;
            parameters[5].Value  = model.CStartTime;
            parameters[6].Value  = model.CEndTime;
            parameters[7].Value  = model.CApplySTime;
            parameters[8].Value  = model.CApplyETime;
            parameters[9].Value  = model.CType;
            parameters[10].Value = model.CPublisherID;
            parameters[11].Value = model.CPublisherName;
            parameters[12].Value = model.CLevel;

            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_Competition GetModel(int CID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CID,CName,CIntroduce,CAttachment1,CAttachment2,CAttachment3,CStartTime,CEndTime,CApplySTime,CApplyETime,CType,CPublisherID,CPublisherName,CLevel from T_Match_Competition ");
            strSql.Append(" where CID=@CID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CID", SqlDbType.Int, 4)
            };
            parameters[0].Value = CID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Match.Model.T_Match_Competition DataRowToModel(DataRow row)
 {
     Match.Model.T_Match_Competition model = new Match.Model.T_Match_Competition();
     if (row != null)
     {
         if (row["CID"] != null && row["CID"].ToString() != "")
         {
             model.CID = int.Parse(row["CID"].ToString());
         }
         if (row["CName"] != null)
         {
             model.CName = row["CName"].ToString();
         }
         if (row["CIntroduce"] != null)
         {
             model.CIntroduce = row["CIntroduce"].ToString();
         }
         if (row["CAttachment1"] != null)
         {
             model.CAttachment1 = row["CAttachment1"].ToString();
         }
         if (row["CAttachment2"] != null)
         {
             model.CAttachment2 = row["CAttachment2"].ToString();
         }
         if (row["CAttachment3"] != null)
         {
             model.CAttachment3 = row["CAttachment3"].ToString();
         }
         if (row["CStartTime"] != null && row["CStartTime"].ToString() != "")
         {
             model.CStartTime = DateTime.Parse(row["CStartTime"].ToString());
         }
         if (row["CEndTime"] != null && row["CEndTime"].ToString() != "")
         {
             model.CEndTime = DateTime.Parse(row["CEndTime"].ToString());
         }
         if (row["CApplySTime"] != null && row["CApplySTime"].ToString() != "")
         {
             model.CApplySTime = DateTime.Parse(row["CApplySTime"].ToString());
         }
         if (row["CApplyETime"] != null && row["CApplyETime"].ToString() != "")
         {
             model.CApplyETime = DateTime.Parse(row["CApplyETime"].ToString());
         }
         if (row["CType"] != null && row["CType"].ToString() != "")
         {
             model.CType = int.Parse(row["CType"].ToString());
         }
         if (row["CPublisherID"] != null && row["CPublisherID"].ToString() != "")
         {
             model.CPublisherID = int.Parse(row["CPublisherID"].ToString());
         }
         if (row["CPublisherName"] != null)
         {
             model.CPublisherName = row["CPublisherName"].ToString();
         }
         if (row["CLevel"] != null && row["CLevel"].ToString() != "")
         {
             model.CLevel = int.Parse(row["CLevel"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Match.Model.T_Match_Competition model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Match_Competition set ");
            strSql.Append("CName=@CName,");
            strSql.Append("CIntroduce=@CIntroduce,");
            strSql.Append("CAttachment1=@CAttachment1,");
            strSql.Append("CAttachment2=@CAttachment2,");
            strSql.Append("CAttachment3=@CAttachment3,");
            strSql.Append("CStartTime=@CStartTime,");
            strSql.Append("CEndTime=@CEndTime,");
            strSql.Append("CApplySTime=@CApplySTime,");
            strSql.Append("CApplyETime=@CApplyETime,");
            strSql.Append("CType=@CType,");
            strSql.Append("CPublisherID=@CPublisherID,");
            strSql.Append("CPublisherName=@CPublisherName,");
            strSql.Append("CLevel=@CLevel");
            strSql.Append(" where CID=@CID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CName",          SqlDbType.VarChar,   100),
                new SqlParameter("@CIntroduce",     SqlDbType.NVarChar,   -1),
                new SqlParameter("@CAttachment1",   SqlDbType.VarChar,   255),
                new SqlParameter("@CAttachment2",   SqlDbType.VarChar,   255),
                new SqlParameter("@CAttachment3",   SqlDbType.VarChar,   255),
                new SqlParameter("@CStartTime",     SqlDbType.DateTime),
                new SqlParameter("@CEndTime",       SqlDbType.DateTime),
                new SqlParameter("@CApplySTime",    SqlDbType.DateTime),
                new SqlParameter("@CApplyETime",    SqlDbType.DateTime),
                new SqlParameter("@CType",          SqlDbType.Int,         4),
                new SqlParameter("@CPublisherID",   SqlDbType.Int,         4),
                new SqlParameter("@CPublisherName", SqlDbType.VarChar,   255),
                new SqlParameter("@CLevel",         SqlDbType.Int,         4),
                new SqlParameter("@CID",            SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.CName;
            parameters[1].Value  = model.CIntroduce;
            parameters[2].Value  = model.CAttachment1;
            parameters[3].Value  = model.CAttachment2;
            parameters[4].Value  = model.CAttachment3;
            parameters[5].Value  = model.CStartTime;
            parameters[6].Value  = model.CEndTime;
            parameters[7].Value  = model.CApplySTime;
            parameters[8].Value  = model.CApplyETime;
            parameters[9].Value  = model.CType;
            parameters[10].Value = model.CPublisherID;
            parameters[11].Value = model.CPublisherName;
            parameters[12].Value = model.CLevel;
            parameters[13].Value = model.CID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }