Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AMS.Model.AMS_AdvertUsage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_AdvertUsage(");
            strSql.Append("AdvertID,SchoolID,AdvertUsage,LastUpdateTime)");
            strSql.Append(" values (");
            strSql.Append("@AdvertID,@SchoolID,@AdvertUsage,@LastUpdateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AdvertID",       SqlDbType.Int,   4),
                new SqlParameter("@SchoolID",       SqlDbType.Int,   4),
                new SqlParameter("@AdvertUsage",    SqlDbType.Text),
                new SqlParameter("@LastUpdateTime", SqlDbType.DateTime)
            };
            parameters[0].Value = model.AdvertID;
            parameters[1].Value = model.SchoolID;
            parameters[2].Value = model.AdvertUsage;
            parameters[3].Value = model.LastUpdateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS.Model.AMS_AdvertUsage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_AdvertUsage set ");
            strSql.Append("AdvertID=@AdvertID,");
            strSql.Append("SchoolID=@SchoolID,");
            strSql.Append("AdvertUsage=@AdvertUsage,");
            strSql.Append("LastUpdateTime=@LastUpdateTime");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AdvertID",       SqlDbType.Int,       4),
                new SqlParameter("@SchoolID",       SqlDbType.Int,       4),
                new SqlParameter("@AdvertUsage",    SqlDbType.Text),
                new SqlParameter("@LastUpdateTime", SqlDbType.DateTime),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.AdvertID;
            parameters[1].Value = model.SchoolID;
            parameters[2].Value = model.AdvertUsage;
            parameters[3].Value = model.LastUpdateTime;
            parameters[4].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_AdvertUsage GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,AdvertID,SchoolID,AdvertUsage,LastUpdateTime from AMS_AdvertUsage ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdvertID"] != null && ds.Tables[0].Rows[0]["AdvertID"].ToString() != "")
                {
                    model.AdvertID = int.Parse(ds.Tables[0].Rows[0]["AdvertID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["SchoolID"] != null && ds.Tables[0].Rows[0]["SchoolID"].ToString() != "")
                {
                    model.SchoolID = int.Parse(ds.Tables[0].Rows[0]["SchoolID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdvertUsage"] != null && ds.Tables[0].Rows[0]["AdvertUsage"].ToString() != "")
                {
                    model.AdvertUsage = ds.Tables[0].Rows[0]["AdvertUsage"].ToString();
                }
                if (ds.Tables[0].Rows[0]["LastUpdateTime"] != null && ds.Tables[0].Rows[0]["LastUpdateTime"].ToString() != "")
                {
                    model.LastUpdateTime = DateTime.Parse(ds.Tables[0].Rows[0]["LastUpdateTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
//        /// <summary>
//        /// 增加一条数据
//        /// </summary>
//        public bool Add(AMS.Model.View_AdvertUsage model)
//        {
//            StringBuilder strSql=new StringBuilder();
//            strSql.Append("insert into View_AdvertUsage(");
//            strSql.Append(")");
//            strSql.Append(" values (");
//            strSql.Append(")");
//            SqlParameter[] parameters = {
//};

//            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
//            if (rows > 0)
//            {
//                return true;
//            }
//            else
//            {
//                return false;
//            }
//        }
//        /// <summary>
//        /// 更新一条数据
//        /// </summary>
//        public bool Update(AMS.Model.View_AdvertUsage model)
//        {
//            StringBuilder strSql=new StringBuilder();
//            strSql.Append("update View_AdvertUsage set ");
//#warning 系统发现缺少更新的字段,请手工确认如此更新是否正确!
//            strSql.Append(" where ");
//            SqlParameter[] parameters = {
//};

//            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
//            if (rows > 0)
//            {
//                return true;
//            }
//            else
//            {
//                return false;
//            }
//        }

//        /// <summary>
//        /// 删除一条数据
//        /// </summary>
//        public bool Delete()
//        {
//            //该表无主键信息,请自定义主键/条件字段
//            StringBuilder strSql=new StringBuilder();
//            strSql.Append("delete from View_AdvertUsage ");
//            strSql.Append(" where ");
//            SqlParameter[] parameters = {
//};

//            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
//            if (rows > 0)
//            {
//                return true;
//            }
//            else
//            {
//                return false;
//            }
//        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_AdvertUsage GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  from View_AdvertUsage ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

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