Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                 if (int.TryParse(Request.QueryString["pid"],out groupEventID) && groupEventID > 0)
                 {
                     this.hidPid.Value = groupEventID.ToString();
                     EventItemGroupEntity entity = bll.QueryGroupEntity(groupEventID);

                     if (entity != null && entity.GroupEventID > 0)
                     {
                         this.txtGroupEventName.Value = entity.GroupEventName;
                         this.txtPublishTime.Value = entity.PublishTime.ToString("yyyy-MM-dd HH:mm:ss");
                     }
                     else
                     {
                         WebMaster.EndPage();
                     }
                 }
                else
                 {
                     WebMaster.EndPage();
                 }
            }
        }
        /// <summary>
        /// 添加分组关联项
        /// </summary>
        /// <param name="groupEntity"></param>
        /// <param name="groupRelEntityList"></param>
        /// <returns></returns>
        public bool InsertGroupRel(EventItemGroupEntity groupEntity, List <EventItemGroupRelEntity> groupRelEntityList)
        {
            bool           isSuccess = false;
            SqlTransaction trans     = null;

            try
            {
                StringBuilder sbInsert       = new StringBuilder();
                string        insertGroupSQL = "INSERT INTO M_EventItemGroups(GroupEventName,PublishTime,CreatedTime,GroupState) VALUES (@GroupEventName,@PublishTime,@CreatedTime,@GroupState);SELECT @@IDENTITY;";
                string        insertRelSQL   = "INSERT INTO M_EventItem_Group_Rel(EventGroupID,EventItemID,DisplayOrder) VALUES({0},{1},{2});";

                SqlParameter[] prms =
                {
                    new SqlParameter("@GroupEventName", SqlDbType.VarChar,   100),
                    new SqlParameter("@PublishTime",    SqlDbType.DateTime),
                    new SqlParameter("@CreatedTime",    SqlDbType.DateTime),
                    new SqlParameter("@GroupState",     SqlDbType.Int)
                };
                prms[0].Value = groupEntity.GroupEventName;
                prms[1].Value = groupEntity.PublishTime;
                prms[2].Value = groupEntity.CreatedTime;
                prms[3].Value = groupEntity.GroupState;

                //去除重专题文章
                //groupRelEntityList = groupRelEntityList.Distinct(new EventItemGroupRelEntityDistinct()).ToList();

                using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
                {
                    conn.Open();
                    trans = conn.BeginTransaction();

                    int groupEventID = Convert.ToInt32(SQlHelper.ExecuteScalar(trans, CommandType.Text, insertGroupSQL, prms));

                    if (groupRelEntityList != null && groupRelEntityList.Count > 0)
                    {
                        foreach (EventItemGroupRelEntity groupRelEntity in groupRelEntityList)
                        {
                            sbInsert.AppendFormat(insertRelSQL, groupEventID, groupRelEntity.EventItemID, groupRelEntity.DisplayOrder);
                        }

                        int num2 = SQlHelper.ExecuteNonQuery(trans, CommandType.Text, sbInsert.ToString());
                    }

                    isSuccess = true;
                    trans.Commit();
                }
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);

                if (trans != null)
                {
                    trans.Rollback();
                }
                return(false);
            }

            return(isSuccess);
        }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool UpdateGroup(EventItemGroupEntity entity)
 {
     try
     {
         string updateSQL = "UPDATE M_EventItemGroups SET GroupEventName=@GroupEventName,CreatedTime=@CreatedTime,PublishTime=@PublishTime  WHERE GroupEventID=@GroupEventID";
         using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
         {
             return(conn.Execute(updateSQL, new { GroupEventID = entity.GroupEventID, GroupEventName = entity.GroupEventName, CreatedTime = entity.CreatedTime, PublishTime = entity.PublishTime }) > 0);
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(false);
     }
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="groupEntity"></param>
 /// <returns></returns>
 public bool InsertGroup(EventItemGroupEntity entity)
 {
     try
     {
         string insertSQL = "INSERT INTO M_EventItemGroups(GroupEventName,CreatedTime,PublishTime) VALUES(@GroupEventName,@CreatedTime,@PublishTime)";
         using (SqlConnection conn = new SqlConnection(SQlHelper.MyConnectStr))
         {
             return(conn.Execute(insertSQL, new { GroupEventName = entity.GroupEventName, CreatedTime = entity.CreatedTime, PublishTime = entity.PublishTime }) > 0);
         }
     }
     catch (Exception ex)
     {
         LogUtil.WriteLog(ex);
         return(false);
     }
 }
 /// <summary>
 /// 添加分组关联项
 /// </summary>
 /// <param name="groupEntity"></param>
 /// <param name="groupRelEntityList"></param>
 /// <returns></returns>
 public bool InsertGroupRel(EventItemGroupEntity groupEntity, List <EventItemGroupRelEntity> groupRelEntityList)
 {
     return(dao.InsertGroupRel(groupEntity, groupRelEntityList));
 }
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool UpdateGroup(EventItemGroupEntity entity)
 {
     return(dao.UpdateGroup(entity));
 }
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="groupEntity"></param>
 /// <returns></returns>
 public bool InsertGroup(EventItemGroupEntity entity)
 {
     return(dao.InsertGroup(entity));
 }
Example #8
0
        public List <EventItemGroupEntity> QueryAllEventItemGroups(int pageindex, int pagesize)
        {
            List <EventItemGroupEntity> items = new List <EventItemGroupEntity>();
            DataTable dt = eventitemobj.QueryAllEventItemGroups(pageindex, pagesize);

            int groupid = 0;
            EventItemGroupEntity tempgroup = null;

            foreach (DataRow dr in dt.Rows)
            {
                int gid = dr["GroupEventID"].ToString().ToInt();
                if (groupid == gid)
                {
                    tempgroup.EventItems.Add(new EventItemEntity()
                    {
                        EventItemID   = dr["EventItemID"].ToString().ToInt(),
                        Title         = dr["Title"].ToString(),
                        Content       = dr["Content"].ToString(),
                        Domain        = dr["Domain"].ToString(),
                        PicturePath   = dr["PicturePath"].ToString(),
                        PictureID     = dr["PictureID"].ToString().ToInt(),
                        EventItemGUID = Guid.Parse(dr["EventItemGUID"].ToString()),
                        StartTime     = Convert.ToDateTime(dr["StartTime"]),
                        EndTime       = Convert.ToDateTime(dr["EndTime"]),
                        LikeCnt       = dr["LikeCnt"].ToString().ToInt(),
                        CommentCnt    = dr["CommentCnt"].ToString().ToInt(),
                        Url           = dr["Url"].ToString()
                    });
                }
                else
                {
                    if (tempgroup != null)
                    {
                        items.Add(tempgroup);
                    }
                    tempgroup            = new EventItemGroupEntity();
                    tempgroup.EventItems = new List <EventItemEntity>();
                    tempgroup.EventItems.Add(new EventItemEntity()
                    {
                        EventItemID   = dr["EventItemID"].ToString().ToInt(),
                        Title         = dr["Title"].ToString(),
                        Content       = dr["Content"].ToString(),
                        Domain        = dr["Domain"].ToString(),
                        PicturePath   = dr["PicturePath"].ToString(),
                        PictureID     = dr["PictureID"].ToString().ToInt(),
                        EventItemGUID = Guid.Parse(dr["EventItemGUID"].ToString()),
                        StartTime     = Convert.ToDateTime(dr["StartTime"]),
                        EndTime       = Convert.ToDateTime(dr["EndTime"]),
                        LikeCnt       = dr["LikeCnt"].ToString().ToInt(),
                        CommentCnt    = dr["CommentCnt"].ToString().ToInt(),
                        Url           = dr["Url"].ToString()
                    });
                    tempgroup.GroupEventID = gid;
                    groupid = gid;
                }
            }

            if (tempgroup != null)
            {
                items.Add(tempgroup);
            }

            return(items);
        }