protected void btnGuiCauHoi_Click(object sender, EventArgs e) { try { HoiDapSanPham hoidap = new HoiDapSanPham(); //hoidap.InsertFields(int.Parse(Request.QueryString["id"].ToString()), null, txtNguoiHoi.Text, txtNoiDung.Text, null); string strScript = "<script language='JavaScript'>" + "dialogArguments.opener.TabSelected(2,true);this.close();</script>"; ClientScript.RegisterStartupScript(Type.GetType("System.String"), "Refresh", strScript); } catch (Exception ex) { Response.Redirect("Message.aspx?msg=" + ex.ToString().Replace("\r\n", "")); } }
private void LoadData(string Id) { try { HoiDapSanPham hd = new HoiDapSanPham(); DataSet ds = hd.SelectByID(Convert.ToInt32(Id)); if (ds.Tables[0].Rows.Count > 0) { txtCauHoi.Text = ds.Tables[0].Rows[0]["CauHoi"].ToString(); txtTraLoi.Text = ds.Tables[0].Rows[0]["TraLoi"].ToString(); } } catch (Exception ex) { Response.Write(ex.ToString()); } }
private void LoadData() { int id = 0; if (Common.LoaiNguoiDungID() == 3) { id = 0; } else if (Common.LoaiNguoiDungID() == 2) { id = Common.NguoiDungID(); } HoiDapSanPham hd = new HoiDapSanPham(); DataSet ds = hd.SelectHoiDapSanPhamByNguoiDung(id); grdHoiDap.DataSource = ds.Tables[0]; grdHoiDap.DataBind(); }
protected void btnLuu_Click(object sender, EventArgs e) { try { if (txtCauHoi.Text.Trim() != "") { HoiDapSanPham hd = new HoiDapSanPham(); if (Request.QueryString["aid"] != null) { //hd.UpdateFields(System.Convert.ToInt32(Request.QueryString["aid"].ToString()), null, null, // null, txtCauHoi.Text, txtTraLoi.Text); } string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>"; ClientScript.RegisterStartupScript(GetType(), "Refresh", strScript); } } catch (Exception ex) { Response.Write(ex.ToString()); } }
private void LuuCauHoi() { HoiDapSanPham hd = new HoiDapSanPham(); hd.InsertFields(int.Parse("0" + ViewState["SanPhamID"]), Common.NguoiDungID(), null, txtCauHoi.Value, null, DateTime.Now, null, null, null, txtChiTietCauHoi.Value); txtCauHoi.Value = ""; txtChiTietCauHoi.Value = ""; hidLuuCauHoi.Value = "false"; //LoadTabContent03(); }
private void LoadTabContent03() { tblHoiDap.Visible = Common.NguoiDungID() != 0; tblTraGiaContent.Visible = false; tblHoiDapContent.Visible = true; tblCacCuaHang.Visible = false; tblContent.Rows.Clear(); HoiDapSanPham hdsp = new HoiDapSanPham(); DataSet hdds = hdsp.SelectHoiDapSanPhamBySanPhamID(int.Parse(ViewState["SanPhamID"].ToString())); //string strThongTin = sds.Tables[0].Rows[0]["ThongTinSanPham"].ToString(); if (hdds.Tables[0].Rows.Count > 0) { lblHoiDap.Visible = false; int countrow = tblHoiDapContent.Rows.Count; for (int j = 1; j < countrow; j++) { tblHoiDapContent.Rows.Remove(tblHoiDapContent.Rows[1]); } int index = 0; foreach (DataRow dr in hdds.Tables[0].Rows) { index++; HtmlTableRow str = new HtmlTableRow(); HtmlTableCell std1 = new HtmlTableCell(); HtmlTableCell std2 = new HtmlTableCell(); HtmlTableCell std3 = new HtmlTableCell(); HtmlTableCell std4 = new HtmlTableCell(); //HtmlTableCell std5 = new HtmlTableCell(); std1.Align = "center"; std1.Style.Add("border", "1pt solid"); std2.Align = "left"; std2.Style.Add("padding-left", "15px"); std2.Style.Add("border", "1pt solid"); std3.Align = "left"; std3.Style.Add("padding-right", "10px"); std3.Style.Add("border", "1pt solid"); std4.Align = "center"; std4.Style.Add("border", "1pt solid"); //std5.Align = "center"; std1.InnerHtml = index.ToString(); std2.InnerHtml = dr["HovaTen"] + "<br>" + "<a href=\"ymsgr:sendIM?" + dr["YM"] + "\"><img src=\"http://opi.yahoo.com/online?u=" + dr["YM"] + "&t=1\" border=\"0\"></a>"; std3.InnerHtml = "<b>" + dr["CauHoi"] + "</b><br>" + dr["ChiTietCauHoi"]; std4.InnerHtml = "(" + DateTime.Parse(dr["NgayHoi"].ToString()).ToString("dd/MM/yyyy") + ")"; str.Cells.Add(std1); str.Cells.Add(std2); str.Cells.Add(std3); str.Cells.Add(std4); //str.Cells.Add(std5); tblHoiDapContent.Rows.Add(str); } } else { lblHoiDap.Visible = true; } }
protected void btnXoa_Click(object sender, EventArgs e) { try { switch (ViewState["TYPE"].ToString()) { case "thuoctinh": if (Common.LoaiNguoiDungID() == 3) { ThuocTinh tt = new ThuocTinh(); tt.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "nhomsanpham": if (Common.LoaiNguoiDungID() == 3) { NhomSanPham nhomsanpham = new NhomSanPham(); nhomsanpham.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "vitrisanpham": if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2)) { ViTriSanPham vtsp = new ViTriSanPham(); vtsp.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "cuahangnhomsanpham": if (Common.LoaiNguoiDungID() == 2) { deleteCuaHangNhomSanPham(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "nhomsanphamcuahang": if (Common.LoaiNguoiDungID() == 2) { deleteNhomSanPhamCuaHang(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "nhanxetsanpham": if (Common.LoaiNguoiDungID() != 1) { NhanXetSanPham nhanxet = new NhanXetSanPham(); nhanxet.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "tintuc": if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2)) { TinTuc tt = new TinTuc(); tt.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "hotrotructuyen": if ((Common.LoaiNguoiDungID() == 3) || (Common.LoaiNguoiDungID() == 2)) { HoTroTrucTuyen ht = new HoTroTrucTuyen(); ht.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "hoidapsanpham": if (Common.LoaiNguoiDungID() != 1) { HoiDapSanPham hoidap = new HoiDapSanPham(); hoidap.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "nguoidung": if (Common.LoaiNguoiDungID() == 3) { if (CheckExistCuaHang(id) != true) { NguoiDung nguoidung = new NguoiDung(); nguoidung.Delete(id); } else { Response.Redirect("../message.aspx?msg=Không thể xóa người dùng đã có cửa hàng", false); } } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "hangsanxuat": if (Common.LoaiNguoiDungID() == 3) { HangSanXuat hsx = new HangSanXuat(); hsx.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "khuvuc": if (Common.LoaiNguoiDungID() == 3) { KhuVuc kv = new KhuVuc(); kv.Delete(id); } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "quangcao": if (Common.LoaiNguoiDungID() == 2 || Common.LoaiNguoiDungID() == 3) { QuangCao qcao = new QuangCao(); DataSet ds = qcao.SelectByQuangCaoID(id); if (ds.Tables[0].Rows.Count == 1) { if (Common.LoaiNguoiDungID() == 3) { //Administrator if (ds.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() == "3") qcao.Delete(id); } else { //e-Store if (ds.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() == "2" && ds.Tables[0].Rows[0]["NguoiDungID"].ToString() == Common.NguoiDungID().ToString()) qcao.Delete(id); } } } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; case "sanpham": { SanPham sanpham = new SanPham(); DataSet dssp = sanpham.SelectBySanPhamID(id); if (Common.LoaiNguoiDungID() == 2) { if (dssp.Tables[0].Rows.Count == 1) { //e-Store if (dssp.Tables[0].Rows[0]["LoaiNguoiDungID"].ToString() == Common.LoaiNguoiDungID().ToString() && dssp.Tables[0].Rows[0]["NguoiDungID"].ToString() == Common.NguoiDungID().ToString()) { sanpham.Delete(id); } } } else if (Common.LoaiNguoiDungID() == 3) { if (dssp.Tables[0].Rows.Count == 1) { sanpham.Delete(id); } } else { Response.Redirect("../message.aspx?msg=Access denied"); } } break; case "sanphammau": { SanPhamMau sanpham = new SanPhamMau(); DataSet dssp = sanpham.SelectByID(id); if (Common.LoaiNguoiDungID() == 3) { if (dssp.Tables[0].Rows.Count == 1) { sanpham.Delete(id); } } else { Response.Redirect("../message.aspx?msg=Access denied"); } } break; case "anhsanpham": if ((Common.LoaiNguoiDungID() == 2) || (Common.LoaiNguoiDungID() == 3)) { Anh anhsanpham = new Anh(); DataSet dssp = anhsanpham.SelectByID(id); if (dssp.Tables[0].Rows.Count == 1) { anhsanpham.Delete(id); if (File.Exists(Server.MapPath(Request.QueryString["src"]))) { File.Delete(Server.MapPath(Request.QueryString["src"])); } } } else { Response.Redirect("../message.aspx?msg=Access denied"); } break; } string strScript = "<script language='JavaScript'>" + "window.parent.Refresh();</script>"; ClientScript.RegisterStartupScript(Type.GetType("System.String"), "Refresh", strScript); } catch (Exception ex) { Response.Write(ex.ToString()); } }