/// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SeatManage.ClassModel.AMS_AdvertUsage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_AdvertUsage set ");
            strSql.Append("AdvertID=@AdvertID,");
            strSql.Append("AdvertUsage=@AdvertUsage,");
            strSql.Append("LastUpdateTime=@LastUpdateTime");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AdvertID",       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.ToXml();
            parameters[2].Value = model.LastUpdateTime;
            parameters[3].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(SeatManage.ClassModel.AMS_AdvertUsage model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新使用情况
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string UpdateAdvertUsage(SeatManage.ClassModel.AMS_AdvertUsage model)
 {
     try
     {
         SeatManage.ClassModel.AMS_AdvertUsage oldModel = GetAdvertUsage(model.AdvertNum, model.AdvertType);
         if (oldModel != null)
         {
             oldModel.LastUpdateTime = DateTime.Now;
             oldModel.PlayCount     += model.PlayCount;
             oldModel.PrintCount    += model.PrintCount;
             oldModel.WatchCount    += model.WatchCount;
             foreach (KeyValuePair <string, SeatManage.ClassModel.AdvertisementUsage> item in model.ItemUsage)
             {
                 if (oldModel.ItemUsage.ContainsKey(item.Key))
                 {
                     oldModel.ItemUsage[item.Key].PlayCount  += item.Value.PlayCount;
                     oldModel.ItemUsage[item.Key].PrintCount += item.Value.PrintCount;
                     oldModel.ItemUsage[item.Key].WatchCount += item.Value.WatchCount;
                 }
                 else
                 {
                     oldModel.ItemUsage.Add(item.Key, item.Value);
                 }
             }
             if (advertusage_dal.Update(oldModel))
             {
                 return("");
             }
             else
             {
                 return("更新失败");
             }
         }
         else
         {
             model.LastUpdateTime = DateTime.Now;
             if (advertusage_dal.Add(model))
             {
                 return("");
             }
             else
             {
                 return("添加失败");
             }
         }
     }
     catch
     {
         throw;
     }
 }
Exemplo n.º 4
0
        private SeatManage.ClassModel.AMS_AdvertUsage DataRowToAMS_AdvertUsage(DataRow dr)
        {
            //ID,AdvertID,AdvertUsage,LastUpdateTime,AdvertType,AdvertNum
            SeatManage.ClassModel.AMS_AdvertUsage model = new SeatManage.ClassModel.AMS_AdvertUsage();
            model                = SeatManage.ClassModel.AMS_AdvertUsage.ToModel(dr["AdvertUsage"].ToString());
            model.ID             = int.Parse(dr["ID"].ToString());
            model.AdvertID       = int.Parse(dr["AdvertID"].ToString());
            model.AdvertNum      = dr["AdvertNum"].ToString();
            model.AdvertType     = (SeatManage.EnumType.AdType) int.Parse(dr["AdvertType"].ToString());
            model.AdvertUsage    = dr["AdvertUsage"].ToString();
            model.LastUpdateTime = DateTime.Parse(dr["LastUpdateTime"].ToString());

            return(model);
        }
Exemplo n.º 5
0
//        /// <summary>
//        /// 增加一条数据
//        /// </summary>
//        public bool Add(Maticsoft.Model.ViewAdvertUsage model)
//        {
//            StringBuilder strSql=new StringBuilder();
//            strSql.Append("insert into ViewAdvertUsage(");
//            strSql.Append("ID,AdvertID,AdvertUsage,LastUpdateTime,AdvertType,AdvertNum)");
//            strSql.Append(" values (");
//            strSql.Append("@ID,@AdvertID,@AdvertUsage,@LastUpdateTime,@AdvertType,@AdvertNum)");
//            SqlParameter[] parameters = {
//                    new SqlParameter("@ID", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertID", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertUsage", SqlDbType.Text),
//                    new SqlParameter("@LastUpdateTime", SqlDbType.DateTime),
//                    new SqlParameter("@AdvertType", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertNum", SqlDbType.NVarChar,50)};
//            parameters[0].Value = model.ID;
//            parameters[1].Value = model.AdvertID;
//            parameters[2].Value = model.AdvertUsage;
//            parameters[3].Value = model.LastUpdateTime;
//            parameters[4].Value = model.AdvertType;
//            parameters[5].Value = model.AdvertNum;

//            int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
//            if (rows > 0)
//            {
//                return true;
//            }
//            else
//            {
//                return false;
//            }
//        }
//        /// <summary>
//        /// 更新一条数据
//        /// </summary>
//        public bool Update(Maticsoft.Model.ViewAdvertUsage model)
//        {
//            StringBuilder strSql=new StringBuilder();
//            strSql.Append("update ViewAdvertUsage set ");
//            strSql.Append("ID=@ID,");
//            strSql.Append("AdvertID=@AdvertID,");
//            strSql.Append("AdvertUsage=@AdvertUsage,");
//            strSql.Append("LastUpdateTime=@LastUpdateTime,");
//            strSql.Append("AdvertType=@AdvertType,");
//            strSql.Append("AdvertNum=@AdvertNum");
//            strSql.Append(" where ");
//            SqlParameter[] parameters = {
//                    new SqlParameter("@ID", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertID", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertUsage", SqlDbType.Text),
//                    new SqlParameter("@LastUpdateTime", SqlDbType.DateTime),
//                    new SqlParameter("@AdvertType", SqlDbType.Int,4),
//                    new SqlParameter("@AdvertNum", SqlDbType.NVarChar,50)};
//            parameters[0].Value = model.ID;
//            parameters[1].Value = model.AdvertID;
//            parameters[2].Value = model.AdvertUsage;
//            parameters[3].Value = model.LastUpdateTime;
//            parameters[4].Value = model.AdvertType;
//            parameters[5].Value = model.AdvertNum;

//            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 ViewAdvertUsage ");
//            strSql.Append(" where ");
//            SqlParameter[] parameters = {
//};

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


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

            strSql.Append("select  top 1 ID,AdvertID,AdvertUsage,LastUpdateTime,AdvertType,AdvertNum from ViewAdvertUsage ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

            SeatManage.ClassModel.AMS_AdvertUsage model = new SeatManage.ClassModel.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]["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());
                }
                if (ds.Tables[0].Rows[0]["AdvertType"] != null && ds.Tables[0].Rows[0]["AdvertType"].ToString() != "")
                {
                    model.AdvertType = (SeatManage.EnumType.AdType) int.Parse(ds.Tables[0].Rows[0]["AdvertType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdvertNum"] != null && ds.Tables[0].Rows[0]["AdvertNum"].ToString() != "")
                {
                    model.AdvertNum = ds.Tables[0].Rows[0]["AdvertNum"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeatManage.ClassModel.AMS_AdvertUsage GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

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

            SeatManage.ClassModel.AMS_AdvertUsage model = new SeatManage.ClassModel.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]["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);
            }
        }