Exemplo n.º 1
0
        public ActionResult NhanGiaoDichThueCanHo(ThueCanHo thuecanho, string chkSuaLoi)
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    TaiKhoan tk = new TaiKhoan();
                    tk = (TaiKhoan)Session["taikhoan"];
                    ViewBag.chkSuaLoi = chkSuaLoi;

                    DataProvider dp = new DataProvider();

                    SqlParameter[] param = new SqlParameter[2];
                    param[0] = new SqlParameter("@mataikhoan", SqlDbType.Int);
                    param[0].Value = tk.MaTaiKhoan;

                    param[1] = new SqlParameter("@mathuecanho", SqlDbType.Int);
                    param[1].Value = thuecanho.MaThueCanHo;

                    if (chkSuaLoi != null)
                    {
                        //Set level = Serializable để giải quyết Unrepeatable Read
                        dp.ExecuteProcNonQuery("sp_NhanGiaoDich_Fixed", ref param);
                    }
                    else
                    {
                        //Set level = ReadCommitted mức mặc định
                        dp.ExecuteProcNonQuery("sp_NhanGiaoDich", ref param);
                    }

                    return Redirect("/Admin/ThueCanHo/ChiTietThueCanHo/" + thuecanho.MaThueCanHo.ToString());
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return Redirect("/Admin/ThueCanHo/");
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult ChinhSuaTaiKhoan(TaiKhoan taikhoan)
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    DataProvider dp = new DataProvider();

                    SqlParameter[] param = new SqlParameter[3];
                    param[0] = new SqlParameter("@mataikhoan", SqlDbType.Int);
                    param[0].Value = taikhoan.MaTaiKhoan;

                    param[1] = new SqlParameter("@maloaitaikhoan", SqlDbType.Int);
                    param[1].Value = taikhoan.MaLoaiTaiKhoan;

                    param[2] = new SqlParameter("@trangthai", SqlDbType.Int);
                    param[2].Value = taikhoan.MaTrangThai;

                    dp.ExecuteProcNonQuery("sp_ChinhSuaTaiKhoan", ref param);
                    ViewBag.ErrorMessage = "Cập nhật thành công!";
                    return Redirect("/Admin/TaiKhoan/");
                }
                catch(Exception ex)
                {
                    ViewBag.ErrorMessage = "";
                    return View("~/Views/Admin/TaiKhoan/ChinhSuaTaiKhoan.cshtml", taikhoan);
                }
            }
        }
Exemplo n.º 3
0
        public ActionResult XacNhanXoaCanHo(int id)
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    DataProvider dp = new DataProvider();

                    SqlParameter[] param = new SqlParameter[1];
                    param[0] = new SqlParameter("@macanho", SqlDbType.Int);
                    param[0].Value = id;

                    dp.ExecuteProcNonQuery("sp_XoaCanHo", ref param);
                    ViewBag.ErrorMessage = "";
                    return Redirect("/Admin/CanHo/");
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return Redirect("/Admin/CanHo/");
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult TaoCanHo(CanHo canho)
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    TaiKhoan tk = new TaiKhoan();
                    tk = (TaiKhoan)Session["taikhoan"];

                    canho.NguoiDang = tk.MaTaiKhoan;
                    canho.NgayDang = DateTime.Now;

                    SqlParameter[] param = new SqlParameter[10];
                    param[0] = new SqlParameter("@tencanho", SqlDbType.NVarChar);
                    param[0].Value = canho.TenCanHo;

                    param[1] = new SqlParameter("@maduong", SqlDbType.Int);
                    param[1].Value = canho.MaDuong;

                    param[2] = new SqlParameter("@diachi", SqlDbType.NVarChar);
                    param[2].Value = canho.DiaChi;

                    param[3] = new SqlParameter("@mieuta", SqlDbType.NVarChar);
                    param[3].Value = canho.MieuTa;

                    param[4] = new SqlParameter("@toado", SqlDbType.NVarChar);
                    param[4].Value = canho.ToaDo;

                    param[5] = new SqlParameter("@giathue", SqlDbType.Float);
                    param[5].Value = canho.GiaThue;

                    param[6] = new SqlParameter("@dientich", SqlDbType.Float);
                    param[6].Value = canho.DienTich;

                    param[7] = new SqlParameter("@matrangthaicanho", SqlDbType.Int);
                    param[7].Value = canho.MaTrangThaiCanHo;

                    param[8] = new SqlParameter("@ngaydang", SqlDbType.DateTime);
                    param[8].Value = canho.NgayDang;

                    param[9] = new SqlParameter("@nguoidang", SqlDbType.Int);
                    param[9].Value = canho.NguoiDang;

                    DataProvider dp = new DataProvider();
                    dp.ExecuteProcNonQuery("sp_TaoCanHo", ref param);

                    ViewBag.ErrorMessage = "Đăng tin căn hộ thành công";
                    return Redirect("/Admin/CanHo/");
                }
                catch (Exception ex)
                {
                    List<ThanhPho> lsThanhPho = new List<ThanhPho>();
                    lsThanhPho = ThanhPhoController.ListThanhPho();
                    ViewBag.MaThanhPho = new SelectList(lsThanhPho, "mathanhpho", "tenthanhpho");

                    List<Quan> lsQuan = new List<Quan>();
                    lsQuan = QuanController.ListQuan();
                    ViewBag.MaQuan = new SelectList(lsQuan, "maquan", "tenquan");

                    List<Duong> lsDuong = new List<Duong>();
                    lsDuong = DuongController.ListDuong();
                    ViewBag.MaDuong = new SelectList(lsDuong, "maduong", "tenduong");

                    ViewBag.ErrorMessage = "Khởi tạo không thành công";
                    return View("~/Views/Admin/CanHo/TaoCanHo.cshtml");
                }

            }
        }
Exemplo n.º 5
0
        public ActionResult ChinhSuaCanHo(CanHo canho, string chkSuaLoi, string chkDirtyRead)
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                //*/
                try
                {
                    ViewBag.chkDirtyRead = chkDirtyRead;
                    ViewBag.chkSuaLoi = chkSuaLoi;
                    DataProvider dp = new DataProvider();

                    SqlParameter[] param = new SqlParameter[9];
                    param[0] = new SqlParameter("@macanho", SqlDbType.Int);
                    param[0].Value = canho.MaCanHo;

                    param[1] = new SqlParameter("@tencanho", SqlDbType.NVarChar);
                    param[1].Value = canho.TenCanHo;

                    param[2] = new SqlParameter("@maduong", SqlDbType.Int);
                    param[2].Value = canho.MaDuong;

                    param[3] = new SqlParameter("@diachi", SqlDbType.NVarChar);
                    param[3].Value = canho.DiaChi;

                    param[4] = new SqlParameter("@mieuta", SqlDbType.NVarChar);
                    param[4].Value = canho.MieuTa;

                    param[5] = new SqlParameter("@toado", SqlDbType.NVarChar);
                    param[5].Value = canho.ToaDo;

                    param[6] = new SqlParameter("@giathue", SqlDbType.Float);
                    param[6].Value = canho.GiaThue;

                    param[7] = new SqlParameter("@dientich", SqlDbType.Float);
                    param[7].Value = canho.DienTich;

                    param[8] = new SqlParameter("@matrangthaicanho", SqlDbType.Int);
                    param[8].Value = canho.MaTrangThaiCanHo;

                    if (chkSuaLoi != null)
                    {
                        //Set level = Serializable để giải quyết Unrepeatable Read
                        dp.ExecuteProcNonQuery("sp_ChinhSuaCanHo_Fixed", ref param);
                    }
                    else if (chkDirtyRead != null)
                    {
                        //Set waitfor delay
                        dp.ExecuteProcNonQuery("sp_ChinhSuaCanHo_DirtyRead", ref param);
                    }
                    else
                    {
                        //Set level = ReadCommitted mức mặc định
                        dp.ExecuteProcNonQuery("sp_ChinhSuaCanHo", ref param);
                    }

                    ViewBag.ErrorMessage = "Cập nhật thành công!";
                    return Redirect("/Admin/CanHo/");

                }
                catch (Exception ex)
                {
                    List<ThanhPho> lsThanhPho = new List<ThanhPho>();
                    lsThanhPho = ThanhPhoController.ListThanhPho();
                    ViewBag.MaThanhPho = new SelectList(lsThanhPho, "mathanhpho", "tenthanhpho");

                    List<Quan> lsQuan = new List<Quan>();
                    lsQuan = QuanController.ListQuan();
                    ViewBag.MaQuan = new SelectList(lsQuan, "maquan", "tenquan");

                    List<Duong> lsDuong = new List<Duong>();
                    lsDuong = DuongController.ListDuong();
                    ViewBag.MaDuong = new SelectList(lsDuong, "maduong", "tenduong", canho.MaDuong);
                    ViewBag.ErrorMessage = ex.Message;
                    return View("~/Views/Admin/CanHo/ChinhSuaCanHo.cshtml", canho);
                }
                //*/
            }
        }
