/// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AMS.Model.AMS_TitleAd GetModel(string Name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,Operator,CustomerId,EffectDate,EndDate,AdContent,Num from AMS_TitleAd ");
            strSql.Append(" where Name=@Name");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name", SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = Name;

            AMS.Model.AMS_TitleAd model = new AMS.Model.AMS_TitleAd();
            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]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Operator"] != null && ds.Tables[0].Rows[0]["Operator"].ToString() != "")
                {
                    model.Operator = int.Parse(ds.Tables[0].Rows[0]["Operator"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CustomerId"] != null && ds.Tables[0].Rows[0]["CustomerId"].ToString() != "")
                {
                    model.CustomerId = int.Parse(ds.Tables[0].Rows[0]["CustomerId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EffectDate"] != null && ds.Tables[0].Rows[0]["EffectDate"].ToString() != "")
                {
                    model.EffectDate = DateTime.Parse(ds.Tables[0].Rows[0]["EffectDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["EndDate"] != null && ds.Tables[0].Rows[0]["EndDate"].ToString() != "")
                {
                    model.EndDate = DateTime.Parse(ds.Tables[0].Rows[0]["EndDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdContent"] != null && ds.Tables[0].Rows[0]["AdContent"].ToString() != "")
                {
                    model.AdContent = ds.Tables[0].Rows[0]["AdContent"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Num"] != null && ds.Tables[0].Rows[0]["Num"].ToString() != "")
                {
                    model.Num = ds.Tables[0].Rows[0]["Num"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
 /// <summary>
 /// 更新冠名广告
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool GetTitleAd(int Num)
 {
     try
     {
         AMS.Model.AMS_TitleAd advertTitle = AMS.ServiceProxy.ITitleAdService.GetTitleAdByNum(Num);
         if (advertTitle != null)
         {
             SeatManage.ClassModel.TitleAdvertInfo model     = SeatManage.Bll.AMS_TitleAd.GetTitleModel(advertTitle.Num);
             SeatManage.ClassModel.TitleAdvertInfo seatTitle = new SeatManage.ClassModel.TitleAdvertInfo();
             seatTitle.EffectDate    = Convert.ToDateTime(advertTitle.EffectDate);
             seatTitle.EndDate       = Convert.ToDateTime(advertTitle.EndDate);
             seatTitle.TitleAdvert   = advertTitle.AdContent;
             seatTitle.TitleAdvertNo = advertTitle.Num;
             if (model == null)
             {
                 if (SeatManage.Bll.AMS_TitleAd.AddTitleAdvert(seatTitle) == SeatManage.EnumType.HandleResult.Successed)
                 {
                     return
                         (true);
                 }
                 return(false);
             }
             else
             {
                 if (SeatManage.Bll.AMS_TitleAd.UpdateTitleAdvert(seatTitle) == SeatManage.EnumType.HandleResult.Successed)
                 {
                     return
                         (true);
                 }
                 return(false);
             }
         }
         else
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AMS.Model.AMS_TitleAd model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AMS_TitleAd set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Operator=@Operator,");
            strSql.Append("CustomerId=@CustomerId,");
            strSql.Append("EffectDate=@EffectDate,");
            strSql.Append("EndDate=@EndDate,");
            strSql.Append("AdContent=@AdContent");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.NVarChar,   20),
                new SqlParameter("@Operator",   SqlDbType.Int,         4),
                new SqlParameter("@CustomerId", SqlDbType.Int,         4),
                new SqlParameter("@EffectDate", SqlDbType.DateTime),
                new SqlParameter("@EndDate",    SqlDbType.DateTime),
                new SqlParameter("@AdContent",  SqlDbType.NVarChar,  300),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Operator;
            parameters[2].Value = model.CustomerId;
            parameters[3].Value = model.EffectDate;
            parameters[4].Value = model.EndDate;
            parameters[5].Value = model.AdContent;
            parameters[6].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 添加新的冠名
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static string AddNewtTitleAd(AMS.Model.AMS_TitleAd model)
 {
     AMS.IBllService.IAdvertManageBllService bllService = AMS.ServiceConnectChannel.AdvertManageBllServiceChannel.CreateServiceChannel();
     try
     {
         return(bllService.AddNewTitleAd(model));
     }
     catch (EndpointNotFoundException ex)
     {
         throw new AMS.Model.CustomerException("连接服务器失败");
     }
     catch (CommunicationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         ICommunicationObject ICommObjectService = bllService as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(AMS.Model.AMS_TitleAd model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AMS_TitleAd(");
            strSql.Append("Name,Operator,CustomerId,EffectDate,EndDate,AdContent,Num)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Operator,@CustomerId,@EffectDate,@EndDate,@AdContent,@Num)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.NVarChar,   20),
                new SqlParameter("@Operator",   SqlDbType.Int,         4),
                new SqlParameter("@CustomerId", SqlDbType.Int,         4),
                new SqlParameter("@EffectDate", SqlDbType.DateTime),
                new SqlParameter("@EndDate",    SqlDbType.DateTime),
                new SqlParameter("@AdContent",  SqlDbType.NVarChar,  300),
                new SqlParameter("@Num",        SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Operator;
            parameters[2].Value = model.CustomerId;
            parameters[3].Value = model.EffectDate;
            parameters[4].Value = model.EndDate;
            parameters[5].Value = model.AdContent;
            parameters[6].Value = model.Num;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }