Ejemplo n.º 1
0
        protected void gvNhaTro_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma = gvNhaTro.Rows[chiso].Cells[0].Text;
                    DataTable dt = XLDL.GetData("select MaNhaTro from NhaTroChoThue where MaNhaTro='" + ma + "'");
                    if (dt.Rows.Count > 1)
                    {
                        lbBaoLoi.Text = "Xóa thất bại";
                    }
                    else
                    {
                        XLDL.Excute("Delete HinhAnhChiTietNhaTro from HinhAnhChiTietNhaTro where HinhAnhChiTietNhaTro.MaNhaTro =" + ma);
                        XLDL.Excute("Delete DanhGia from DanhGia where DanhGia.MaNhaTro=" + ma);
                        XLDL.Excute("Delete NhaTroChoThue from NhaTroChoThue where NhaTroChoThue.MaNhaTro =" + ma);
                        Response.Redirect("~/AD/NhaTro.aspx");
                    }
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
Ejemplo n.º 2
0
        protected void gvThongTinKH_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma = gvThongTinKH.Rows[chiso].Cells[0].Text;
                    DataTable dt = XLDL.GetData("select MaKH from KhachHang where MaKH='" + ma + "'");
                    if (dt.Rows.Count > 1)
                    {
                        lbBaoLoi.Text = "Khách hàng đang có bài viết nên không thể xóa.<br/> Bạn cần xóa hết các bài viết của khách hàng này trước";
                    }
                    else
                    {
                        string str = "delete from KhachHang where MaKH='" + ma + "'";
                        XLDL.Excute(str);
                        Response.Redirect("~/AD/KhachHang.aspx");
                    }
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaQH = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [MaTinh],[TenQH] from QuanHuyen where  MaQH='" + MaQH + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update QuanHuyen set MaTinh='" + txtMaTinh.Text + "',TenQH=N'" + txtTenQuanHuyen.Text + "' where  MaQH='" + MaQH + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
        protected void gvQuanTriVIen_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Xoa")
            {
                try
                {
                    int chiso = int.Parse(e.CommandArgument.ToString());

                    string    ma  = gvQuanTriVIen.Rows[chiso].Cells[0].Text;
                    DataTable dt  = XLDL.GetData("select ID_Admin from NguoiQuanLi where ID_Admin='" + ma + "'");
                    string    str = "delete from NguoiQuanLi where ID_Admin='" + ma + "'";
                    XLDL.Excute(str);
                    Response.Redirect("~/AD/QuanTriVien.aspx");
                }
                catch
                {
                    lbBaoLoi.Text = "Thất bại";
                    //Response.Write("<script>alert('Xóa Thất Bại!!!');</script>");
                }
            }
        }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaNT = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [MaKH],[TinhThanh],[QuanHuyen],[PhuongXa],[SoNha],[DiaChi],[SDTNguoiChoThue],[MoTa],[GiaChoThue],[DienTich],[TieuDe] from NhaTroChoThue where  MaNhaTro='" + MaNT + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update NhaTroChoThue set MaKH=" + txtMaKH.Text + ",TinhThanh=N'" + txtTinhThanh.Text + "',QuanHuyen=N'" + txtQuanHuyen.Text + "',PhuongXa=N'" + txtPhuongXa.Text + "',SoNha=N'" + txtSoNha.Text + "',DiaChi=N'" + txtDiaChi.Text + "',SDTnguoiChoThue='" + txtSDT.Text + "',MoTa=N'" + txtMoTa.Text + "',GiaChoThue='" + txtGiaChoThue.Text + "',DienTich='" + txtDienTich.Text + "',TieuDe=N'" + txtTieuDe.Text + "' where  MaNhaTro='" + MaNT + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaKH = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [TenKH],[SDT],[Email],[MatKhau],[TenTK] from KhachHang where  MaKH='" + MaKH + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update KhachHang set TenKH=N'" + txtTenKH.Text + "',SDT='" + txtSDT.Text + "',Email='" + txtEmail.Text + "',MatKhau='" + txtMatKhau.Text + "',TenTK='" + txtTaiKhoan.Text + "' where  MaKH='" + MaKH + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaAD = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select  [TenTK],[MatKhau],[SDT_Admin] from NguoiQuanLi where  ID_Admin='" + MaAD + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update NguoiQuanLi set TenTK=N'" + txtTaiKhoanAD.Text + "',MatKhau='" + txtMatKhauAD.Text + "',SDT_Admin='" + txtSDT_AD.Text + "' where ID_Admin='" + MaAD + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }
 protected void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         string    MaPX = Request.QueryString["Ma"].ToString();
         DataTable dt   = XLDL.GetData("select [MaQH],[TenPhuongXa] from PhuongXa where MaPX='" + MaPX + "'");
         if (dt.Rows.Count > 0)
         {
             XLDL.Excute(@"update PhuongXa set MaQH='" + txtMaQH.Text + "',TenPhuongXa=N'" + txtPhuongXa.Text + "' where  MaPX='" + MaPX + "'");
             lbBaoLoi.Text = "Lưu thành công";
         }
         else
         {
             lbBaoLoi.Text = "Lưu không thành công!";
         }
     }
     catch
     {
         lbBaoLoi.Text = "Thất bại";
     }
 }