Exemplo n.º 6
0
        public ActionResult Index(string txtNgayBatDauThue, int txtThoiGianThue,
                                string txtNgayKetThuc, double txtTienThue,
                                double txtGiamGia, double txtTienPhaiTra,
                                double txtTienCoc, string txtHoTen,
                                string txtEmail, string txtDiaChi,
                                string txtDienThoai)
        {
            TaiKhoan tk = isLogin();
            if (tk == null)
            {
                return Redirect("/DangNhap");
            }

            int maCanHo = 0;
            CanHo ch = new CanHo();

            if (!Int32.TryParse(Request.Params["id"], out maCanHo))
            {
                ch.MaTrangThaiCanHo = -999;
                return null;
            }

            DateTime ngaybatdau = DateTime.ParseExact(txtNgayBatDauThue, "yyyy-M-d", null);
            DateTime ngayketthuc = DateTime.ParseExact(txtNgayKetThuc, "d/M/yyyy", null);

            DataProvider dp = new DataProvider();

            SqlParameter[] param = new SqlParameter[9];
            param[0] = new SqlParameter("@mataikhoan", SqlDbType.Int);
            param[0].Value = tk.MaTaiKhoan;

            param[1] = new SqlParameter("@macanho", SqlDbType.Int);
            param[1].Value = maCanHo;

            param[2] = new SqlParameter("@tiencoc", SqlDbType.Float);
            param[2].Value = txtTienCoc;

            param[3] = new SqlParameter("@thoigianthue", SqlDbType.DateTime);
            param[3].Value = ngaybatdau;

            param[4] = new SqlParameter("@thoigiankethuc", SqlDbType.DateTime);
            param[4].Value = ngayketthuc;

            param[5] = new SqlParameter("@thoigiangiaodich", SqlDbType.DateTime);
            param[5].Value = DateTime.Now;

            param[6] = new SqlParameter("@dienthoai", SqlDbType.NVarChar);
            param[6].Value = txtDienThoai;

            param[7] = new SqlParameter("@diachi", SqlDbType.NVarChar);
            param[7].Value = txtDiaChi;

            param[8] = new SqlParameter("@ghichu", SqlDbType.Text);
            param[8].Value = "";

            ViewBag.taiKhoan = tk;
            ViewBag.ketQuaThueCanHo = dp.ExecuteProcNonQuery("sp_thuecanho", ref param);
            ViewBag.isThueCanHo = true;

            return View("~/Views/Shared/DatThueCanHo.cshtml", new CanHo());
        }