private void BindListCate(int newsgroupID) { NewsCateBSO newsCateBSO = new NewsCateBSO(); DataTable table = newsCateBSO.GetNewsCateByNewsGroupID(newsgroupID); string strID = ""; if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; strID += row["CateNewsID"].ToString() + ","; } } if (strID != "") { lboCateSelect.Items.Clear(); CateNewsBSO catenewsBSO = new CateNewsBSO(); DataTable table1 = catenewsBSO.GetCateNewsBystrId(strID); if (table1.Rows.Count > 0) { for (int i = 0; i < table1.Rows.Count; i++) { DataRow row = table1.Rows[i]; lboCateSelect.Items.Add(new ListItem(row["CateNewsName"].ToString(), row["CateNewsID"].ToString())); } } } }
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 add_NewsCate(int _newsgroupID) { NewsCateBSO _newscateBSO = new NewsCateBSO(); NewsCate _newsCate = new NewsCate(); foreach (ListItem items in lboCateSelect.Items) { _newsCate.CateNewsID = Convert.ToInt32(items.Value); _newsCate.NewsGroupID = _newsgroupID; int i = _newscateBSO.CreateNewsCateGet(_newsCate); //strID += items.Value + ","; } //foreach (ListItem items in lboCateSelect.Items) //{ // if (items.Selected) // { // _newsCate.CateNewsID = Convert.ToInt32(items.Value); // _newsCate.NewsGroupID = _newsgroupID; // int i = _newscateBSO.CreateNewsCateGet(_newsCate); // } //} }
protected void grvNewsGroup_RowCommand(object sender, GridViewCommandEventArgs e) { int Id = Convert.ToInt32(e.CommandArgument.ToString()); NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsgroup = newsGroupBSO.GetNewsGroupById(Id); string nName = e.CommandName.ToLower(); AdminBSO adminBSO = new AdminBSO(); Admin admin = new Admin(); switch (nName) { case "_listfiles": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { Response.Redirect("~/Admin/listnewsfiles/" + Id + "/Default.aspx"); } break; case "_addfiles": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { Response.Redirect("~/Admin/editnewsfiles/" + Id + "/0/Default.aspx"); } break; case "_relation": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { Response.Redirect("~/Admin/EditNewsRelation/" + Id + "/Default.aspx"); } break; case "_view": break; case "_edit": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { Response.Redirect("~/Admin/editnews/" + Id + "/Default.aspx"); } break; case "_delete": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write")) { newsGroupBSO.DeleteNewsGroup(Id); //newsGroupBSO.UpdateNewsGroupisDelete(Id, "1"); ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue)); NewsCateBSO newscateBSO = new NewsCateBSO(); if (newscateBSO.GetNewsCateByNewsGroupID(Id).Rows.Count > 0) { newscateBSO.DeleteNewsCatebyNewsID(Id); } AspNetCache.Reset(); } break; case "_restore": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { newsGroupBSO.UpdateNewsGroupisDelete(Id, "0"); ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue)); AspNetCache.Reset(); } break; } }