protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; lbNewsID.Text = "0"; if (Request["id"] != null) lbNewsID.Text = Request["id"]; string cmdTxt = string.Format("EXEC news_news_edit @userID={0}, @newsID={1}", UserId, lbNewsID.Text); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); try { ddNhom.DataSource = ds.Tables[1]; ddNhom.DataBind(); if (lbNewsID.Text != "0") { ddNhom.SelectedValue = ds.Tables[0].Rows[0][1].ToString(); tbTieuDe.Text = ds.Tables[0].Rows[0][2].ToString(); tbMoTa.Text = ds.Tables[0].Rows[0][3].ToString(); tbHinhAnh.Text = ds.Tables[0].Rows[0][4].ToString(); imgHinhAnh.ImageUrl = ds.Tables[0].Rows[0][4].ToString(); cbAllowComment.Checked = Convert.ToBoolean(ds.Tables[0].Rows[0][5].ToString()); cbPublished.Checked = Convert.ToBoolean(ds.Tables[0].Rows[0][6].ToString()); dnnNoiDung.Text = ds.Tables[0].Rows[0][7].ToString(); lbDang.Text = string.Format("{2} _ Đăng bởi {1} - {0}", ds.Tables[0].Rows[0][9].ToString(), ds.Tables[0].Rows[0][10].ToString(), ds.Tables[0].Rows[0][8].ToString()); lbSua.Text = string.Format("{2} _ Chỉnh sửa lần cuối bởi {1} - {0}", ds.Tables[0].Rows[0][12].ToString(), ds.Tables[0].Rows[0][13].ToString(), ds.Tables[0].Rows[0][11].ToString()); } } catch (Exception ex) { lbError.Text = ex.Message; } getDirec(); }
protected void bindData() { try { string cmdTxt = string.Format("EXEC news_news_manager @userID={0}, @type='{1}', @sort='{2}'", UserId, ddDanhSach.SelectedValue, ddSapXep.SelectedValue); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); DataColumn dc = new DataColumn("newsLink"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn("newsEdit"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); try { dr["newsLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr[6].ToString()), "", "id/" + dr[0].ToString()); } catch { } dr["newsEdit"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "nsNEWS", "mid/" + ModuleId, "id/" + dr[0].ToString()); dr.EndEdit(); } gvNews.DataSource = ds; gvNews.DataBind(); } catch { } }
protected void Page_Load(object sender, EventArgs e) { try { string cmdTxt = string.Format("EXEC news_news_view @userID={0}, @newsID={1}", UserId, Request["id"]); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); lbHeadline.Text = ds.Tables[0].Rows[0][1].ToString(); lbDate.Text = ds.Tables[0].Rows[0][3].ToString(); lbContent.Text = ds.Tables[0].Rows[0][2].ToString(); hlCatName.Text = ds.Tables[0].Rows[0][5].ToString(); hlCatName.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(ds.Tables[0].Rows[0][6].ToString()), "", "categoryid/", ds.Tables[0].Rows[0][4].ToString()); ds.Tables[1].AcceptChanges(); foreach (DataRow dr in ds.Tables[1].Rows) { dr.BeginEdit(); dr["NewsLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr[2].ToString()), "", "id/", dr[0].ToString()); dr.EndEdit(); } lbTinKhac.Visible = (ds.Tables[1].Rows.Count > 0); gvTinKhac.DataSource = ds.Tables[1]; gvTinKhac.DataBind(); } catch { lbHeadline.Text = "Bạn không thể xem bài viết này"; } }
protected void bindData() { string catID = "url"; if (Settings["Nguon"] != null) catID = Settings["Nguon"].ToString(); if (catID == "url") catID = Request["categoryid"]; int page = 10; if (Settings["Trang"] != null) try { page = Int32.Parse(Settings["Trang"].ToString()); } catch { } news_class ob = new news_class(); string cmdTxt = string.Format("EXEC news_cat_view @catID='{0}'", catID); DataSet ds = ob.fillDataset(cmdTxt); try { if (catID == "new") lbCatName.Text = "Bài viết mới nhất"; else if (catID == "view") lbCatName.Text = "Bài viết xem nhiều"; else if (catID == "hot") lbCatName.Text = "Bài viết nổi bật"; else lbCatName.Text = ds.Tables[0].Rows[0]["CatName"].ToString(); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); try { dr["NewsLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr["DesktopViewID"].ToString()), "", "id/", dr[0].ToString()); } catch { } dr.EndEdit(); } } catch { } gvTinTuc.PageSize = page; gvTinTuc.DataSource = ds; gvTinTuc.DataBind(); }
private void Load_News(int catID, int count, string sql) { try { news_class ob = new news_class(); string cmd = string.Format("EXEC dbo.News_NPC_List {0}, {1}", catID, count); if (sql.Length > 0) cmd = sql; DataSet ds = ob.fillDataset(cmd); DataColumn dc = new DataColumn("Link"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["Link"] = DotNetNuke.Common.Globals.NavigateURL(int.Parse(dr[5].ToString()), "", "id/" + dr[0].ToString()); dr.EndEdit(); } gvCatList.DataSource = ds.Tables[0]; gvCatList.DataBind(); try { hlCategory.Text = ds.Tables[0].Rows[0][6].ToString(); hlCategory.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(int.Parse(ds.Tables[0].Rows[0][8].ToString()), "", "categoryid/" + ds.Tables[0].Rows[0][7].ToString()); } catch { } } catch { } }
protected void bindData() { string cmdTxt = "EXEC news_cat_manager"; news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); DataColumn dc = new DataColumn("CatLink"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); try { dr["CatLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr[3].ToString()), "", "categoryid/" + dr[0].ToString()); } catch { } dr.EndEdit(); } gvNhom.DataSource = ds.Tables[0]; gvNhom.DataBind(); ddList.DataSource = ds.Tables[1]; ddList.DataBind(); ddView.DataSource = ds.Tables[2]; ddView.DataBind(); }
protected void bindData() { string catID = "new"; if (Settings["Nguon"] != null) catID = Settings["Nguon"].ToString(); if (catID == "url") catID = "new"; news_class ob = new news_class(); string cmdTxt = string.Format("EXEC news_cat_view @catID='{0}'", catID); DataSet ds = ob.fillDataset(cmdTxt); try { ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["NewsLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr["DesktopViewID"].ToString()), "", "id/", dr[0].ToString()); dr.EndEdit(); } if (catID == "new") txtCAT.Text = "Bài viết mới nhất"; else if (catID == "view") txtCAT.Text = "Bài viết xem nhiều"; else if (catID == "hot") txtCAT.Text = "Bài viết nổi bật"; else txtCAT.Text = ds.Tables[0].Rows[0]["CatName"].ToString(); txtCAT.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(ds.Tables[0].Rows[0]["DesktopListID"].ToString()) , "", "categoryid/", ds.Tables[0].Rows[0]["CatID"].ToString()); txtTITLE.Text = ds.Tables[0].Rows[0][1].ToString(); txtTITLE.NavigateUrl = ds.Tables[0].Rows[0][4].ToString(); txtDESCRIP.Text = ds.Tables[0].Rows[0][2].ToString(); txtIMG.ImageUrl = ds.Tables[0].Rows[0][3].ToString(); imgNew.Visible = Int32.Parse(ds.Tables[0].Rows[0]["DD"].ToString()) >= 0; if (ds.Tables[0].Rows.Count > 1) { hl1st.Text = ds.Tables[0].Rows[1][1].ToString(); hl1st.NavigateUrl = ds.Tables[0].Rows[1][4].ToString(); imgNew1.Visible = Int32.Parse(ds.Tables[0].Rows[1]["DD"].ToString()) >= 0; } else imgNew1.Visible = false; if (ds.Tables[0].Rows.Count > 2) { hl2nd.Text = ds.Tables[0].Rows[2][1].ToString(); hl2nd.NavigateUrl = ds.Tables[0].Rows[2][4].ToString(); imgNew2.Visible = Int32.Parse(ds.Tables[0].Rows[2]["DD"].ToString()) >= 0; } else imgNew2.Visible = false; if (ds.Tables[0].Rows.Count > 3) { hl3rd.Text = ds.Tables[0].Rows[3][1].ToString(); hl3rd.NavigateUrl = ds.Tables[0].Rows[3][4].ToString(); imgNew3.Visible = Int32.Parse(ds.Tables[0].Rows[3]["DD"].ToString()) >= 0; } else imgNew3.Visible = false; if (ds.Tables[0].Rows.Count > 4) { hl4th.Text = ds.Tables[0].Rows[4][1].ToString(); hl4th.NavigateUrl = ds.Tables[0].Rows[4][4].ToString(); imgNew4.Visible = Int32.Parse(ds.Tables[0].Rows[4]["DD"].ToString()) >= 0; } else imgNew4.Visible = false; } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; try { news_class ob = new news_class(); DataSet ds = ob.fillDataset("exec news_ALLPC"); gvNews.DataSource = ds; gvNews.DataBind(); } catch { } }
public override void LoadSettings() { try { //if (ModuleSettings["SQL"] != null) tbSQL.Text = ModuleSettings["SQL"].ToString(); if (ModuleSettings["Nguon"] != null) ddNguonTin.SelectedValue = ModuleSettings["Nguon"].ToString(); if (ModuleSettings["Trang"] != null) tbSoBai.Text = ModuleSettings["Trang"].ToString(); string cmdTxt = "exec news_cat_list"; news_class ob = new news_class(); ddNguonTin.DataSource = ob.fillDataset(cmdTxt); ddNguonTin.DataBind(); } catch { } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; lbCatID.Text = "0"; try { news_class ob = new news_class(); DataSet ds = ob.fillDataset("EXEC dbo.News_Get_TabID"); dlList.DataSource = ds.Tables[0]; dlList.DataBind(); dlView.DataSource = ds.Tables[1]; dlView.DataBind(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } bindData(); }
protected void btXoaNhom_Click(object sender, EventArgs e) { string cmdTxt = string.Format("EXEC news_cat_delete @userID = {0}, @catID = {1}", UserId, lbCatID.Text); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); try { if (ds.Tables[0].Rows[0][0].ToString() == "1") { btLamLai_Click(sender, e); bindData(); lbError.Text = "Xóa nhóm thành công"; } else lbError.Text = "Có lỗi trong quá trình xóa nhóm"; } catch (Exception ex) { lbError.Text = ex.Message; } }
private void bindData() { string cmdTxt = "EXEC dbo.News_Get_Category " + dlSapXep.SelectedValue; news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); DataColumn dc = new DataColumn("CatLink"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["CatLink"] = DotNetNuke.Common.Globals.NavigateURL(int.Parse(dr[3].ToString()), "", "categoryid/" + dr[0].ToString()); dr.EndEdit(); } gvNhom.DataSource = ds.Tables[0]; gvNhom.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; try { news_class ob = new news_class(); DataSet ds = ob.fillDataset("EXEC dbo.News_Get_Category_User"); dlNhomTin.DataSource = ds.Tables[0]; dlNhomTin.DataBind(); dlNguoiDang.DataSource = ds.Tables[1]; dlNguoiDang.DataBind(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } tbTuNgay.Text = DateTime.Today.AddMonths(-5).ToString("01/MM/yyyy"); tbDenNgay.Text = DateTime.Today.ToString("dd/MM/yyyy"); Bind_Data(); }
protected void btCapNhat_Click(object sender, EventArgs e) { if (UserInfo.IsInRole("DuyetTin")) if (tbTenNhom.Text.Trim() == "") lbError.Text = "Chưa nhập tên nhóm"; else try { string cmd = string.Format("EXEC dbo.News_Set_Category {0}, {1}, N'{2}', {3}, {4}", UserId, lbCatID.Text, tbTenNhom.Text, dlList.SelectedValue, dlView.SelectedValue); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") { btLamLai_Click(sender, e); bindData(); lbError.Text = "Cập nhật thành công"; } else lbError.Text = "Có lỗi trong quá trình cập nhật"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
private void Bind_Data() { news_class ob = new news_class(); string cmdTxt = string.Format("EXEC dbo.News_Get_News N'{0}', '{1}', '{2}', {3}, {4}, {5}", tbTieuDe.Text, ob.dateFormat(tbTuNgay.Text), ob.dateFormat(tbDenNgay.Text), dlNguoiDang.SelectedValue, dlNhomTin.SelectedValue, dlSapXep.SelectedValue); DataSet ds = ob.fillDataset(cmdTxt); DataColumn dc = new DataColumn("Link"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn("EditLink"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["Link"] = DotNetNuke.Common.Globals.NavigateURL(int.Parse(dr[7].ToString()), "", "id/" + dr[0].ToString()); dr["EditLink"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "nsNEWS", "mid/" + ModuleId, "id/" + dr[0].ToString()); dr.EndEdit(); } gvTinTuc.DataSource = ds.Tables[0]; gvTinTuc.DataBind(); }
protected void btCapNhat_Click(object sender, EventArgs e) { if (tbTenNhom.Text.Trim() == "") { lbError.Text = "Chưa nhập tên nhóm"; return; } string cmdTxt = string.Format("EXEC news_cat_update @userID={0}, @catID={1}, @catName=N'{2}', @list={3}, @view={4}", UserId, lbCatID.Text, tbTenNhom.Text, ddList.SelectedValue, ddView.SelectedValue); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); try { if (ds.Tables[0].Rows[0][0].ToString() == "1") { btLamLai_Click(sender, e); bindData(); lbError.Text = "Cập nhật thành công"; } else lbError.Text = "Có lỗi trong quá trình cập nhật"; } catch (Exception ex) { lbError.Text = ex.Message; } }
protected void getDirec() { try { string path = Server.MapPath(@"Portals\0\"); string[] direc = Directory.GetDirectories(path); DataTable dt = new DataTable(); DataColumn dc = new DataColumn("FolderPath"); dt.Columns.Add(dc); dc = new DataColumn("FolderName"); dt.Columns.Add(dc); news_class ob = new news_class(); foreach (string s in direc) { DataRow dr = dt.NewRow(); dr["FolderPath"] = s; dr["FolderName"] = ob.pathFromPortals(s); dt.Rows.Add(dr); } ddThuMuc.DataSource = dt; ddThuMuc.DataBind(); } catch (Exception ex) { lbError.Text = ex.Message; } }
protected void bindData() { news_class ob = new news_class(); DataSet ds = ob.fillDataset("EXEC news_cat_view 6"); try { ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["NewsLink"] = DotNetNuke.Common.Globals.NavigateURL(Int32.Parse(dr["DesktopViewID"].ToString()), "", "id/", dr[0].ToString()); dr.EndEdit(); } if (ds.Tables[0].Rows.Count > 0) { ticker01.Text = ds.Tables[0].Rows[0][1].ToString(); ticker01.NavigateUrl = ds.Tables[0].Rows[0][4].ToString(); } if (ds.Tables[0].Rows.Count > 1) { ticker02.Text = ds.Tables[0].Rows[1][1].ToString(); ticker02.NavigateUrl = ds.Tables[0].Rows[1][4].ToString(); } if (ds.Tables[0].Rows.Count > 2) { ticker03.Text = ds.Tables[0].Rows[2][1].ToString(); ticker03.NavigateUrl = ds.Tables[0].Rows[2][4].ToString(); } if (ds.Tables[0].Rows.Count > 3) { ticker04.Text = ds.Tables[0].Rows[3][1].ToString(); ticker04.NavigateUrl = ds.Tables[0].Rows[3][4].ToString(); } } catch { } }
protected void btXoa_Click(object sender, EventArgs e) { if (UserInfo.IsInRole("DuyetTin")) try { string cmd = string.Format("EXEC dbo.News_Set_Category {0}, {1}, 'DELETE', 0, 0", UserId, lbCatID.Text); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") { btLamLai_Click(sender, e); bindData(); lbError.Text = "Xóa nhóm thành công"; } else lbError.Text = "Có lỗi trong quá trình xóa nhóm"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình xóa nhóm. " + ex.Message; } }
protected void btXem_Click(object sender, EventArgs e) { try { string[] files = Directory.GetFiles(ddThuMuc.SelectedValue); DataTable dt = new DataTable(); DataColumn dc = new DataColumn("FilePath"); dt.Columns.Add(dc); dc = new DataColumn("FileName"); dt.Columns.Add(dc); news_class ob = new news_class(); foreach (string s in files) { string ext = Path.GetExtension(s).ToLower(); if (ext == ".jpeg" || ext == ".jpg" || ext == ".gif" || ext == ".png") { DataRow dr = dt.NewRow(); dr["FilePath"] = ob.webPath(ob.pathFromPortals(s)); dr["FileName"] = Path.GetFileNameWithoutExtension(s); dt.Rows.Add(dr); } } dlHinhAnh.DataSource = dt; dlHinhAnh.DataBind(); } catch (Exception ex) { lbError.Text = ex.Message; } }
protected void btXoaBai_Click(object sender, EventArgs e) { string cmdTxt = string.Format("EXEC news_news_delete @userID={0}, @newsID={1}", UserId, lbNewsID.Text); news_class ob = new news_class(); DataSet ds = ob.fillDataset(cmdTxt); try { if (ds.Tables[0].Rows[0][0].ToString() == "1") Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "nsQLTT", "mid/" + ModuleId)); else lbError.Text = "Có lỗi trong quá trình xóa tin"; } catch (Exception ex) { lbError.Text = ex.Message; } }
protected void btCapNhat_Click(object sender, EventArgs e) { if (tbTieuDe.Text == "") { lbError.Text = "Chưa nhập tiêu đề."; return; } if (tbMoTa.Text == "") { lbError.Text = "Chưa nhập đoạn mô tả."; return; } if (tbHinhAnh.Text == "") { lbError.Text = "Chưa có ảnh đại diện."; return; } if (dnnNoiDung.Text == "") { lbError.Text = "Chưa nhập nội dung."; return; } int allow = 0; if (cbAllowComment.Checked) allow = 1; int publish = 0; if (cbPublished.Checked) publish = 1; SqlParameter paNoiDung = new SqlParameter("@paNoiDung", Server.HtmlDecode(dnnNoiDung.Text)); string cmdTxt = string.Format(@"EXEC news_news_update @userID={0}, @newsID={1}, @catID={2}, @headline=N'{3}', @description=N'{4}', @image='{5}', @content=@paNoiDung, @allow={6}, @publish={7}", UserId, lbNewsID.Text, ddNhom.SelectedValue, tbTieuDe.Text, tbMoTa.Text, tbHinhAnh.Text, allow, publish); news_class ob = new news_class(); DataSet ds = ob.fillWithPara(cmdTxt, paNoiDung); try { if (ds.Tables[0].Rows[0][0].ToString() == "1") Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "nsQLTT", "mid/" + ModuleId)); else lbError.Text = "Có lỗi trong quá trình cập nhật"; } catch (Exception ex) { lbError.Text = ex.Message; } }
protected void upload() { if (fileUpload.HasFile) { //if (fileUpload.PostedFile.ContentLength > 1048576) string ext = Path.GetExtension(fileUpload.FileName).ToLower(); if (ext == ".jpeg" || ext == ".jpg" || ext == ".gif" || ext == ".png") { try { string my_folder = Server.MapPath(@"Portals\0\") + DateTime.Today.ToString("yyyy-MM") + "\\"; if (!Directory.Exists(my_folder)) Directory.CreateDirectory(my_folder); news_class ob = new news_class(); string my_filename = ob.rewriteFilename(fileUpload.FileName); fileUpload.SaveAs(my_folder + my_filename); tbHinhAnh.Text = ob.webPath(ob.pathFromPortals(my_folder) + my_filename); imgHinhAnh.ImageUrl = ob.webPath(ob.pathFromPortals(my_folder) + my_filename); getDirec(); } catch (Exception ex) { lbError.Text = ex.Message; } } else lbError.Text = "Chỉ chấp nhận các định dạng jpeg, jpg, gif, png."; } else lbError.Text = "Chưa chọn file đính kèm"; }