Exemplo n.º 1
0
        public static GiaoDich DanhSachGiaoDichThueCanHo(int mathuecanho)
        {
            try
            {
                GiaoDich item = new GiaoDich();

                DataProvider dp = new DataProvider();
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@mathuecanho", SqlDbType.Int);
                param[0].Value = mathuecanho;

                DataTable dt = new DataTable();
                dt = dp.ExecuteProcQuery("sp_DanhSachNhanGiaoDichThueCanHo", ref param);

                if (dt.Rows.Count > 0)
                {
                    item.MaGiaoDich = (int)dt.Rows[0]["magiaodich"];
                    item.MaTaiKhoan = (int)dt.Rows[0]["mataikhoan"];
                    item.TenTaiKhoan = (String)dt.Rows[0]["ten"];
                    item.MaLoaiTaiKhoan = (int)dt.Rows[0]["maloaitaikhoan"];
                    item.MaThueCanHo = (int)dt.Rows[0]["mathuecanho"];
                    item.MaTrangThaiGiaoDich = (int)dt.Rows[0]["matrangthaigiaodich"];
                    switch (item.MaTrangThaiGiaoDich)
                    {
                        case 1:
                            item.TrangThaiGiaoDich = TrangThaiGiaoDich.Cho_Xac_Nhan;
                            break;
                        case 2:
                            item.TrangThaiGiaoDich = TrangThaiGiaoDich.Dang_Giao_Dich;
                            break;
                        case 3:
                            item.TrangThaiGiaoDich = TrangThaiGiaoDich.Da_Giao_Dich;
                            break;
                        case 4:
                            item.TrangThaiGiaoDich = TrangThaiGiaoDich.Thanh_Toan_Hoan_Tat;
                            break;
                        case 5:
                            item.TrangThaiGiaoDich = TrangThaiGiaoDich.Giao_Dich_Huy_Bo;
                            break;
                    }
                    return item;
                }
                else return null;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        //
        // GET: /ThueCanHo/
        public ActionResult Index()
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                //*/
                try
                {
                    DataProvider dp = new DataProvider();

                    int page = 1;
                    if (Request.QueryString["page"] != null)
                    {
                        page = int.Parse(Request.QueryString["page"]);
                    }

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

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

                    param[2] = new SqlParameter("@count", SqlDbType.Int);
                    param[2].Value = DBNull.Value; //Chua biet gia tri
                    param[2].Direction = ParameterDirection.Output;
                    DataTable dt = new DataTable();

                    dt = dp.ExecuteProcQuery("sp_DanhSachThueCanHo", ref param);

                    List<ThueCanHo> ls = new List<ThueCanHo>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ThueCanHo item = new ThueCanHo();

                        item.MaThueCanHo = (int)dt.Rows[i]["mathuecanho"];
                        item.MaTaiKhoan = (int)dt.Rows[i]["mataikhoan"];
                        item.TenTaiKhoan = (string)dt.Rows[i]["ten"];
                        item.MaCanHo = (int)dt.Rows[i]["macanho"];
                        item.TenCanHo = (string)dt.Rows[i]["tencanho"];
                        item.TienCoc = (double)dt.Rows[i]["tiencoc"];
                        item.ThoiGianThue = (DateTime)dt.Rows[i]["thoigianthue"];
                        item.ThoiGianKetThuc = (DateTime)dt.Rows[i]["thoigianketthuc"];
                        item.ThoiGianGiaoDich = (DateTime)dt.Rows[i]["thoigiangiaodich"];

                        if (dt.Rows[i]["dienthoai"] != DBNull.Value)
                        {
                            item.DienThoai = (string)dt.Rows[i]["dienthoai"];
                        }
                        if (dt.Rows[i]["diachi"] != DBNull.Value)
                        {
                            item.DiaChi = (string)dt.Rows[i]["diachi"];
                        }
                        if (dt.Rows[i]["ghichu"] != DBNull.Value)
                        {
                            item.GhiChu = (string)dt.Rows[i]["ghichu"];
                        }
                        item.KichHoat = (int)dt.Rows[i]["kichhoat"];

                        ls.Add(item);
                    }

                    ViewBag.RowPerPage = RowPerPage;
                    ViewBag.Page = page;
                    ViewBag.Count = (int)param[2].Value;

                    return View("~/Views/Admin/ThueCanHo/Index.cshtml", ls);

                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return null;
                }
                //*/
            }
        }
