private void ViewNewsLog(int newsGroupID) { commonBSO commonBSO = new commonBSO(); NewsLogBSO newsLogBSO = new NewsLogBSO(); DataTable table = new DataTable(); _page = new PagingInfo(10, Convert.ToInt32(hdnPage.Value), true); table = newsLogBSO.GetNewsLogPaging(Language.language, newsGroupID, _page); if (table.Rows.Count > 0) { TotalRecord = Convert.ToInt32(table.Rows[0]["Total"].ToString()); SetAttributeGvArticle(Convert.ToInt32(table.Rows[0]["Total"].ToString())); commonBSO.FillToGridView(grvNewsLog, table); Paging.DataLoad(); if (TotalPage(Convert.ToInt32(table.Rows[0]["Total"].ToString())) <= 1) { Paging.Visible = false; } else { Paging.Visible = true; } } else { SetAttributeGvArticle(0); grvNewsLog.DataSource = null; grvNewsLog.DataBind(); Paging.Visible = false; } }
protected void btn_edit_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); newsgroupBSO.UpdateNewsGroup(newsgroup); //Add NewsCate NewsCateBSO _newscateBSO = new NewsCateBSO(); DataTable tblNewsCate = _newscateBSO.GetNewsCateByNewsGroupID(newsgroup.NewsGroupID); if (tblNewsCate.Rows.Count > 0) { _newscateBSO.DeleteNewsCatebyNewsID(newsgroup.NewsGroupID); } add_NewsCate(newsgroup.NewsGroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>"; initControl(newsgroup.NewsGroupID); ViewNewsLog(newsgroup.NewsGroupID); AspNetCache.Reset(); //ViewCateNews(Convert.ToInt32(hddGroup.Value)); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void grvNewsLog_RowCommand(object sender, GridViewCommandEventArgs e) { int Id = Convert.ToInt32(e.CommandArgument.ToString()); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog newslog = newsLogBSO.GetNewsLogById(Id); string nName = e.CommandName.ToLower(); AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); switch (nName) { case "_view": break; case "_edit": if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { // Response.Redirect("~/Admin/editnewslog/" + Id + "/Default.aspx"); Response.Redirect("~/Admin/s/EditNewsbyUser/" + hddNewsGroupID.Value + "/" + Id + "/Default.aspx"); } break; case "_delete": if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { newsLogBSO.DeleteNewsLog(Id, -1); ViewNewsLog(Convert.ToInt32(hddNewsGroupID.Value)); AspNetCache.Reset(); } break; } }
protected void btn_add_Click_more(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); //Add NewsCate add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; AspNetCache.Reset(); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
protected void btn_add_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; initControl(_newsgroupID); AspNetCache.Reset(); ViewNewsLog(_newsgroupID); //Response.Redirect("~/Admin/Group/listnewsgroup/" + hddGroup.Value + "/Default.aspx"); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
private void ViewNews(int Id) { NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog newsLog = newsLogBSO.GetNewsLogById(Id); if (newsLog != null) { ltlTitle.Text = newsLog.Title; LabelDate.Text = newsLog.PostDate.ToString("dd/MM/yyyy");// Convert.ToString(newsLog.PostDate); ltlDescribe.Text = newsLog.ShortDescribe; FullDescirbe.Text = newsLog.FullDescribe; LabelAuthor.Text = newsLog.Author; //if (newsLog.ImageThumb != "") // ltlImageThumb.Text = @"<img src='" + ResolveUrl("~/") + "Upload/newsLog/newsLogThumb/" + newsLog.ImageThumb + "' align='left' class='border_image' width='250' >"; } }
protected void btn_add_Click(object sender, EventArgs e) { try { NewsGroup newsgroup = ReceiveHtml(); NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); // MessageBox.Show(); //if (Tool.CountWords2(Tool.StripTagsCharArray(newsgroup.ShortDescribe)) > 60) //{ // String csname = "PopupScript"; // Type cstype = this.GetType(); // ClientScriptManager cs = Page.ClientScript; // if (!cs.IsStartupScriptRegistered(cstype, csname)) // { // String cstext = "Confirmation();"; // cs.RegisterStartupScript(cstype, csname, cstext, true); // } // if (hnd.Value != "") // { int _newsgroupID = newsgroupBSO.CreateNewsGroupGet(newsgroup); //Add NewsCate add_NewsCate(_newsgroupID); NewsLogBSO newsLogBSO = new NewsLogBSO(); NewsLog _newsLog = newsLogBSO.GetNewsLog(newsgroup, Session["Admin_UserName"].ToString(), DateTime.Now, 0); int _newsLogID = newsLogBSO.CreateNewsLog(_newsLog); clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>"; initControl(_newsgroupID); AspNetCache.Reset(); ViewNewsLog(_newsgroupID); //Response.Redirect("~/Admin/Group/listnewsgroup/" + hddGroup.Value + "/Default.aspx"); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } }
private void initControl(int Id, int subId) { AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); if (Id > 0) { btn_add.Visible = false; btn_edit.Visible = true; btn_add2.Visible = false; btn_add1.Visible = false; btn_edit1.Visible = true; try { NewsLog newsgroup = new NewsLog(); NewsLogBSO newsgroupBSO = new NewsLogBSO(); newsgroup = newsgroupBSO.GetNewsLogById(subId); //NewsGroup newsgroup = new NewsGroup(); //NewsGroupBSO newsgroupBSO = new NewsGroupBSO(); //newsgroup = newsgroupBSO.GetNewsGroupById(Id); hddNewsGroupID.Value = Convert.ToString(newsgroup.NewsGroupID); ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID); hddParentNewsID.Value = Convert.ToString(newsgroup.ParentNewsID); //rdbGroupCate.SelectedValue = Convert.ToString(newsgroup.GroupCate); //Thêm txtTitle.Text = newsgroup.Title; txtRadShort.Text = System.Net.WebUtility.HtmlDecode(newsgroup.ShortDescribe); txtRadFull.Text = newsgroup.FullDescribe; hddImageThumb.Value = newsgroup.ImageThumb; hddImageLarge.Value = newsgroup.ImageLarge; txtimage4_3.Text = newsgroup.ImageThumb; txtimage16_9.Text = newsgroup.ImageLarge; if (newsgroup.ImageThumb != "") { img_thumb.Text = "<img src='" + newsgroup.ImageThumb + "' width='48px' valign='middle'>"; } if (newsgroup.ImageLarge != "") { img_large.Text = "<img src='" + newsgroup.ImageLarge + "' width='48px' valign='middle'>"; } hddFileName.Value = newsgroup.FileName; txtAuthor.Text = newsgroup.Author; txtRadDate.Text = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); // "9/3/2008 16:05:07" .ToString(); hddRelationTotal.Value = Convert.ToString(newsgroup.RelationTotal); rdbStatus.Checked = newsgroup.Status; rdbIshot.Checked = newsgroup.Ishot; rdbIshome.Checked = newsgroup.Ishome; hddCommentTotal.Value = Convert.ToString(newsgroup.CommentTotal); hddIsView.Value = Convert.ToString(newsgroup.Isview); hddCreateUserName.Value = newsgroup.CreatedUserName; hddApprovalUserName.Value = newsgroup.ApprovalUserName; hddApprovalDate.Value = Convert.ToString(newsgroup.ApprovalDate); txtKeywords.Text = newsgroup.Keyword; txtTags.Text = newsgroup.Tags; txtSlug.Text = newsgroup.Slug; rdbComment.Checked = newsgroup.IsComment; rdbApproval.Checked = newsgroup.IsApproval; if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.Enabled = true; } else { rdbApproval.Enabled = false; } //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); //if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) //{ // rdbApproval.Checked = newsgroup.IsApproval; // rdbApproval.Enabled = true; //} //else //{ // rdbApproval.Checked = newsgroup.IsApproval; // rdbApproval.Enabled = false; //} hddGroup.Value = newsgroup.GroupCate.ToString(); BindToCateNews(newsgroup.GroupCate); ddlCateNewsGroup.SelectedValue = hddGroup.Value; ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID); rdbTypeNews.Checked = newsgroup.TypeNews; txtShortTitle.Text = newsgroup.ShortTitle; chkUrl.Checked = newsgroup.isUrl; txtUrl.Text = newsgroup.Url; if (newsgroup.isUrl) { txtUrl.Visible = true; panelUrl.Visible = true; } else { txtUrl.Visible = false; panelUrl.Visible = false; } hddisDelete.Value = newsgroup.isDelete.ToString(); BindListCate(newsgroup.NewsGroupID); //MultiCate ViewNewsLog(newsgroup.NewsGroupID); } catch (Exception ex) { clientview.Text = ex.Message.ToString(); } } else { txtRadDate.Text = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString(); hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString(); txtUrl.Visible = false; btn_add.Visible = true; btn_edit.Visible = false; btn_add2.Visible = true; btn_add1.Visible = true; btn_edit1.Visible = false; if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { rdbApproval.Enabled = true; } else { rdbApproval.Enabled = false; } txtUrl.Visible = false; panelUrl.Visible = false; chkUrl.Checked = false; } }