/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { MPeerNews PeerNewsModel = BPeerNews.CreateInstance().GetPeerNews(EditId); PeerNewsModel.Content = Utils.GetFormValue(txtDescription.UniqueID); PeerNewsModel.Title = Utils.GetFormValue(this.Title.UniqueID); PeerNewsModel.AttachInfo = GetAttachInfo(PeerNewsModel.AttachInfo); PeerNewsModel.B2BDisplay = (NewsB2BDisplay)Utils.GetInt(Utils.GetFormValue(this.DdlB2B.UniqueID)); PeerNewsModel.TypeId = (PeerNewType)Utils.GetInt(Utils.GetFormValue(this.DdlType.UniqueID)); PeerNewsModel.SortId = Utils.GetInt(Utils.GetFormValue(this.txt_B2BOrder.UniqueID)); int result = EyouSoft.BLL.NewsStructure.BPeerNews.CreateInstance().ManageUpdatePeerNews(PeerNewsModel); if (result == 1) { if (EyouSoft.Common.Utils.GetQueryStringValue("type") == "list")// 弹窗的话就hide() { Response.Write("<script language='javascript'>alert('修改成功!');parent.Boxy.getIframeDialog('" + Request.QueryString["iframeid"] + "').hide();parent.Informationindustry.GetInformationList()</script>"); } else { //这里跳转回去就翻页翻不动了。。 EyouSoft.Common.Function.MessageBox.ShowAndRedirect(this.Page, "修改成功!", returnUrl); } } else { EyouSoft.Common.Function.MessageBox.Show(this.Page, "修改失败!"); } PeerNewsModel = null; }
/// <summary> /// 用户后台修改同业资讯信息 /// </summary> /// <param name="model">同业资讯实体</param> /// <returns>返回1成功,其他失败</returns> /// <remarks> /// 图片和附件通过集合的传值与否来修改: /// 图片附件集合为空或者长度小于1,不修改原来的附件信息, /// 否则删除原来的信息,保存新的图片附件信息 /// </remarks> public int CustomerUpdatePeerNews(MPeerNews model) { if (model == null || string.IsNullOrEmpty(model.NewId)) { return(0); } return(_dal.CustomerUpdatePeerNews(model)); }
/// <summary> /// 运营后台修改同业资讯信息 /// </summary> /// <param name="model">同业资讯实体</param> /// <returns>返回1成功,其他失败</returns> /// <remarks> /// 图片和附件通过集合的传值与否来修改: /// 图片附件集合为空或者长度小于1,不修改原来的附件信息, /// 否则删除原来的信息,保存新的图片附件信息 /// </remarks> public int ManageUpdatePeerNews(MPeerNews model) { if (model == null || string.IsNullOrEmpty(model.CompanyId) || string.IsNullOrEmpty(model.OperatorId) || string.IsNullOrEmpty(model.Title) || string.IsNullOrEmpty(model.NewId)) { return(0); } return(_dal.ManageUpdatePeerNews(model)); }
/// <summary> /// 添加同业资讯信息 /// </summary> /// <param name="model">同业资讯实体</param> /// <returns>返回1成功,其他失败</returns> public int AddPeerNews(MPeerNews model) { if (model == null || string.IsNullOrEmpty(model.CompanyId) || string.IsNullOrEmpty(model.OperatorId) || string.IsNullOrEmpty(model.Title)) { return(0); } return(_dal.AddPeerNews(model)); }
/// <summary> /// 添加同业资讯信息 /// </summary> /// <param name="model">同业资讯实体</param> /// <returns>返回1成功,其他失败</returns> public int AddPeerNews(MPeerNews model) { if (model == null || string.IsNullOrEmpty(model.CompanyId) || string.IsNullOrEmpty(model.OperatorId) || string.IsNullOrEmpty(model.Title)) { return(0); } model.NewId = Guid.NewGuid().ToString(); model.IssueTime = DateTime.Now; model.LastUpdateTime = model.IssueTime; var strSql = new StringBuilder(); strSql.Append(SqlPeerNewsAdd); if (model.AttachInfo != null && model.AttachInfo.Count > 0) { foreach (var t in model.AttachInfo) { if (t == null) { continue; } t.Id = Guid.NewGuid().ToString(); strSql.AppendFormat(SqlPeerNewsAttachInfoAdd, t.Id, model.NewId, (int)t.Type, t.Path, t.FileName, t.Remark); } } DbCommand dc = _db.GetSqlStringCommand(strSql.ToString()); _db.AddInParameter(dc, "NewId", DbType.AnsiStringFixedLength, model.NewId); _db.AddInParameter(dc, "Title", DbType.String, model.Title); _db.AddInParameter(dc, "TypeId", DbType.Byte, (int)model.TypeId); _db.AddInParameter(dc, "Content", DbType.String, model.Content); _db.AddInParameter(dc, "CompanyId", DbType.AnsiStringFixedLength, model.CompanyId); _db.AddInParameter(dc, "CompanyName", DbType.String, model.CompanyName); _db.AddInParameter(dc, "OperatorId", DbType.AnsiStringFixedLength, model.OperatorId); _db.AddInParameter(dc, "OperatorName", DbType.String, model.OperatorName); _db.AddInParameter(dc, "B2BDisplay", DbType.Byte, (int)model.B2BDisplay); _db.AddInParameter(dc, "SortId", DbType.Int32, model.SortId); _db.AddInParameter(dc, "ClickNum", DbType.Int32, model.ClickNum); _db.AddInParameter(dc, "IP", DbType.String, model.Ip); _db.AddInParameter(dc, "IssueTime", DbType.DateTime, model.IssueTime); _db.AddInParameter(dc, "LastUpdateTime", DbType.DateTime, model.LastUpdateTime); _db.AddInParameter(dc, "AreaId", DbType.Int32, model.AreaId); _db.AddInParameter(dc, "AreaName", DbType.String, model.AreaName); _db.AddInParameter(dc, "AreaType", DbType.Byte, (int)model.AreaType); _db.AddInParameter(dc, "ScenicId", DbType.String, model.ScenicId); return(DbHelper.ExecuteSql(dc, _db) > 0 ? 1 : -1); }
/// <summary> /// 用户后台修改同业资讯信息 /// </summary> /// <param name="model">同业资讯实体</param> /// <returns>返回1成功,其他失败</returns> public int CustomerUpdatePeerNews(MPeerNews model) { if (model == null || string.IsNullOrEmpty(model.NewId)) { return(0); } model.LastUpdateTime = DateTime.Now; var strSql = new StringBuilder(); strSql.Append(SqlPeerNewsUpdateByCustomer); if (model.AttachInfo != null && model.AttachInfo.Count > 0) { strSql.Append(SqlPeerNewsAttachInfoDelByNewId); foreach (var t in model.AttachInfo) { if (t == null) { continue; } t.Id = Guid.NewGuid().ToString(); strSql.AppendFormat(SqlPeerNewsAttachInfoAdd, t.Id, model.NewId, (int)t.Type, t.Path, t.FileName, t.Remark); } } else if (model.AttachInfo == null || model.AttachInfo.Count <= 0) { strSql.AppendFormat(SqlPeerNewsAttachInfoDelByNewId); } DbCommand dc = _db.GetSqlStringCommand(strSql.ToString()); _db.AddInParameter(dc, "NewId", DbType.AnsiStringFixedLength, model.NewId); _db.AddInParameter(dc, "Title", DbType.String, model.Title); _db.AddInParameter(dc, "TypeId", DbType.Byte, (int)model.TypeId); _db.AddInParameter(dc, "Content", DbType.String, model.Content); _db.AddInParameter(dc, "LastUpdateTime", DbType.DateTime, model.LastUpdateTime); _db.AddInParameter(dc, "AreaId", DbType.Int32, model.AreaId); _db.AddInParameter(dc, "AreaName", DbType.String, model.AreaName); _db.AddInParameter(dc, "AreaType", DbType.Byte, (int)model.AreaType); _db.AddInParameter(dc, "ScenicId", DbType.String, model.ScenicId); return(DbHelper.ExecuteSql(dc, _db) > 0 ? 1 : -1); }
/// <summary> /// ajax_页面保存 /// </summary> protected void PageSave(string id) { StringBuilder strMsg = new StringBuilder(); IPeerNews BLL = BPeerNews.CreateInstance(); MPeerNews Model; if (string.IsNullOrEmpty(id)) { //新增 Model = new MPeerNews(); strMsg.Append(this.CommonModel(Model)); Model.IssueTime = DateTime.Now; if (strMsg.Length == 0 && BLL.AddPeerNews(Model) == 1) { strMsg.Append("添加成功!"); } else { strMsg.Remove(0, strMsg.Length); strMsg.Append("添加失败!"); }; } else { //修改 Model = BLL.GetPeerNews(id); strMsg.Append(this.CommonModel(Model)); Model.LastUpdateTime = DateTime.Now; if (strMsg.Length == 0 && BLL.CustomerUpdatePeerNews(Model) == 1) { strMsg.Append("更新成功!"); } else { strMsg.Remove(0, strMsg.Length); strMsg.Append("更新失败!"); } } Response.Clear(); Response.Write(strMsg.ToString()); Response.End(); }
/// <summary> /// 获取同业资讯列表 /// </summary> /// <param name="topNum">top数量</param> /// <param name="queryModel">查询实体</param> /// <returns>返回同业资讯信息集合</returns> public IList <MPeerNews> GetGetPeerNewsList(int topNum, MQueryPeerNews queryModel) { var strSql = new StringBuilder(); strSql.Append(" select "); if (topNum > 0) { strSql.AppendFormat(" top {0} ", topNum); } strSql.Append( @" [NewId],[Title],[TypeId],[Content],[CompanyId],[CompanyName],[OperatorId],[OperatorName] ,[B2BDisplay],[SortId],[ClickNum],[IP],[IssueTime],[LastUpdateTime],[MQ],[AreaId],[AreaName],[AreaType],[ScenicId] "); strSql.Append(" from view_PeerNewsUserInfo "); strSql.Append(" where 1 = 1 "); if (queryModel != null) { if (!string.IsNullOrEmpty(queryModel.CompanyId)) { strSql.AppendFormat(" and [CompanyId] = '{0}' ", queryModel.CompanyId); } if (!string.IsNullOrEmpty(queryModel.Title)) { strSql.AppendFormat(" and [Title] like '%{0}%' ", queryModel.Title); } if (!string.IsNullOrEmpty(queryModel.KeyWord)) { strSql.AppendFormat(" and isnull([Title],'') + isnull([CompanyName],'') like '%{0}%' ", queryModel.KeyWord); } if (queryModel.TypeId.HasValue) { strSql.AppendFormat(" and [TypeId] = {0} ", (int)queryModel.TypeId.Value); } if (!queryModel.IsShowHideNew) { strSql.AppendFormat(" and [B2BDisplay] <> {0} ", (int)NewsB2BDisplay.隐藏); } strSql.Append(" order by "); switch (queryModel.OrderIndex) { case 0: strSql.Append(" LastUpdateTime desc "); break; case 1: strSql.Append(" LastUpdateTime asc "); break; case 2: strSql.Append(" IssueTime desc "); break; case 3: strSql.Append(" IssueTime asc "); break; case 4: strSql.Append(" B2BDisplay desc,SortId asc,IssueTime desc "); break; case 5: strSql.Append(" B2BDisplay asc,SortId desc,IssueTime asc "); break; default: strSql.Append(" LastUpdateTime desc "); break; } } DbCommand dc = _db.GetSqlStringCommand(strSql.ToString()); IList <MPeerNews> list; using (IDataReader dr = DbHelper.ExecuteReader(dc, _db)) { list = new List <MPeerNews>(); while (dr.Read()) { var model = new MPeerNews(); if (!dr.IsDBNull(dr.GetOrdinal("NewId"))) { model.NewId = dr.GetString(dr.GetOrdinal("NewId")); } if (!dr.IsDBNull(dr.GetOrdinal("Title"))) { model.Title = dr.GetString(dr.GetOrdinal("Title")); } if (!dr.IsDBNull(dr.GetOrdinal("TypeId"))) { model.TypeId = (PeerNewType)dr.GetByte(dr.GetOrdinal("TypeId")); } if (!dr.IsDBNull(dr.GetOrdinal("Content"))) { model.Content = dr.GetString(dr.GetOrdinal("Content")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyId"))) { model.CompanyId = dr.GetString(dr.GetOrdinal("CompanyId")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyName"))) { model.CompanyName = dr.GetString(dr.GetOrdinal("CompanyName")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorId"))) { model.OperatorId = dr.GetString(dr.GetOrdinal("OperatorId")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorName"))) { model.OperatorName = dr.GetString(dr.GetOrdinal("OperatorName")); } if (!dr.IsDBNull(dr.GetOrdinal("B2BDisplay"))) { model.B2BDisplay = (NewsB2BDisplay)dr.GetByte(dr.GetOrdinal("B2BDisplay")); } if (!dr.IsDBNull(dr.GetOrdinal("SortId"))) { model.SortId = dr.GetInt32(dr.GetOrdinal("SortId")); } if (!dr.IsDBNull(dr.GetOrdinal("ClickNum"))) { model.ClickNum = dr.GetInt32(dr.GetOrdinal("ClickNum")); } if (!dr.IsDBNull(dr.GetOrdinal("IP"))) { model.Ip = dr.GetString(dr.GetOrdinal("IP")); } if (!dr.IsDBNull(dr.GetOrdinal("IssueTime"))) { model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); } if (!dr.IsDBNull(dr.GetOrdinal("LastUpdateTime"))) { model.LastUpdateTime = dr.GetDateTime(dr.GetOrdinal("LastUpdateTime")); } if (!dr.IsDBNull(dr.GetOrdinal("MQ"))) { model.OperatorMQ = dr.GetString(dr.GetOrdinal("MQ")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaId"))) { model.AreaId = dr.GetInt32(dr.GetOrdinal("AreaId")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaName"))) { model.AreaName = dr.GetString(dr.GetOrdinal("AreaName")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaType"))) { model.AreaType = (Model.SystemStructure.AreaType)dr.GetByte(dr.GetOrdinal("AreaType")); } if (!dr.IsDBNull(dr.GetOrdinal("ScenicId"))) { model.ScenicId = dr.GetString(dr.GetOrdinal("ScenicId")); } list.Add(model); } } return(list); }
/// <summary> /// 获取同业资讯列表 /// </summary> /// <param name="pageSize">每页记录数</param> /// <param name="pageIndex">当前页数</param> /// <param name="recordCount">总记录数</param> /// <param name="queryModel">查询实体</param> /// <returns>返回同业资讯信息集合</returns> public IList <MPeerNews> GetGetPeerNewsList(int pageSize, int pageIndex, ref int recordCount , MQueryPeerNews queryModel) { string fileds = @" [NewId] ,[Title],[TypeId],[Content],[CompanyId],[CompanyName],[OperatorId],[OperatorName],[B2BDisplay],[SortId] ,[ClickNum],[IP],[IssueTime],[LastUpdateTime],[MQ],[AreaId],[AreaName],[AreaType],[ScenicId] "; string tableName = "view_PeerNewsUserInfo"; string orderby = " LastUpdateTime desc "; var strWhere = new StringBuilder(" 1 = 1 "); if (queryModel != null) { if (!string.IsNullOrEmpty(queryModel.CompanyId)) { strWhere.AppendFormat(" and [CompanyId] = '{0}' ", queryModel.CompanyId); } if (!string.IsNullOrEmpty(queryModel.Title)) { strWhere.AppendFormat(" and [Title] like '%{0}%' ", queryModel.Title); } if (!string.IsNullOrEmpty(queryModel.KeyWord)) { strWhere.AppendFormat(" and isnull([Title],'') + isnull([CompanyName],'') like '%{0}%' ", queryModel.KeyWord); } if (queryModel.TypeId.HasValue) { strWhere.AppendFormat(" and [TypeId] = {0} ", (int)queryModel.TypeId.Value); } if (!queryModel.IsShowHideNew) { strWhere.AppendFormat(" and [B2BDisplay] <> {0} ", (int)NewsB2BDisplay.隐藏); } switch (queryModel.OrderIndex) { case 0: orderby = " LastUpdateTime desc "; break; case 1: orderby = " LastUpdateTime asc "; break; case 2: orderby = " IssueTime desc "; break; case 3: orderby = " IssueTime asc "; break; case 4: orderby = " B2BDisplay desc,SortId asc,IssueTime desc "; break; case 5: orderby = " B2BDisplay asc,SortId desc,IssueTime asc "; break; default: orderby = " LastUpdateTime desc "; break; } } IList <MPeerNews> list; using (IDataReader dr = DbHelper.ExecuteReader(_db, pageSize, pageIndex, ref recordCount , tableName, "NewId", fileds, strWhere.ToString(), orderby)) { list = new List <MPeerNews>(); while (dr.Read()) { var model = new MPeerNews(); if (!dr.IsDBNull(dr.GetOrdinal("NewId"))) { model.NewId = dr.GetString(dr.GetOrdinal("NewId")); } if (!dr.IsDBNull(dr.GetOrdinal("Title"))) { model.Title = dr.GetString(dr.GetOrdinal("Title")); } if (!dr.IsDBNull(dr.GetOrdinal("TypeId"))) { model.TypeId = (PeerNewType)dr.GetByte(dr.GetOrdinal("TypeId")); } if (!dr.IsDBNull(dr.GetOrdinal("Content"))) { model.Content = dr.GetString(dr.GetOrdinal("Content")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyId"))) { model.CompanyId = dr.GetString(dr.GetOrdinal("CompanyId")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyName"))) { model.CompanyName = dr.GetString(dr.GetOrdinal("CompanyName")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorId"))) { model.OperatorId = dr.GetString(dr.GetOrdinal("OperatorId")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorName"))) { model.OperatorName = dr.GetString(dr.GetOrdinal("OperatorName")); } if (!dr.IsDBNull(dr.GetOrdinal("B2BDisplay"))) { model.B2BDisplay = (NewsB2BDisplay)dr.GetByte(dr.GetOrdinal("B2BDisplay")); } if (!dr.IsDBNull(dr.GetOrdinal("SortId"))) { model.SortId = dr.GetInt32(dr.GetOrdinal("SortId")); } if (!dr.IsDBNull(dr.GetOrdinal("ClickNum"))) { model.ClickNum = dr.GetInt32(dr.GetOrdinal("ClickNum")); } if (!dr.IsDBNull(dr.GetOrdinal("IP"))) { model.Ip = dr.GetString(dr.GetOrdinal("IP")); } if (!dr.IsDBNull(dr.GetOrdinal("IssueTime"))) { model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); } if (!dr.IsDBNull(dr.GetOrdinal("LastUpdateTime"))) { model.LastUpdateTime = dr.GetDateTime(dr.GetOrdinal("LastUpdateTime")); } if (!dr.IsDBNull(dr.GetOrdinal("MQ"))) { model.OperatorMQ = dr.GetString(dr.GetOrdinal("MQ")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaId"))) { model.AreaId = dr.GetInt32(dr.GetOrdinal("AreaId")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaName"))) { model.AreaName = dr.GetString(dr.GetOrdinal("AreaName")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaType"))) { model.AreaType = (Model.SystemStructure.AreaType)dr.GetByte(dr.GetOrdinal("AreaType")); } if (!dr.IsDBNull(dr.GetOrdinal("ScenicId"))) { model.ScenicId = dr.GetString(dr.GetOrdinal("ScenicId")); } list.Add(model); } } return(list); }
/// <summary> /// 获取同业资讯信息 /// </summary> /// <param name="newId">资讯编号</param> /// <returns>返回同业资讯信息实体</returns> public MPeerNews GetPeerNews(string newId) { MPeerNews model = null; if (string.IsNullOrEmpty(newId)) { return(model); } var strSql = new StringBuilder(); strSql.Append(SqlPeerNewsSelect); strSql.Append(" where [NewId] = @NewId order by LastUpdateTime desc ; "); strSql.Append(SqlPeerNewsAttachInfoSelect); strSql.Append(" where [NewId] = @NewId order by Type desc ; "); DbCommand dc = _db.GetSqlStringCommand(strSql.ToString()); _db.AddInParameter(dc, "NewId", DbType.AnsiStringFixedLength, newId); model = new MPeerNews(); using (IDataReader dr = DbHelper.ExecuteReader(dc, _db)) { if (dr.Read()) { if (!dr.IsDBNull(dr.GetOrdinal("NewId"))) { model.NewId = dr.GetString(dr.GetOrdinal("NewId")); } if (!dr.IsDBNull(dr.GetOrdinal("Title"))) { model.Title = dr.GetString(dr.GetOrdinal("Title")); } if (!dr.IsDBNull(dr.GetOrdinal("TypeId"))) { model.TypeId = (PeerNewType)dr.GetByte(dr.GetOrdinal("TypeId")); } if (!dr.IsDBNull(dr.GetOrdinal("Content"))) { model.Content = dr.GetString(dr.GetOrdinal("Content")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyId"))) { model.CompanyId = dr.GetString(dr.GetOrdinal("CompanyId")); } if (!dr.IsDBNull(dr.GetOrdinal("CompanyName"))) { model.CompanyName = dr.GetString(dr.GetOrdinal("CompanyName")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorId"))) { model.OperatorId = dr.GetString(dr.GetOrdinal("OperatorId")); } if (!dr.IsDBNull(dr.GetOrdinal("OperatorName"))) { model.OperatorName = dr.GetString(dr.GetOrdinal("OperatorName")); } if (!dr.IsDBNull(dr.GetOrdinal("B2BDisplay"))) { model.B2BDisplay = (NewsB2BDisplay)dr.GetByte(dr.GetOrdinal("B2BDisplay")); } if (!dr.IsDBNull(dr.GetOrdinal("SortId"))) { model.SortId = dr.GetInt32(dr.GetOrdinal("SortId")); } if (!dr.IsDBNull(dr.GetOrdinal("ClickNum"))) { model.ClickNum = dr.GetInt32(dr.GetOrdinal("ClickNum")); } if (!dr.IsDBNull(dr.GetOrdinal("IP"))) { model.Ip = dr.GetString(dr.GetOrdinal("IP")); } if (!dr.IsDBNull(dr.GetOrdinal("IssueTime"))) { model.IssueTime = dr.GetDateTime(dr.GetOrdinal("IssueTime")); } if (!dr.IsDBNull(dr.GetOrdinal("LastUpdateTime"))) { model.LastUpdateTime = dr.GetDateTime(dr.GetOrdinal("LastUpdateTime")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaId"))) { model.AreaId = dr.GetInt32(dr.GetOrdinal("AreaId")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaName"))) { model.AreaName = dr.GetString(dr.GetOrdinal("AreaName")); } if (!dr.IsDBNull(dr.GetOrdinal("AreaType"))) { model.AreaType = (Model.SystemStructure.AreaType)dr.GetByte(dr.GetOrdinal("AreaType")); } if (!dr.IsDBNull(dr.GetOrdinal("ScenicId"))) { model.ScenicId = dr.GetString(dr.GetOrdinal("ScenicId")); } } dr.NextResult(); model.AttachInfo = new List <MPeerNewsAttachInfo>(); MPeerNewsAttachInfo modelInfo; while (dr.Read()) { modelInfo = new MPeerNewsAttachInfo(); if (!dr.IsDBNull(dr.GetOrdinal("Id"))) { modelInfo.Id = dr.GetString(dr.GetOrdinal("Id")); } if (!dr.IsDBNull(dr.GetOrdinal("Type"))) { modelInfo.Type = (AttachInfoType)dr.GetByte(dr.GetOrdinal("Type")); } if (!dr.IsDBNull(dr.GetOrdinal("Path"))) { modelInfo.Path = dr.GetString(dr.GetOrdinal("Path")); } if (!dr.IsDBNull(dr.GetOrdinal("FileName"))) { modelInfo.FileName = dr.GetString(dr.GetOrdinal("FileName")); } if (!dr.IsDBNull(dr.GetOrdinal("Remark"))) { modelInfo.Remark = dr.GetString(dr.GetOrdinal("Remark")); } model.AttachInfo.Add(modelInfo); } } return(model); }
protected void initData(string id) { if (string.IsNullOrEmpty(id)) { return; } IPeerNews BLL = BPeerNews.CreateInstance(); MPeerNews Model = BLL.GetPeerNews(id); if (null == Model) { return; } this.lbTitle.Text = Model.Title;//标 题 //资讯相关 EyouSoft.BLL.CompanyStructure.CompanyInfo companyBLL = new EyouSoft.BLL.CompanyStructure.CompanyInfo(); CompanyDetailInfo companyModel = companyBLL.GetModel(Model.CompanyId); if (null != companyModel) { string strAboutInfo = string.Empty; if (companyModel.CompanyRole.HasRole(CompanyType.地接) || companyModel.CompanyRole.HasRole(CompanyType.专线)) { if (!string.IsNullOrEmpty(Model.AreaName)) { //2012-02-10 14:10信息来源:楼 链接到组团菜单中的"旅游线路库" strAboutInfo = string.Format(@"<a href='javascript:void(0)' onclick=""topTab.open('{0}','资讯相关',{{}})"" class='font12_grean' title='{1}'>{1}</a>", EyouSoft.Common.Domain.UserBackCenter + "/teamservice/linelibrarylist.aspx?lineId=" + Model.AreaId, Model.AreaName); } } else if (companyModel.CompanyRole.HasRole(CompanyType.景区)) { EyouSoft.Model.ScenicStructure.MScenicArea Area = new EyouSoft.BLL.ScenicStructure.BScenicArea().GetModel(Model.ScenicId); if (null != Area) { strAboutInfo = string.Format("<a href='{0}' target='_blank'>{1}</a>", EyouSoft.Common.Domain.UserPublicCenter + "/ScenicManage/NewScenicDetails.aspx?ScenicId=" + Area.ScenicId, Area.ScenicName); } } this.lbRoute.Text = strAboutInfo.Length > 0 ? strAboutInfo : "暂无"; } this.lbCompany.Text = Model.CompanyName; //发布企业 this.lbType.Text = Convert.ToString(Model.TypeId); //类别 this.lbTime.Text = string.Format("{0:yyyy-MM-dd}", Model.IssueTime); //发布时间 this.lbContent.Text = Model.Content; //内容 IList <MPeerNewsAttachInfo> lst = Model.AttachInfo; StringBuilder strPic = new StringBuilder(); StringBuilder strFile = new StringBuilder(); if (null != lst && lst.Count > 0) { for (int i = 0; i < lst.Count; i++) { switch (lst[i].Type) { case AttachInfoType.图片: strPic.AppendFormat("<a href='{0}' title='{1}' target='_blank'>查看</a>", Domain.FileSystem + lst[i].Path, lst[i].FileName); break; case AttachInfoType.文件: strFile.AppendFormat("<a href='{0}' title='{1}' target='blank'>{2}</a>", Domain.FileSystem + lst[i].Path, lst[i].FileName, lst[i].FileName); break; } } } this.lbPic.Text = strPic.Length > 0 ? strPic.ToString() : "暂无图片"; //图片 this.lbFile.Text = strFile.Length > 0 ? strFile.ToString() : "暂无附件"; //附件下载 //点击次数加1 BLL.UpdateClickNum(id); }
/// <summary> /// 初始化 /// </summary> protected void InitData(string id) { ////相关专线、相关酒店、相关景区初始化值 string selInfoValue = string.Empty; //分类 this.ddlType.DataSource = EnumObj.GetList(typeof(EyouSoft.Model.NewsStructure.PeerNewType)); this.ddlType.DataTextField = "text"; this.ddlType.DataValueField = "value"; this.ddlType.DataBind(); //编辑初始化 if (!string.IsNullOrEmpty(id)) { IPeerNews BLL = BPeerNews.CreateInstance(); MPeerNews Model = BLL.GetPeerNews(id); if (null == Model) { return; } this.txtTitle.Value = Model.Title;//标题 //相关专线、相关酒店、相关景区 selInfoValue = Model.AreaId.ToString(); this.ddlType.SelectedValue = Convert.ToString((int)Model.TypeId); //分类 this.txtContent.Value = Model.Content; //内容 IList <MPeerNewsAttachInfo> lst = Model.AttachInfo; if (null != lst && lst.Count > 0) { StringBuilder strPic = new StringBuilder(); StringBuilder strFile = new StringBuilder(); StringBuilder strPicHidden = new StringBuilder(); StringBuilder strFileHidden = new StringBuilder(); for (int i = 0; i < lst.Count; i++) { switch (lst[i].Type) { case AttachInfoType.图片: strPic.AppendFormat("<a href='{0}' title='{1}' target='_blank'>查看</a><a href=\"javascript:void(0);\" onclick=\"NewsList.delFile(this,'pic');\"><img src='{2}/images/fujian_x.gif' border='0'/></a>", Domain.FileSystem + lst[i].Path, lst[i].FileName, this.ImageServerUrl); strPicHidden.AppendFormat(lst[i].Path + ","); break; case AttachInfoType.文件: strFile.AppendFormat("<a href='{0}' title='{1}' target='blank'>{1}</a><a href=\"javascript:void(0);\" onclick=\"NewsList.delFile(this,'file');\"><img src='{2}/images/fujian_x.gif' border='0'/></a>", Domain.FileSystem + lst[i].Path, lst[i].FileName, this.ImageServerUrl); strFileHidden.AppendFormat("{0}|{1},", lst[i].FileName, lst[i].Path); break; } } if (strPicHidden.Length > 0) { strPicHidden.Remove(strPicHidden.Length - 1, 1); } if (strFileHidden.Length > 0) { strFileHidden.Remove(strFileHidden.Length - 1, 1); } MessageBox.ResponseScript(this, string.Format("NewsList.setUploadHiddenValue('{0}','pic');NewsList.setUploadHiddenValue('{1}','file');", strPicHidden, strFileHidden)); this.lbPic.Text = strPic.Length > 0 ? strPic.ToString() : ""; //图片 this.lbFile.Text = strFile.Length > 0 ? strFile.ToString() : ""; //附件下载 } } this.getSelectInfo(selInfoValue); //this.InitTypeName(); }
/// <summary> /// 编辑与添加的公共model部分 /// </summary> protected string CommonModel(MPeerNews Model) { StringBuilder str = new StringBuilder(); string txtTitle = Utils.GetFormValue(this.txtTitle.UniqueID).Trim(); //标题 string[] selectInfo = Utils.GetFormValue("selectInfo").Split('|'); //相关专线、相关地接、相关景区ID string selectInfoName = Utils.GetFormValue("selectInfoName"); //相关专线、相关地接、相关景区Name int ddlType = Utils.GetInt(Utils.GetFormValue(this.ddlType.UniqueID), -1); //分 类 string txtContent = Utils.EditInputText(Request.Form[this.txtContent.UniqueID]); //内容 string[] picPath = Utils.GetFormValue(this.filePic.UniqueID + "$hidFileName").Split(','); //已上传的图片路径 ,多个用逗号隔开 string[] filePath = Utils.GetFormValue(this.files.UniqueID + "$hidFileName").Split(','); //已上传的附件路径 ,多个用逗号隔开 /*数据验证开始*/ if (string.IsNullOrEmpty(txtTitle)) { str.Append("标题不能为空!\\n"); } if (string.IsNullOrEmpty(txtContent)) { str.Append("内容不能为空!\\n"); } if (str.Length > 0) { return(str.ToString()); } /*数据验证结束*/ Model.CompanyId = this.SiteUserInfo.CompanyID; Model.CompanyName = this.SiteUserInfo.CompanyName; Model.Content = txtContent; Model.Ip = StringValidate.GetRemoteIP(); if (this.SiteUserInfo.CompanyRole.HasRole(EyouSoft.Model.CompanyStructure.CompanyType.专线) || this.SiteUserInfo.CompanyRole.HasRole(EyouSoft.Model.CompanyStructure.CompanyType.地接)) { if (selectInfo.Length == 2) { Model.AreaId = Utils.GetInt(selectInfo[0]); Model.AreaType = (AreaType)Utils.GetInt(selectInfo[1]); } else { Model.AreaId = Utils.GetInt(selectInfo[0]); } } else if (this.SiteUserInfo.CompanyRole.HasRole(EyouSoft.Model.CompanyStructure.CompanyType.景区)) { Model.ScenicId = selectInfo[0]; } Model.AreaName = selectInfoName; Model.OperatorId = this.SiteUserInfo.ID; Model.OperatorName = this.SiteUserInfo.UserName; Model.Title = txtTitle; Model.TypeId = (PeerNewType)ddlType; /*文件上传开始*/ List <MPeerNewsAttachInfo> lstFile = new List <MPeerNewsAttachInfo>(); //图片 if (picPath.Length > 0) { for (int i = 0; i < picPath.Length; i++) { if (string.IsNullOrEmpty(picPath[i])) { break; } MPeerNewsAttachInfo picModel = new MPeerNewsAttachInfo(); picModel.FileName = picPath[i].Substring(picPath[i].LastIndexOf('/') + 1); picModel.Path = picPath[i]; picModel.Type = AttachInfoType.图片; lstFile.Add(picModel); } } //附件 if (filePath.Length > 0) { for (int i = 0; i < filePath.Length; i++) { if (string.IsNullOrEmpty(filePath[i])) { break; } MPeerNewsAttachInfo fileModel = new MPeerNewsAttachInfo(); if (filePath[i].IndexOf('|') > 0) { string[] strFileInfo = filePath[i].Split('|'); fileModel.FileName = strFileInfo[0]; fileModel.Path = strFileInfo[1]; } else { fileModel.FileName = filePath[i].Substring(filePath[i].LastIndexOf('/')); fileModel.Path = filePath[i]; } fileModel.Type = AttachInfoType.文件; lstFile.Add(fileModel); } } Model.AttachInfo = lstFile.Count == 0 ? null : lstFile; /*文件上传结束*/ return(str.ToString()); }