Exemplo n.º 3
0
        public ActionResult ChiTietThueCanHo(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("@mathuecanho", SqlDbType.Int);
                    param[0].Value = id;

                    DataTable dt = new DataTable();
                    dt = dp.ExecuteProcQuery("sp_ChiTietThueCanHo", ref param);

                    ThueCanHo item = new ThueCanHo();
                    if (dt.Rows.Count > 0)
                    {
                        item.MaThueCanHo = (int)dt.Rows[0]["mathuecanho"];
                        item.MaTaiKhoan = (int)dt.Rows[0]["mataikhoan"];
                        item.TenTaiKhoan = (string)dt.Rows[0]["ten"];
                        item.MaCanHo = (int)dt.Rows[0]["macanho"];
                        item.TenCanHo = (string)dt.Rows[0]["tencanho"];
                        item.TienCoc = (double)dt.Rows[0]["tiencoc"];
                        item.ThoiGianThue = (DateTime)dt.Rows[0]["thoigianthue"];
                        item.ThoiGianKetThuc = (DateTime)dt.Rows[0]["thoigianketthuc"];
                        item.ThoiGianGiaoDich = (DateTime)dt.Rows[0]["thoigiangiaodich"];

                        if (dt.Rows[0]["dienthoai"] != DBNull.Value)
                        {
                            item.DienThoai = (string)dt.Rows[0]["dienthoai"];
                        }
                        if (dt.Rows[0]["diachi"] != DBNull.Value)
                        {
                            item.DiaChi = (string)dt.Rows[0]["diachi"];
                        }
                        if (dt.Rows[0]["ghichu"] != DBNull.Value)
                        {
                            item.GhiChu = (string)dt.Rows[0]["ghichu"];
                        }
                        item.KichHoat = (int)dt.Rows[0]["kichhoat"];
                    }

                    GiaoDich gd = GiaoDichController.DanhSachGiaoDichThueCanHo(item.MaThueCanHo);

                    if (gd != null)
                    {
                        ViewBag.DanhSachGiaoDich = gd;
                    }

                    return View("~/Views/Admin/ThueCanHo/ChiTietThueCanHo.cshtml", item);
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return Redirect("/Admin/ThueCanHo/");
                }
            }
        }
