Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Library.Model.Test_Table model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Test_Table(");
            strSql.Append("F_TempleteID,F_Time,F_BannerContent,F_IsShow)");
            strSql.Append(" values (");
            strSql.Append("@F_TempleteID,@F_Time,@F_BannerContent,@F_IsShow)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_TempleteID",    SqlDbType.Int,          4),
                new SqlParameter("@F_Time",          SqlDbType.DateTime),
                new SqlParameter("@F_BannerContent", SqlDbType.VarChar,   1000),
                new SqlParameter("@F_IsShow",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_TempleteID;
            parameters[1].Value = model.F_Time;
            parameters[2].Value = model.F_BannerContent;
            parameters[3].Value = model.F_IsShow;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Library.Model.Test_Table DataRowToModel(DataRow row)
 {
     Library.Model.Test_Table model = new Library.Model.Test_Table();
     if (row != null)
     {
         if (row["F_ID"] != null && row["F_ID"].ToString() != "")
         {
             model.F_ID = int.Parse(row["F_ID"].ToString());
         }
         if (row["F_TempleteID"] != null && row["F_TempleteID"].ToString() != "")
         {
             model.F_TempleteID = int.Parse(row["F_TempleteID"].ToString());
         }
         if (row["F_Time"] != null && row["F_Time"].ToString() != "")
         {
             model.F_Time = DateTime.Parse(row["F_Time"].ToString());
         }
         if (row["F_BannerContent"] != null)
         {
             model.F_BannerContent = row["F_BannerContent"].ToString();
         }
         if (row["F_IsShow"] != null && row["F_IsShow"].ToString() != "")
         {
             model.F_IsShow = int.Parse(row["F_IsShow"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Library.Model.Test_Table model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_Test_Table set ");
            strSql.Append("F_TempleteID=@F_TempleteID,");
            strSql.Append("F_Time=@F_Time,");
            strSql.Append("F_BannerContent=@F_BannerContent,");
            strSql.Append("F_IsShow=@F_IsShow");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_TempleteID",    SqlDbType.Int,          4),
                new SqlParameter("@F_Time",          SqlDbType.DateTime),
                new SqlParameter("@F_BannerContent", SqlDbType.VarChar,   1000),
                new SqlParameter("@F_IsShow",        SqlDbType.Int,          4),
                new SqlParameter("@F_ID",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.F_TempleteID;
            parameters[1].Value = model.F_Time;
            parameters[2].Value = model.F_BannerContent;
            parameters[3].Value = model.F_IsShow;
            parameters[4].Value = model.F_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Library.Model.Test_Table GetModel(int F_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 F_ID,F_TempleteID,F_Time,F_BannerContent,F_IsShow from T_Test_Table ");
            strSql.Append(" where F_ID=@F_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@F_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = F_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Library.Model.Test_Table model)
 {
     return(dal.Update(model));
 }
Esempio n. 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Library.Model.Test_Table model)
 {
     return(dal.Add(model));
 }