public ActionResult Delete(int id) { AjaxResult result = new AjaxResult(); try { NewsClass entity = m_FTISService.GetNewsClassById(id); //檢查底下的News數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("NewsClassId", id.ToString()); int subsCount = m_FTISService.GetNewsCount(conditions); if (subsCount > 0) { return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有新聞,不可刪除。", entity.Name)))); } m_FTISService.DeleteNewsClass(entity); result.ErrorCode = AjaxResultStatus.Success; result.Message = string.Format("{0}刪除成功", entity.Name); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Exception; result.Message = ex.Message; } return(this.Json(result)); }
protected void btnsave_ServerClick(object sender, EventArgs e) { ClNews cl = new ClNews(); cl.Comment = txtcontent.Value; cl.RegUser = Convert.ToInt32(CSharp.PublicFunction.GetUserID()); cl.NewID = Convert.ToInt32(lblNewsID.Text); int i = 0; if (lblNewsID.Text == "0") { i = NewsClass.insert(cl); } else { i = NewsClass.Update(cl); } if (i == 0) { TerraficPlanBLL.Utility.ShowMsg(Page, ProPertyData.MsgType.warning, "خطا در ثبت"); } else { TerraficPlanBLL.Utility.ShowMsg(Page, ProPertyData.MsgType.General_Success, "درج انجام شد"); } }
/// <summary> /// 招生专题单页 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult singleEnrol(int id) { var singlePageClass = _isectionService.getNewsClassByID(id); var parentClass = _isectionService.getNewsClassByID(singlePageClass.ParentID); #region 位置导航 NewsClass curentSectionParent = null; if (singlePageClass.ParentID != 0) { curentSectionParent = _isectionService.getNewsClassByID(singlePageClass.ParentID); } var nav = ""; ViewBag.parentName = ""; if (curentSectionParent != null) { nav += curentSectionParent.ClassName + "-" + singlePageClass.ClassName + ""; ViewBag.parentName = curentSectionParent.ClassName; } else { nav += singlePageClass.ClassName + ""; ViewBag.parentName = singlePageClass.ClassName; } ViewData["nav"] = nav; #endregion return(View(singlePageClass)); }
protected void Button1_Click(object sender, EventArgs e) { nClass = this.GetSelectedNews(); txtCaption.Text = nClass.NewsLabe; txtArticle.Text = nClass.Article; picNewsSource.ImageUrl = "~/ImageHandler.ashx?imgID=" + ddlNews.SelectedValue; }
protected void BtnSave_Click(object sender, EventArgs e) { NewsClass newsClass = new NewsClass(); try { if (Request.QueryString["action"] != null) { string Action = Request.QueryString["action"].ToString(); if (Action == "modify") { newsClass.ClassName = TextBox_ClassName.Text; newsClass.Summary = TextBox_Summary.Text; newsClass.ID = new Guid(Request.QueryString["ClassID"].ToString()); news.UpdateClass(newsClass, Action); //NewsPub.Show(this, "修改成功!"); NewsPub.ShowAlert("修改成功", "NewsClass_List.aspx"); } } else { newsClass.ClassName = TextBox_ClassName.Text; newsClass.Summary = TextBox_Summary.Text; news.InsertClass(newsClass, ""); NewsPub.Show(this, "添加成功!"); TextBox_ClassName.Text = ""; TextBox_Summary.Text = ""; } } catch (Exception EX) { Label_Message.Text = EX.Message; } }
public ActionResult Index() { NewsClass objNews = new NewsClass(); var news = objNews.getLatestNews(); return(View(news)); }
public List <NewsClass> GetAllNews(int id) { int ShowRecords = 20; int skip = id * ShowRecords; var DesiMasala = ""; var AllRecords = obj.News.Count(); int max = (skip + ShowRecords); if (max > AllRecords) { max = AllRecords; } DesiMasala = (skip + 1).ToString() + "-" + max.ToString() + "/" + AllRecords.ToString(); List <NewsClass> li = new List <NewsClass>(); var AllNews = obj.News.Skip(skip).Take(ShowRecords).Where(x => x.status != 0).ToList(); var count = AllNews.Count(); foreach (var details in AllNews) { NewsClass temp = new NewsClass(); temp.Id = details.Id; temp.Title = details.Title; temp.Description = details.Description; temp.Image = details.Image; temp.Count = count; temp.NumberOfShowing = DesiMasala; li.Add(temp); } return(li); }
public CommentsPage(NewsClass GetNew) { InitializeComponent(); comments = new ObservableCollection <Comments>(); news = GetNew; this.DataContext = this; }
public void InsertClass(NewsClass newsClass, string Action) { if (newsClass == null) { throw new ArgumentNullException("newsClass"); } SqlParameter[] insertParam = InitNewsClass(newsClass, ""); m_SqlHelper.ExecuteNoneQuery(sql_Insert, insertParam); }
public void UpdateClass(NewsClass newsClass, string Action) { if (newsClass == null) { throw new ArgumentNullException("newsClass"); } SqlParameter[] updateParam = InitNewsClass(newsClass, "modify"); m_SqlHelper.ExecuteNoneQuery(sql_UpdateById, updateParam); }
protected void button1_Click(object sender, EventArgs e) { DateTime dt = Convert.ToDateTime(TextBox3.Text); DateTime dt1 = Convert.ToDateTime(TextBox4.Text); NewsClass news = new NewsClass(TextBox1.Text, TextBox2.Text, dt, dt1); string result = ConnectionClass.AddNews(news); lblresult.Text = result; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ClNews cl = new ClNews(); DataSet ds = NewsClass.GetList(cl); lblnews.Text = ds.Tables[0].Rows[0]["CommentClear"].ToString(); ds.Dispose(); } }
public void DeleteClass(NewsClass newsClass) { if (newsClass == null) { throw new ArgumentNullException("newsClass"); } SqlParameter paramClassId = new SqlParameter(param_ID, SqlDbType.VarChar, 34); paramClassId.Value = newsClass.ID; m_SqlHelper.ExecuteNoneQuery(sql_DelById, new SqlParameter[] { paramClassId }); }
private NewsClass CreateNewsClass(string name) { NewsClass newsClass = new NewsClass() { Name = name, LangId = "2", SortId = 250, Status = "1" }; m_FTISService.CreateNewsClass(newsClass); Assert.AreNotEqual(0, newsClass.NewsClassId); return(newsClass); }
protected void LoadEntity(NewsClass entity) { if (entity != null) { EntityId = entity.NewsClassId; Name = entity.Name; NameENG = entity.NameENG; SortId = entity.SortId; Status = entity.Status; } }
private void BindNews() { ClNews cl = new ClNews(); DataSet ds = NewsClass.GetList(cl); if (ds.Tables[0].Rows.Count > 0) { DataRow DR = ds.Tables[0].Rows[0]; txtcontent.Value = DR["Comment"].ToString().Replace("<_", "<").Replace("_>", ">"); lblNewsID.Text = DR["NewID"].ToString(); } }
NewsClass DataRowNewsClass(DataRow dataRow) { if (dataRow == null) { throw new ArgumentNullException("dataRow"); } string Id = dataRow[col_ID].ToString(); string className = dataRow[col_ClassName].ToString(); string summary = dataRow[col_Summary].ToString(); NewsClass news = new NewsClass(new Guid(Id), className, summary); return(news); }
public NewsClass CreateNews(NewsCreateViewModel inputModel, string authorId) { var news = new NewsClass { Title = inputModel.Title, Content = inputModel.Content, PublishedOn = DateTime.Now, AuthorId = authorId }; this.db.News.Add(news); this.db.SaveChanges(); return(news); }
public static string AddNews(NewsClass news) { try { conn.Open(); string query = string.Format("INSERT into NewsManagement VALUES ('{0}','{1}','{2}','{3}')", news.NewsHeadlines, news.NewsDetails, news.ExpiryDate, news.PublishDate); com.CommandText = query; com.ExecuteNonQuery(); return("News Added Succesfully"); } finally { conn.Close(); } }
public void Test_NewsClass() { //新增 string name = "新增NewsClass測試aaaaaaaaaa"; NewsClass newsClass = CreateNewsClass(name); //更新 string updateName = "更新NewsClass測試bbbbbbbbb"; NewsClass updateNewsClass = m_FTISService.GetNewsClassById(newsClass.NewsClassId); Assert.AreEqual(name, updateNewsClass.Name); updateNewsClass.Name = updateName; m_FTISService.UpdateNewsClass(updateNewsClass); //查詢 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("Name", updateName); conditions.Add("Status", "1"); IList <NewsClass> newsClassList = m_FTISService.GetNewsClassList(conditions); Assert.AreEqual(1, newsClassList.Count); Assert.AreEqual(1, m_FTISService.GetNewsClassCount(conditions)); Assert.AreEqual(updateName, newsClassList[0].Name); conditions = new Dictionary <string, string>(); conditions.Add("Name", name); conditions.Add("Status", "1"); newsClassList = m_FTISService.GetNewsClassList(conditions); Assert.AreEqual(0, newsClassList.Count); Assert.AreEqual(0, m_FTISService.GetNewsClassCount(conditions)); conditions = new Dictionary <string, string>(); conditions.Add("Name", updateName); conditions.Add("Status", "0"); newsClassList = m_FTISService.GetNewsClassList(conditions); Assert.AreEqual(1, newsClassList.Count); Assert.AreEqual(1, m_FTISService.GetNewsClassCount(conditions)); //刪除 m_FTISService.DeleteNewsClass(updateNewsClass); conditions = new Dictionary <string, string>(); conditions.Add("Name", updateName); conditions.Add("Status", "1"); newsClassList = m_FTISService.GetNewsClassList(conditions); Assert.AreEqual(0, newsClassList.Count); Assert.AreEqual(0, m_FTISService.GetNewsClassCount(conditions)); }
public static NEWS CreateNews(Entities e, NewsClass news) { NEWS _News = new NEWS() { NEWS_ID = e.NEWS.Max(n => n.NEWS_ID) + 1, USER_ID = news.userId, TYPE = news.type, NEWS_SUB_CAT_ID = news.subcategory.id, TITLE = news.title, HEADLINE = news.headLine, SHARABLE = news.sharable ? short.Parse("1") : short.Parse("2"), CREATION_DATE = DateTime.Now, EVENT_DATE = news.eventDate, VOTE_COUNT = 1, VOTE_RESULT = 1, VOTE_TYPE = 1, HIERARCHY_TYPE = 1, USERS = e.USERS.FirstOrDefault(u => u.USER_ID == news.userId), NEWS_SUB_CATS = e.NEWS_SUB_CATS.FirstOrDefault(n => n.NEWS_SUB_CAT_ID == news.subcategory.id), APPROVED = new UserPrivateInfoClass(news.userId).needApprove, ACCESSIBILITY = news.privateNewsType == 0 ? 1 : 2 }; processFKForNEWS_IDAndNEWS_MEDIA(e); int offset = e.NEWS_MEDIAS.Max(n => n.NEWS_MEDIA_ID) + 1; if (news.body != null) { _News.NEWS_MEDIAS.Add(new NEWS_MEDIAS() { NEWS_MEDIA_ID = offset, NEWS_ID = _News.NEWS_ID, BODY = news.body, TYPE = 1 }); if (news.newsImage != null) { offset++; } } if (news.newsImage != null) { _News.NEWS_MEDIAS.Add(new NEWS_MEDIAS() { NEWS_MEDIA_ID = offset, NEWS_ID = _News.NEWS_ID, ATTACH = news.newsImage, TYPE = 2, NAME = "No Name.jpg" }); } return(_News); }
public int UpdateNews(NewsClass NC) { int check = 0; try { New news = obj.News.First(x => x.Id.Equals(NC.Id)); news.Title = NC.Title; news.Description = NC.Description; news.status = 1; obj.SubmitChanges(); check = news.Id; } catch (Exception e) { check = 0; } return(check); }
private void Save(NewsClass entity) { entity.Name = Name; entity.NameENG = NameENG; entity.SortId = SortId; entity.Status = Status; if (entity.NewsClassId == 0) { m_FTISService.CreateNewsClass(entity); } else { m_FTISService.UpdateNewsClass(entity); } LoadEntity(entity.NewsClassId); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["action"] != null) { string Action = Request.QueryString["action"].ToString(); if (Action == "modify") { string ClassId = Request.QueryString["ClassID"].ToString(); NewsClass newsClass = news.GetClassById(ClassId); TextBox_ClassName.Text = newsClass.ClassName; TextBox_Summary.Text = newsClass.Summary; BtnSave.Text = "修改类别"; } } } }
public int PostNews(NewsClass NC) { int check = 0; try { New news = new New(); news.Title = NC.Title; news.Description = NC.Description; news.status = 1; news.AddDate = DateTime.Now.ToShortDateString(); obj.News.InsertOnSubmit(news); obj.SubmitChanges(); check = news.Id; } catch (Exception e) { check = 0; } return(check); }
public ActionResult AddSection(int ParentID = 0, int id = 0) { #region 访问权限 var user = (Maticsoft.Model.User_Info)ViewBag.curentUser; var curentUser = _iuserService.getUserByID(user.Id); var ManagePermission = curentUser.UserGroup.ManagePermission; List <string> managePermissionstr = new List <string>(ManagePermission.Split(',')); var managePermission = managePermissionstr.Select(x => Convert.ToInt32(x)).ToList(); if (curentUser.UserGroupID != 1) { if (!managePermission.Contains((int)SortEnum.sortClass.newsManage)) { return(new RedirectResult("/Home/deny")); } } #endregion var pId = -1; var model = new NewsClass(); if (id != 0)//编辑 { model = _isectionService.getNewsClassByID(id); model.ClassName = HttpUtility.HtmlDecode(model.ClassName); model.linkAddress = HttpUtility.HtmlDecode(model.linkAddress); model.NaviContent = HttpUtility.HtmlDecode(model.NaviContent); model.PageContent = HttpUtility.HtmlDecode(model.PageContent); pId = model.ParentID; } var parentid = Request.QueryString["ParentID"] == null ? 0 : int.Parse(Request.QueryString["ParentID"]); if ((ParentID == 0 && id == 0) || pId == 0) { ViewBag.isLevelOne = true;//控制是否显示 缩略图 和 banner图 } else { ViewBag.isLevelOne = false; } return(View(model)); }
SqlParameter[] InitNewsClass(NewsClass newclass, string Action) { SqlParameter paramid = new SqlParameter(param_ID, SqlDbType.VarChar, 34); SqlParameter paramClassName = new SqlParameter(param_ClassName, SqlDbType.VarChar, 100); SqlParameter paramSummary = new SqlParameter(param_Summary, SqlDbType.VarChar, 200); if (Action == "modify") { paramid.Value = newclass.ID; } else if (Action == "") { paramid.Value = Guid.NewGuid().ToString(); } paramClassName.Value = newclass.ClassName; paramSummary.Value = newclass.Summary; return(new SqlParameter[] { paramid, paramClassName, paramSummary }); }
public List <NewsClass> GetAllNewsById(int id) { List <NewsClass> li = new List <NewsClass>(); var AllNews = obj.News.Where(x => x.status != 0 && x.Id.Equals(id)).ToList(); var count = AllNews.Count(); foreach (var details in AllNews) { NewsClass temp = new NewsClass(); temp.Id = details.Id; temp.Title = details.Title; temp.Description = details.Description; temp.Image = details.Image; temp.Count = count; li.Add(temp); } return(li); }
public static NewsClass GetNews(NEWS news, PrivateNewsType privteNewsType = PrivateNewsType.Public) { byte[] newsImage = null; string body = ""; foreach (var media in news.NEWS_MEDIAS) { if (media.ATTACH != null) { newsImage = Compression.ImageCompression(media.ATTACH, System.Drawing.Imaging.ImageFormat.Jpeg, 400); } if (media.BODY != null) { body = media.BODY; } } NewsClass newsClass = new NewsClass() { id = news.NEWS_ID, personName = news.USERS.FULL_NAME, userId = news.USERS.USER_ID, userName = news.USERS.USER_NAME, profileImage = Compression.ImageCompression(news.USERS.IMAGE, System.Drawing.Imaging.ImageFormat.Jpeg, 100), type = news.TYPE, subcategory = new SubcategoryClass(news.NEWS_SUB_CATS), privateNewsType = privteNewsType, title = news.TITLE, headLine = news.HEADLINE, sharable = news.SHARABLE == 1, creationDate = news.CREATION_DATE, eventDate = news.EVENT_DATE, newsImage = newsImage, body = body, media = news.NEWS_MEDIAS.Select(m => new ModelView.MediaClass(m)).ToList() }; return(newsClass); }
public ActionResult SetSort(string entityId, string sortValue) { AjaxResult result = new AjaxResult(AjaxResultStatus.Success, string.Empty); StringBuilder sbMsg = new StringBuilder(); try { NewsClass entity = m_FTISService.GetNewsClassById(Convert.ToInt32(entityId)); entity.SortId = int.Parse(sortValue); m_FTISService.UpdateNewsClass(entity); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat(ex.Message + "<br/>"); } result.Message = sbMsg.ToString(); return(this.Json(result)); }
public HttpResponseMessage Add(int school_id, [FromBody] NewsClass news) { try { using (Entities entities = new Entities()) { if (entities.ALLOWED_CATS.FirstOrDefault(a => a.NEWS_SUB_CAT_ID == news.subcategory.id && a.USER_ID == news.userId) == null) { return(Request.CreateResponse(HttpStatusCode.OK, new Result() { statusCode = 400, status = "You do not have permission to add news to this subcategory, please request permission from the administrator" })); } NEWS _News = NewsView.CreateNews(entities, news); _News.SCHOOL_ID = school_id; entities.NEWS.Add(_News); entities.SaveChanges(); NewsClass newNews = NewsView.GetNews(entities.NEWS.FirstOrDefault(n => n.NEWS_ID == _News.NEWS_ID)); return(Request.CreateResponse(HttpStatusCode.OK, new Result() { statusCode = 200, status = "Done", results = new List <NewsClass> { newNews } })); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new Result() { statusCode = 400, status = ex.Message })); } }
private NewsClass GetSelectedNews() { DataView newsTable = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); newsTable.RowFilter = "STY_ID = '" + ddlNews.SelectedValue + "'"; DataRowView row = (DataRowView)newsTable[0]; NewsClass n = new NewsClass(); n.ID = row["STY_ID"].ToString(); n.Article = row["STY_ARTICLE"].ToString(); n.NewsLabe = row["STY_CAPTION"].ToString(); return n; }