Exemplo n.º 4
0
        //
        // GET: /CanHo/
        public ActionResult Index()
        {
            bool fixDirtyRead = true;
            Boolean.TryParse(Request.Params["dirtyread"], out fixDirtyRead);

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

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

            else
            {
                DataProvider dp = new DataProvider();
                string sql = "";
                //Load danh sach thanh pho
                /*string sql = @"SELECT ch.*, d.tenduong, q.tenquan, tp.tenthanhpho
                                FROM canho ch, duong d, quan q, thanhpho tp
                                WHERE ch.kichhoat = 1 AND
                                    ch.matrangthaicanho = 2 AND
                                    ch.maduong = d.maduong AND
                                    d.maquan = q.maquan AND
                                    q.mathanhpho = tp.mathanhpho AND
                                    ch.macanho = " + canHoID.ToString() + @"
                                ORDER BY ch.ngaydang DESC
                                ";*/

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

                DataTable dt = new DataTable();

                if (fixDirtyRead == true)
                {
                    dt = dp.ExecuteProcQuery("sp_XemCanHo_Fixed", ref param);
                }
                else
                {
                    dt = dp.ExecuteProcQuery("sp_XemCanHo", ref param);
                }

                if (dt.Rows.Count > 0)
                {
                    ch.MaCanHo = (int)dt.Rows[0]["macanho"];
                    ch.TenCanHo = dt.Rows[0]["tencanho"].ToString();
                    ch.MaDuong = (int)dt.Rows[0]["maduong"];
                    ch.DiaChi = dt.Rows[0]["diachi"].ToString() + " " +
                                    dt.Rows[0]["tenduong"].ToString() + ", " +
                                    dt.Rows[0]["tenquan"].ToString() + ", " +
                                    dt.Rows[0]["tenthanhpho"].ToString();
                    ch.MieuTa = dt.Rows[0]["mieuta"].ToString();
                    ch.ToaDo = dt.Rows[0]["toado"].ToString();
                    ch.GiaThue = (double)dt.Rows[0]["giathue"];
                    ch.DienTich = (double)dt.Rows[0]["dientich"];
                    ch.MaTrangThaiCanHo = (int)dt.Rows[0]["matrangthaicanho"];
                    ch.TrangThaiCanHo = (TrangThaiCanHo)dt.Rows[0]["matrangthaicanho"];
                    ch.NgayDang = DateTime.Parse(dt.Rows[0]["ngaydang"].ToString());
                    ch.NguoiDang = (int)dt.Rows[0]["nguoidang"];
                    ch.GhiChu = dt.Rows[0]["ghichu"].ToString();
                    ch.KichHoat = (int)dt.Rows[0]["kichhoat"];

                    //Lay hinh anh
                    sql = @"SELECT *
                            FROM hinhanhcanho
                            WHERE macanho = " + canHoID.ToString();
                    dt = new DataTable();
                    dt = dp.ExecuteQuery(sql);
                    List<HinhAnhCanHo> dsHinhAnhCanHo = new List<HinhAnhCanHo>();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        HinhAnhCanHo h = new HinhAnhCanHo();
                        h.MaHinhAnh = (int)dt.Rows[i]["mahinhanh"];
                        h.LienKet = dt.Rows[i]["lienket"].ToString();
                        h.MaCanHo = canHoID;

                        dsHinhAnhCanHo.Add(h);
                    }
                    ViewBag.dsHinhAnhCanHo = dsHinhAnhCanHo;

                    //Lay thong tin nguoi dang tin
                    sql = @"SELECT *
                            FROM taikhoan
                            WHERE mataikhoan = " + ch.NguoiDang.ToString();
                    dt = new DataTable();
                    dt = dp.ExecuteQuery(sql);

                    TaiKhoan tk = new TaiKhoan();
                    tk.MaTaiKhoan = (int)dt.Rows[0]["mataikhoan"];
                    tk.Email = dt.Rows[0]["email"].ToString();
                    tk.MaLoaiTaiKhoan = (int)dt.Rows[0]["maloaitaikhoan"];
                    tk.LoaiTaiKhoan = (LoaiTaiKhoan)dt.Rows[0]["maloaitaikhoan"];
                    tk.Ten = dt.Rows[0]["ten"].ToString();
                    tk.NgaySinh = (DateTime)dt.Rows[0]["ngaysinh"];
                    tk.DiaChi = dt.Rows[0]["diachi"].ToString();
                    tk.DienThoai = dt.Rows[0]["dienthoai"].ToString();
                    tk.NgayDangKy = (DateTime)dt.Rows[0]["ngaydangky"];
                    tk.MaTrangThai = (int)dt.Rows[0]["trangthai"];
                    tk.TrangThai = (TrangThaiTaiKhoan)dt.Rows[0]["trangthai"];

                    ViewBag.taiKhoan = tk;
                }
                else
                {
                    ch.MaTrangThaiCanHo = -999;
                }
            }

            return View("~/Views/Shared/ChiTietCanHo.cshtml", ch);
        }
