private void bind_data() { try { bool isAdmin = UserInfo.IsInRole("admin") || UserInfo.IsInRole("LCD_Admin") || UserInfo.IsInRole("GiaoDichVien"); //bool isAdmin = UserInfo.IsInRole("admin"); string status = "2"; if (isAdmin) status = ddTrangThai.SelectedValue; ddTrangThai.Visible = isAdmin; string cmd = string.Format("EXEC ChungNT.Feedback_Home {0}, {1}, {2}", status, UserId, ModuleId); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmd); DataColumn dc = new DataColumn("Link"); ds.Tables[0].Columns.Add(dc); dc = new DataColumn("Reply"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow row in ds.Tables[0].Rows) { row.BeginEdit(); row[5] = row[5].ToString().Replace(Environment.NewLine, "<br />"); row[8] = row[8].ToString().Replace(Environment.NewLine, "<br />"); row["Link"] = DotNetNuke.Common.Globals.NavigateURL(TabId, "REPLY", "mid/" + ModuleId, "ID/" + row[0].ToString()); if (isAdmin) row["Reply"] = "Trả lời"; else row["Reply"] = ""; row.EndEdit(); } dlFeedback.DataSource = ds.Tables[0]; dlFeedback.DataBind(); lbSoLuong.Text = ds.Tables[1].Rows[0][0].ToString() + " / " + ds.Tables[1].Rows[0][1].ToString(); } catch (Exception ex) { lbCategory.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; hlThoat.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "ADMIN", "mid/" + ModuleId); bool isAdmin = (UserInfo.IsInRole("admin") || UserInfo.IsInRole("LCD_Admin") || UserInfo.IsInRole("GiaoDichVien")); if (!isAdmin) Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId)); try { string sql = "EXEC ChungNT.Feedback_ID @ID"; SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@ID", Request["ID"]); zClass ob = new zClass(); DataSet ds = ob.bindDataset(sql, para); lbHeadline.Text = string.Format("{0} : {1}", ds.Tables[0].Rows[0]["CreatedByName"].ToString(), ds.Tables[0].Rows[0]["Subject"].ToString()); lbID.Text = ds.Tables[0].Rows[0]["FeedbackID"].ToString(); lbHoTen.Text = ds.Tables[0].Rows[0]["CreatedByName"].ToString(); lbDiaChi.Text = ds.Tables[0].Rows[0]["DiaChi"].ToString(); lbDienThoai.Text = ds.Tables[0].Rows[0]["DienThoai"].ToString(); lbEmail.Text = ds.Tables[0].Rows[0]["CreatedByEmail"].ToString(); lbTieuDe.Text = ds.Tables[0].Rows[0]["Subject"].ToString(); lbNoiDung.Text = ds.Tables[0].Rows[0]["Message"].ToString(); lbThoiGian.Text = ds.Tables[0].Rows[0]["DateCreated"].ToString(); lbReplyID.Text = ds.Tables[0].Rows[0]["R_ID"].ToString(); tbHoTen.Text = ds.Tables[0].Rows[0]["R_Name"].ToString(); tbTieuDe.Text = ds.Tables[0].Rows[0]["R_Subject"].ToString(); tbNoiDung.Text = ds.Tables[0].Rows[0]["R_Message"].ToString(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } }
public void bind_data(int status) { string cmdText = string.Format("select subject, createdbyemail, [message], datecreated, feedbackid, createdbyname from feedback" + " where status={0} order by datecreated desc", status); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmdText); try { DataColumn dc = new DataColumn("content"); ds.Tables[0].Columns.Add(dc); ds.Tables[0].AcceptChanges(); foreach (DataRow dr in ds.Tables[0].Rows) { dr.BeginEdit(); dr["content"] = string.Format("<b>{0} : {1}</b><br />{2}<br /><img src='/DesktopModules/zFeedback/zTime.jpg' /> {3}" + " <img src='/DesktopModules/zFeedback/zEmail.png' /> {4}", dr[5].ToString(), dr[0].ToString(), dr[2].ToString(), dr[3].ToString(), dr[1].ToString()); dr.EndEdit(); } GridView1.DataSource = ob.zSelect(cmdText); GridView1.DataBind(); GridView1.Columns[1].Visible = UserInfo.IsInRole(PortalSettings.AdministratorRoleName); GridView1.Columns[2].Visible = UserInfo.IsInRole(PortalSettings.AdministratorRoleName); } catch (Exception ex) { Response.Write("<script language='javascript'>alert('" + ex.Message + "')</script>"); } }
protected void btGuiDi_Click(object sender, EventArgs e) { try { string sql = "EXEC ChungNT.Feedback_Update 0, @PortalID, @CategoryID, @CreatedByName, @CreatedByEmail, @Subject, @Message, 0, @DiaChi, @DienThoai"; SqlParameter[] para = new SqlParameter[8]; para[0] = new SqlParameter("@PortalID", ddDienLuc.SelectedValue); para[1] = new SqlParameter("@CategoryID", ModuleId); para[2] = new SqlParameter("@CreatedByName", tbHoTen.Text); para[3] = new SqlParameter("@CreatedByEmail", tbEmail.Text); para[4] = new SqlParameter("@Subject", tbTieuDe.Text); para[5] = new SqlParameter("@Message", tbNoiDung.Text); para[6] = new SqlParameter("@DiaChi", tbDiaChi.Text); para[7] = new SqlParameter("@DienThoai", tbDienThoai.Text); zClass ob = new zClass(); DataSet ds = ob.bindDataset(sql, para); if (ds.Tables[0].Rows[0][0].ToString() == "1") { btGuiDi.Enabled = false; lbError.Text = "Trả lời thành công. Câu hỏi đã được hiển thị."; } else lbError.Text = "Không thể trả lời."; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
protected void gvQuanLy_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SUA") try { int i = Convert.ToInt32(e.CommandArgument); string cmd = string.Format("EXEC dbo.GetFeedbackList 1, 0, {0}, 0, 0", gvQuanLy.Rows[i].Cells[1].Text); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmd); lbID.Text = ds.Tables[0].Rows[0]["ListID"].ToString(); tbTenNhom.Text = ds.Tables[0].Rows[0]["Name"].ToString(); lbError_SuaNhom.Text = ""; pnBack.CssClass = "pnBack"; pnSuaNhom.CssClass = "pnShow"; } catch { } if (e.CommandName == "XOA") try { int i = Convert.ToInt32(e.CommandArgument); string cmd = string.Format("EXEC ChungNT.Feedback_Category_Update {0}, {1}", gvQuanLy.Rows[i].Cells[1].Text, gvQuanLy.Rows[i].Cells[2].Text); zClass ob = new zClass(); ob.zExecute(cmd); Load_Data(); lbError.Text = "Xóa quyền quản lý nhóm thành công"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình xử lý. " + ex.Message; } }
protected void ImageButton3_Click(object sender, ImageClickEventArgs e) { string name = ((TextBox)GridView1.FooterRow.FindControl("TextBox2")).Text; string st = string.Format("INSERT INTO FeedbackList (PortalID, Name) VALUES (1, N'{0}')", name); zClass ob = new zClass(); ob.zExecute(st); GridView1.EditIndex = -1; GridView1.DataSource = zGetData(); GridView1.DataBind(); }
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text; string id = GridView1.Rows[e.RowIndex].Cells[0].Text; string st = string.Format("UPDATE FeedbackList SET Name=N'{0}' WHERE ListID={1}", name, id); zClass ob = new zClass(); ob.zExecute(st); GridView1.EditIndex = -1; GridView1.DataSource = zGetData(); GridView1.DataBind(); }
private DataTable zGetData() { string st = "SELECT ListID, Name FROM FeedbackList"; zClass ob = new zClass(); DataSet ds = ob.zSelect(st); if (ds.Tables[0].Rows.Count == 0) { string ins = "INSERT INTO FeedbackList (PortalID, Name) VALUES (1, 'Default')"; ob.zExecute(ins); } ds = ob.zSelect(st); return ds.Tables[0]; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string catID = "0"; if (Settings["feedCategory"] != null) catID = Settings["feedCategory"].ToString(); zBindData(catID, "0"); catID = "SELECT Name FROM FeedbackList WHERE ListID=" + catID; zClass ob = new zClass(); lbCategory.Text = ob.zSelect(catID).Tables[0].Rows[0][0].ToString(); if (UserInfo.IsInRole("admin") || UserInfo.IsInRole("Administrators")) GridView1.Columns[2].Visible = true; else GridView1.Columns[2].Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; bool isAdmin = (UserInfo.IsInRole("admin") || UserInfo.IsInRole("LCD_Admin") || UserInfo.IsInRole("GiaoDichVien")); if (!isAdmin) Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId)); zClass ob = new zClass(); try { ddDienLuc.DataSource = ob.zSelect("EXEC ChungNT.Feedback_Roles").Tables[0]; ddDienLuc.DataBind(); } catch { } Panel1.Visible = isAdmin; lbID.Text = Request["ID"] == null ? "0" : Request["ID"]; if (lbID.Text != "0") load_data(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; hlThoat.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId); try { string sql = "EXEC ChungNT.Feedback_DonVi @moduleID, 0"; SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@moduleID", ModuleId); zClass ob = new zClass(); DataSet ds = ob.bindDataset(sql, para); ddDienLuc.DataSource = ds.Tables[0]; ddDienLuc.DataBind(); lbTieuDe.Text = ds.Tables[1].Rows[0][0].ToString(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; hlThoat.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId); bool isAdmin = (UserInfo.IsInRole("admin") || UserInfo.IsInRole("LCD_Admin") || UserInfo.IsInRole("GiaoDichVien")); if (!isAdmin) Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId)); try { string sql = "EXEC ChungNT.Feedback_DonVi @moduleID, 1"; SqlParameter[] para = new SqlParameter[1]; para[0] = new SqlParameter("@moduleID", ModuleId); zClass ob = new zClass(); DataSet ds = ob.bindDataset(sql, para); dlDonVi.DataSource = ds.Tables[0]; dlDonVi.DataBind(); dlChucNang.DataSource = ds.Tables[1]; dlChucNang.DataBind(); load_data(); } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DEL") { string st = "UPDATE Feedback SET Status=-1 WHERE FeedbackID=" + GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text; zClass ob = new zClass(); ob.zExecute(st); string catID = "0"; if (Settings["feedCategory"] != null) catID = Settings["feedCategory"].ToString(); zBindData(catID, "0"); btTraLoi.Visible = false; btGuiDi.Visible = true; } else if (btTraLoi.Visible == false) { zBindData("0", GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[1].Text); btTraLoi.Visible = true; btGuiDi.Visible = false; if (UserInfo.IsInRole("admin") || UserInfo.IsInRole("Administrators")) btTraLoi.Enabled = true; else btTraLoi.Enabled = false; } }
protected void btTraLoi_Click(object sender, EventArgs e) { try { string sql = "EXEC ChungNT.Feedback_Update @ID, 0, @CategoryID, @CreatedByName, '', @Subject, @Message, @ApprovedBy, '', ''"; SqlParameter[] para = new SqlParameter[6]; para[0] = new SqlParameter("@ID", lbReplyID.Text); para[1] = new SqlParameter("@CategoryID", ModuleId); para[2] = new SqlParameter("@CreatedByName", tbHoTen.Text); para[3] = new SqlParameter("@Subject", tbTieuDe.Text); para[4] = new SqlParameter("@Message", tbNoiDung.Text); para[5] = new SqlParameter("@ApprovedBy", lbID.Text); zClass ob = new zClass(); DataSet ds = ob.bindDataset(sql, para); if (ds.Tables[0].Rows[0][0].ToString() == "1") { btTraLoi.Enabled = false; lbError.Text = "Trả lời thành công. Câu hỏi đã được hiển thị."; } else lbError.Text = "Không thể trả lời."; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
private void zBindData(string catID, string feedID) { string st = "SELECT CreatedByEmail, Message, FeedbackID, CreatedByName, DateCreated FROM Feedback"; if (catID != "0") st = st + " WHERE Status=0 AND CategoryID=" + catID + " ORDER BY DateCreated DESC"; else if (feedID != "0") st = st + " WHERE Status=" + feedID + " OR FeedbackID=" + feedID + " ORDER BY DateCreated"; zClass ob = new zClass(); DataTable dt = ob.zSelect(st).Tables[0]; DataTable data = new DataTable(); DataColumn dc = new DataColumn("FeedbackID"); data.Columns.Add(dc); dc = new DataColumn("Message"); data.Columns.Add(dc); DataRow dr; foreach (DataRow row in dt.Rows) { dr = data.NewRow(); dr["FeedbackID"] = row["FeedbackID"].ToString(); dr["Message"] = string.Format("<b>{0}</b><br />{2}<br /><div style='font-size:11px;'><img src='/DesktopModules/zFeedback/zTime.jpg' /> {3} <img src='/DesktopModules/zFeedback/zEmail.png' /> {1}</div>", row[3].ToString(), row[0].ToString(), row[1].ToString(), row[4].ToString()); data.Rows.Add(dr); } GridView1.DataSource = data; GridView1.DataBind(); }
private void load_data() { try { SqlParameter[] para = new SqlParameter[1]; SqlParameter temp = new SqlParameter("@ID", lbID.Text); para[0] = temp; zClass ob = new zClass(); string sql = "EXEC ChungNT.Feedback_ID @ID"; DataSet ds = ob.bindDataset(sql, para); //DataSet ds = ob.zSelect("EXEC ChungNT.Feedback_ID " + lbID.Text); lbID.Text = ds.Tables[0].Rows[0][0].ToString(); tbHoTen.Text = ds.Tables[0].Rows[0][1].ToString(); tbEmail.Text = ds.Tables[0].Rows[0][2].ToString(); tbTieuDe.Text = ds.Tables[0].Rows[0][4].ToString(); tbNoiDung.Text = ds.Tables[0].Rows[0][5].ToString(); lbR_ID.Text = ds.Tables[0].Rows[0][6].ToString(); tbR_HoTen.Text = ds.Tables[0].Rows[0][7].ToString(); tbR_TieuDe.Text = ds.Tables[0].Rows[0][8].ToString(); tbR_NoiDung.Text = ds.Tables[0].Rows[0][9].ToString(); tbDiaChi.Text = ds.Tables[0].Rows[0][11].ToString(); tbDienThoai.Text = ds.Tables[0].Rows[0][12].ToString(); try { ddDienLuc.SelectedValue = ds.Tables[0].Rows[0][10].ToString(); } catch { } } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; lbID.Text = "0"; lbR_ID.Text = "0"; } }
private void Load_Data() { try { zClass ob = new zClass(); DataSet ds = ob.zSelect("EXEC ChungNT.Feedback_Category"); dlNhom.DataSource = ds.Tables[0]; dlNhom.DataBind(); gvQuanLy.DataSource = ds.Tables[1]; gvQuanLy.DataBind(); string id = ""; foreach (GridViewRow dr in gvQuanLy.Rows) if (dr.Cells[1].Text != id) { id = dr.Cells[1].Text; dr.Cells[3].CssClass = "row1"; } else dr.Cells[3].CssClass = "row2"; dlUsers.DataSource = ds.Tables[2]; dlUsers.DataBind(); lbError.Text = ""; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; } }
protected void btGuiDi_Click(object sender, EventArgs e) { try { SqlParameter[] para = new SqlParameter[9]; SqlParameter temp = new SqlParameter("@ID", lbID.Text); para[0] = temp; temp = new SqlParameter("@PortalID", ddDienLuc.SelectedValue); para[1] = temp; temp = new SqlParameter("@CategoryID", ModuleId); para[2] = temp; temp = new SqlParameter("@CreatedByName", tbHoTen.Text); para[3] = temp; temp = new SqlParameter("@CreatedByEmail", tbEmail.Text); para[4] = temp; temp = new SqlParameter("@Subject", tbTieuDe.Text); para[5] = temp; temp = new SqlParameter("@Message", tbNoiDung.Text); para[6] = temp; temp = new SqlParameter("@DiaChi", tbDiaChi.Text); para[7] = temp; temp = new SqlParameter("@DienThoai", tbDienThoai.Text); para[8] = temp; zClass ob = new zClass(); string sql = "EXEC ChungNT.Feedback_Update @ID, @PortalID, @CategoryID, @CreatedByName, @CreatedByEmail, @Subject, @Message, 0, @DiaChi, @DienThoai"; DataSet ds = ob.bindDataset(sql, para); //string hoTen = ob.reWrite(tbHoTen.Text); //string email = ob.reWrite(tbEmail.Text); //string tieuDe = ob.reWrite(tbTieuDe.Text); //string noiDung = ob.reWrite(tbNoiDung.Text); //string diaChi = ob.reWrite(tbDiaChi.Text); //string dienThoai = ob.reWrite(tbDienThoai.Text); //string cmd = string.Format("EXEC ChungNT.Feedback_Update {0}, {5}, '{6}', N'{1}', '{2}', N'{3}', N'{4}', 0, N'{7}', '{8}'", // lbID.Text, hoTen, email, tieuDe, noiDung, ddDienLuc.SelectedValue, ModuleId, diaChi, dienThoai); //DataSet ds = ob.zSelect(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") lbError.Text = "Nội dung của bạn đã được gửi đi. Chúng tôi sẽ trả lời trong thời gian sớm nhất."; else lbError.Text = "Nội dung chưa được gửi đi."; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
protected void btGuiDi_Click(object sender, EventArgs e) { string catID = "0"; if (Settings["feedCategory"] != null) catID = Settings["feedCategory"].ToString(); string st = string.Format("INSERT INTO Feedback (ModuleID, Status, CreatedByEmail, Message, DateCreated, CategoryID, CreatedByName) VALUES (1, 0, '{0}', N'{1}', GETDATE(), '{2}', N'{3}')", tbEmail.Text, tbCauHoi.Text, catID, tbTen.Text); zClass ob = new zClass(); ob.zExecute(st); zBindData(catID, "0"); btNhapLai_Click(sender, e); }
protected void btTraLoi_Click(object sender, EventArgs e) { try { zClass ob = new zClass(); string hoTen_reply = ob.reWrite(tbR_HoTen.Text); string tieuDe_reply = ob.reWrite(tbR_TieuDe.Text); string noiDung_reply = ob.reWrite(tbR_NoiDung.Text); string cmd = string.Format("EXEC ChungNT.Feedback_Update {0}, 1, '{1}', N'{2}', '', N'{3}', N'{4}', {5}, '', ''", lbR_ID.Text, ModuleId, hoTen_reply, tieuDe_reply, noiDung_reply, lbID.Text); DataSet ds = ob.zSelect(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") { load_data(); lbError.Text = "Trả lời thành công. Câu hỏi đã được hiển thị."; } else lbError.Text = "Không thể trả lời."; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
protected void btXoa_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC ChungNT.Feedback_Delete {0}, 1", lbR_ID.Text); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") load_data(); else lbError.Text = "Không thể xóa."; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }
// Sửa nhóm protected void btCapNhat_Click(object sender, EventArgs e) { if (tbTenNhom.Text.Trim().Length == 0) { lbError_SuaNhom.Text = "Chưa nhập tên nhóm"; return; } try { string cmd; if (lbID.Text == "0") cmd = string.Format("EXEC dbo.AddFeedbackList 0, 1, N'{0}', '', 1", tbTenNhom.Text); else cmd = string.Format("EXEC dbo.EditFeedbackList 0, {0}, 0, 1, N'{1}', '', 1", lbID.Text, tbTenNhom.Text); zClass ob = new zClass(); ob.zExecute(cmd); Load_Data(); btDong_Click(sender, e); lbError.Text = "Cập nhật nhóm thành công"; } catch (Exception ex) { lbError_SuaNhom.Text = "Có lỗi trong quá trình xử lý. " + ex.Message; } }
protected void btXoaCH_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC ChungNT.Feedback_Delete {0}, 0", lbID.Text); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmd); if (ds.Tables[0].Rows[0][0].ToString() != "0") 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. " + ex.Message; } }
// Thêm quyền protected void btThem_Click(object sender, EventArgs e) { if (dlUsers.SelectedIndex == 0) { lbError_ThemQuyen.Text = "Chưa chọn người quản lý"; return; } try { string cmd = string.Format("EXEC ChungNT.Feedback_Category_Update {0}, {1}", dlNhom.SelectedValue, dlUsers.SelectedValue); zClass ob = new zClass(); ob.zExecute(cmd); Load_Data(); btDong_Click(sender, e); lbError.Text = "Thêm quyền quản lý nhóm thành công"; } catch (Exception ex) { lbError_ThemQuyen.Text = "Có lỗi trong quá trình xử lý. " + ex.Message; } }
protected void btChuyen_Click(object sender, EventArgs e) { try { string cmd = string.Format("EXEC ChungNT.Feedback_Status {0}, 1", lbID.Text); zClass ob = new zClass(); DataSet ds = ob.zSelect(cmd); if (ds.Tables[0].Rows[0][0].ToString() == "1") lbError.Text = "Chuyển trạng thái thành công"; else lbError.Text = "Không thể chuyển trạng thái"; } catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình cập nhật. " + ex.Message; } }