private void Show_News() { try { string cmd = string.Format("EXEC Communica.News_ViewID {0}, {1}", lbID.Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmd); hlSua.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "UPDATE", "mid/" + ModuleId, "ID/" + ds.Tables[0].Rows[0][0].ToString()); lbTieuDe.Text = ds.Tables[0].Rows[0][2].ToString(); lbMoTa.Text = ds.Tables[0].Rows[0][3].ToString(); lbNoiDung.Text = ds.Tables[0].Rows[0][7].ToString(); lbNhom.Text = ds.Tables[0].Rows[0][9].ToString(); lbPublished.Text = ds.Tables[0].Rows[0][10].ToString(); lbError.Text = string.Format("{0} / {1}", ds.Tables[0].Rows[0][8].ToString(), ds.Tables[0].Rows[0][5].ToString()); hlSua.Visible = UserId == 519 || (ds.Tables[0].Rows[0][4].ToString() == "False" && UserId.ToString() == ds.Tables[0].Rows[0][6].ToString()); btDuyet.Visible = UserId == 519 && ds.Tables[0].Rows[0][4].ToString() == "False"; gvDinhKem.DataSource = ds.Tables[1]; gvDinhKem.DataBind(); ds = ob.fillDataset("EXEC Communica.News_SameCat " + lbID.Text); DataColumn dc = new DataColumn("LinkID"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["LinkID"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "VIEW", "mid/" + ModuleId, "ID/" + dr[0].ToString()); dr.EndEdit(); } gvTinKhac.DataSource = ds.Tables[0]; gvTinKhac.DataBind(); } catch { lbTieuDe.Text = "Nội dung không tồn tại hoặc chưa được duyệt"; } }
private void Load_News() { try { string cmd = string.Format("EXEC Communica.News_ViewID {0}, {1}", lbID.Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmd); rbNhom.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(); tbNoiDung.Text = ds.Tables[0].Rows[0][7].ToString(); lbError.Text = string.Format("{0} / {1}", ds.Tables[0].Rows[0][8].ToString(), ds.Tables[0].Rows[0][5].ToString()); lbPublished.Text = ds.Tables[0].Rows[0][10].ToString(); bool canEdit = ds.Tables[0].Rows[0][6].ToString() == UserId.ToString() || UserId == 519; FileUpload.Enabled = canEdit; btDinhKem.Enabled = canEdit; btGuiDi.Enabled = canEdit; btXoa.Enabled = canEdit; btPhoBien.Enabled = UserId == 519; gvDinhKem.DataSource = ds.Tables[1]; gvDinhKem.DataBind(); } catch (Exception ex) { FileUpload.Enabled = false; btDinhKem.Enabled = false; btXoa.Enabled = false; btPhoBien.Enabled = false; if (lbID.Text != "0") lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } }
protected void btDuyet_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC Communica.News_Update {0}, 0, '', '', 1, {1}, ''", lbID.Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") Show_News(); } catch { } }
private void Load_Home() { try { class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(string.Format("EXEC Communica.News_Home {0}, {1}", rbPublished.SelectedValue, UserId)); DataColumn dc = new DataColumn("LinkID"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn("LinkEdit"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["LinkID"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "VIEW", "mid/" + ModuleId, "ID/" + dr[0].ToString()); dr["LinkEdit"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "UPDATE", "mid/" + ModuleId, "ID/" + dr[0].ToString()); dr.EndEdit(); } dlTinTuc.DataSource = ds.Tables[0]; dlTinTuc.DataBind(); } catch { } }
private void File_Upload() { if (FileUpload.HasFile) try { string cmdTxt = string.Format("EXEC Communica.File_Update 0, {0}, N'{1}', '{2}', {3}", lbID.Text, FileUpload.FileName, Path.GetExtension(FileUpload.FileName), UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmdTxt); if (ds.Tables[0].Rows[0][0].ToString() == "1") { string my_folder = Server.MapPath("Portals\\0\\") + ds.Tables[0].Rows[0][1].ToString() + "\\"; if (Directory.Exists(my_folder) == false) Directory.CreateDirectory(my_folder); FileUpload.SaveAs(my_folder + ds.Tables[0].Rows[0][2].ToString()); Load_Dinhkem(); lbError.Text = "Thêm đính kèm thành công"; } else lbError.Text = "Không thể thêm đính kèm"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đính kèm. " + ex.Message; } else lbError.Text = "Chưa chọn file đính kèm"; }
private void Load_Dinhkem() { try { string cmd = string.Format("EXEC Communica.News_ViewID {0}, {1}", lbID.Text, UserId); class_Communica ob = new class_Communica(); gvDinhKem.DataSource = ob.fillDataset(cmd).Tables[1]; gvDinhKem.DataBind(); } catch { } }
protected void gvDinhKem_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "XOA") try { int i = Convert.ToInt32(e.CommandArgument); string cmdTxt = string.Format("EXEC Communica.File_Update {0}, 0, '', '', {1}", gvDinhKem.Rows[i].Cells[2].Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmdTxt); if (ds.Tables[0].Rows[0][0].ToString() == "1") { Load_Dinhkem(); lbError.Text = "Xóa đính kèm thành công"; } else lbError.Text = "Không thể xóa đính kèm"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật đính kèm. " + ex.Message; } }
protected void btXoa_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC Communica.News_Update {0}, 0, '', '', -1, {1}, ''", lbID.Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId)); else lbError.Text = "Không thể xóa"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật dữ liệu. " + ex.Message; } }
protected void btPhoBien_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC Communica.News_Update {0}, 0, '', '', 1, {1}, ''", lbID.Text, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") { Load_News(); lbError.Text = "Đã duyệt"; } else lbError.Text = "Không thể duyệt"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật dữ liệu. " + ex.Message; } }
protected void btGuiDi_Click(object sender, EventArgs e) { try { SqlParameter paContent = new SqlParameter("@NoiDung", Server.HtmlDecode(tbNoiDung.Text)); string cmd = string.Format("EXEC Communica.News_Update {0}, {1}, N'{2}', N'{3}', {4}, {5}, @NoiDung", lbID.Text, rbNhom.SelectedValue, tbTieuDe.Text, tbMoTa.Text, 0, UserId); class_Communica ob = new class_Communica(); DataSet ds = ob.fillDataset_Para(cmd, paContent); if (ds.Tables[0].Rows[0][0].ToString() == "1") { lbID.Text = ds.Tables[0].Rows[0][1].ToString(); Load_News(); lbError.Text = "Cập nhật thành công"; } else lbError.Text = "Không thể cập nhật"; //SEND_EMAIL(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật dữ liệu. " + ex.Message; } }