Exemplo n.º 5
0
        //
        // GET: /TaiKhoan_/
        public ActionResult Index()
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    DataProvider dp = new DataProvider();
                    int page = 1;
                    if (Request.QueryString["page"] != null)
                    {
                        page = int.Parse(Request.QueryString["page"]);
                    }

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

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

                    param[2] = new SqlParameter("@count", SqlDbType.Int);
                    param[2].Value = DBNull.Value; // chưa biết giá trị nên cho nó bằng rỗng (= null)
                    param[2].Direction = ParameterDirection.Output;
                    DataTable dt = new DataTable();

                    dt = dp.ExecuteProcQuery("sp_DanhSachTaiKhoan", ref param);

                    List<TaiKhoan> ls = new List<TaiKhoan>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        TaiKhoan tk = new TaiKhoan();

                        tk.MaTaiKhoan = (int)dt.Rows[i]["mataikhoan"];
                        tk.Email = (string)dt.Rows[i]["email"];
                        tk.MatKhau = (string)dt.Rows[i]["matkhau"];
                        switch((int)dt.Rows[i]["maloaitaikhoan"])
                        {
                            case 1:
                                tk.LoaiTaiKhoan = LoaiTaiKhoan.Admin;
                                break;
                            case 2:
                                tk.LoaiTaiKhoan = LoaiTaiKhoan.Member;
                                break;
                            case 3:
                                tk.LoaiTaiKhoan = LoaiTaiKhoan.Sales;
                                break;
                        }

                        tk.Ten = (string)dt.Rows[i]["ten"];
                        tk.NgaySinh = (DateTime)dt.Rows[i]["ngaysinh"];
                        if (dt.Rows[i]["diachi"] != DBNull.Value)
                        {
                            tk.DiaChi = (string)dt.Rows[i]["diachi"];
                        }
                        if (dt.Rows[i]["dienthoai"] != DBNull.Value)
                        {
                            tk.DienThoai = (string)dt.Rows[i]["dienthoai"];
                        }

                        tk.NgayDangKy = (DateTime)dt.Rows[i]["ngaydangky"];

                        switch ((int)dt.Rows[i]["trangthai"])
                        {
                            case 0:
                                tk.TrangThai = TrangThaiTaiKhoan.Deactive;
                                break;
                            case 1:
                                tk.TrangThai = TrangThaiTaiKhoan.Active;
                                break;
                        }

                        ls.Add(tk);
                    }
                    ViewBag.RowPerPage = RowPerPage;
                    ViewBag.Page = page;
                    ViewBag.Count = (int)param[2].Value;

                    return View("~/Views/Admin/TaiKhoan/Index.cshtml", ls);

                }
                catch(Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return null;
                }

            }
        }
Exemplo n.º 6
0
        //
        // GET: /NhanGiaoDich_/
        public ActionResult Index()
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                //*/
                try
                {
                    TaiKhoan tk = new TaiKhoan();
                    tk = (TaiKhoan)Session["taikhoan"];

                    DataProvider dp = new DataProvider();

                    int page = 1;
                    if (Request.QueryString["page"] != null)
                    {
                        page = int.Parse(Request.QueryString["page"]);
                    }

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

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

                    param[2] = new SqlParameter("@pagesize", SqlDbType.Int);
                    param[2].Value = RowPerPage;

                    param[3] = new SqlParameter("@count", SqlDbType.Int);
                    param[3].Value = DBNull.Value; //Chua biet gia tri
                    param[3].Direction = ParameterDirection.Output;
                    DataTable dt = new DataTable();

                    dt = dp.ExecuteProcQuery("sp_DanhSachGiaoDich", ref param);

                    List<GiaoDich> ls = new List<GiaoDich>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        GiaoDich item = new GiaoDich();

                        item.MaGiaoDich = (int)dt.Rows[i]["magiaodich"];
                        item.MaTaiKhoan = (int)dt.Rows[i]["mataikhoan"];
                        item.TenTaiKhoan = (String)dt.Rows[i]["ten"];
                        item.MaThueCanHo = (int)dt.Rows[i]["mathuecanho"];
                        item.MaTrangThaiGiaoDich = (int)dt.Rows[i]["matrangthaigiaodich"];
                        switch (item.MaTrangThaiGiaoDich)
                        {
                            case 1:
                                item.TrangThaiGiaoDich = TrangThaiGiaoDich.Cho_Xac_Nhan;
                                break;
                            case 2:
                                item.TrangThaiGiaoDich = TrangThaiGiaoDich.Dang_Giao_Dich;
                                break;
                            case 3:
                                item.TrangThaiGiaoDich = TrangThaiGiaoDich.Da_Giao_Dich;
                                break;
                            case 4:
                                item.TrangThaiGiaoDich = TrangThaiGiaoDich.Thanh_Toan_Hoan_Tat;
                                break;
                            case 5:
                                item.TrangThaiGiaoDich = TrangThaiGiaoDich.Giao_Dich_Huy_Bo;
                                break;
                        }

                        ls.Add(item);
                    }

                    ViewBag.RowPerPage = RowPerPage;
                    ViewBag.Page = page;
                    //Console.Write(param[3].Value.ToString());
                    ViewBag.Count = (int)param[3].Value;

                    return View("~/Views/Admin/GiaoDich/Index.cshtml", ls);

                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return Redirect("/Admin/");
                }
                //*/
            }
        }
Exemplo n.º 7
0
        //
        // GET: /CanHo/
        public ActionResult Index()
        {
            if (isLogin() == -1)
            {
                return Redirect("/DangNhap");
            }
            else if (isLogin() == 2)
            {
                return Redirect("/");
            }
            else
            {
                try
                {
                    DataProvider dp = new DataProvider();

                    int page = 1;
                    if (Request.QueryString["page"] != null)
                    {
                        page = int.Parse(Request.QueryString["page"]);
                    }

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

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

                    param[2] = new SqlParameter("@count", SqlDbType.Int);
                    param[2].Value = DBNull.Value;
                    param[2].Direction = ParameterDirection.Output;
                    DataTable dt = new DataTable();

                    dt = dp.ExecuteProcQuery("sp_DanhSachCanHo", ref param);

                    List<CanHo> ls = new List<CanHo>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        CanHo item = new CanHo();

                        item.MaCanHo = (int)dt.Rows[i]["macanho"];
                        item.TenCanHo = (string)dt.Rows[i]["tencanho"];
                        item.MaDuong = (int)dt.Rows[i]["maduong"];
                        item.DiaChi = (string)dt.Rows[i]["diachi"];

                        if (dt.Rows[i]["mieuta"] != DBNull.Value)
                        {
                            item.MieuTa = (string)dt.Rows[i]["mieuta"];
                        }

                        item.ToaDo = (string)dt.Rows[i]["toado"];
                        item.GiaThue = (double)dt.Rows[i]["giathue"];
                        item.DienTich = (double)dt.Rows[i]["dientich"];

                        switch ((int)dt.Rows[i]["matrangthaicanho"])
                        {
                            case 1:
                                item.TrangThaiCanHo = TrangThaiCanHo.Da_Duoc_Thue;
                                break;
                            case 2:
                                item.TrangThaiCanHo = TrangThaiCanHo.Chua_Duoc_Thue;
                                break;
                            case 3:
                                item.TrangThaiCanHo = TrangThaiCanHo.Dang_Xay_Dung;
                                break;
                        }

                        item.NgayDang = (DateTime)dt.Rows[i]["ngaydang"];
                        item.NguoiDang = (int)dt.Rows[i]["nguoidang"];

                        if (dt.Rows[i]["ghichu"] != DBNull.Value)
                        {
                            item.GhiChu = (string)dt.Rows[i]["ghichu"];
                        }

                        item.KichHoat = (int)dt.Rows[i]["kichhoat"];

                        ls.Add(item);
                    }

                    ViewBag.RowPerPage = RowPerPage;
                    ViewBag.Page = page;
                    //Console.Write(param[3].Value.ToString());
                    ViewBag.Count = (int)param[2].Value;

                    return View("~/Views/Admin/CanHo/Index.cshtml", ls);
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = ex.Message;
                    return Redirect("/Admin/");
                }

            }
        }