Ejemplo n.º 1
0
        private void btnTraPhong_Click(object sender, EventArgs e)
        {
            bus_khachTro.xoaKhach(txtMaKhach.Text);
            bus_chiTietPhong.xoaChiTietPhong(lblPhong.Text);
            bus_hoaDon.xoaHoaDon(lblMaHoaDon.Text);
            bus_chiTietHoaDon.xoaChiTietHoaDon(lblMaHoaDon.Text);
            PHONGTRO phongTam = bus_phongTro.layDoiTuongPhongTheoMaPhong(lblPhong.Text);
            string   tam      = "Trống";

            phongTam.TRANGTHAI = tam;
            bus_phongTro.capNhatPhong(phongTam);

            MetroMessageBox.Show(Owner, "Tra phong thanh cong", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //capnhat lai trang thai
            int soTang = Int32.Parse(cbbTrang.SelectedIndex.ToString());

            bus_phongTro.capNhatSoNguoiTrongPhong(lblPhong.Text, Int32.Parse(txtSoNguoiO.Text));
            List <PHONGTRO> danhSachPhongTheoTang = bus_phongTro.layPhongTheoTang(soTang * 15, 15);

            resetTrangThai();
            hienThiPhong(danhSachPhongTheoTang);

            txtDiaChiThuongTru.Text  = "";
            txtMaKhach.Text          = "";
            txtTenKhach.Text         = "";
            txtsoDienThoai.Text      = "";
            txtSoNguoiO.Text         = "";
            txtsoCMND.Text           = "";
            lblTienPhong.Text        = "";
            lblTongTienDichVu.Text   = "";
            lblTongTienHD.Text       = "";
            pnlXuLyThuePhong.Visible = false;
        }
Ejemplo n.º 2
0
        public PHONGTRO GetId(int MaPhongTro)
        {
            PHONGTRO pt = new PHONGTRO();

            using (SqlConnection connection = con())
            {
                pt = (PHONGTRO)connection.Query <PHONGTRO>("select TOP 1 * from PHONGTRO where MaPhongTro=" + MaPhongTro).FirstOrDefault();
                return(pt);
            }
        }
Ejemplo n.º 3
0
        public int Update(PHONGTRO phongTro)
        {
            int count = 0;

            using (SqlConnection connection = con())
            {
                count = connection.Execute("UPDATE PHONGTRO SET TenPhongTro= @TenPhongTro, DienTich= @DienTich, LoaiPhong=@LoaiPhong,GiaPhong=@GiaPhongTro,trangThai=@trangThai WHERE MaPhongTro=@MaPhongTro", phongTro);
            }
            return(count);
        }
Ejemplo n.º 4
0
        private void btnThemPhong_Click(object sender, EventArgs e)
        {
            string maPhong   = txtmaPhong.Text;
            int    soNguoiO  = Int32.Parse(txtSoNguoiO.Text);
            double tienPhong = double.Parse(txtTienPhong.Text);
            string trangThai = boxTrangThai.SelectedItem.ToString();

            PHONGTRO phong = new PHONGTRO(maPhong, trangThai, tienPhong, soNguoiO);

            bus_phongTro.themPhong(phong);
            bus_phongTro.layPhong();
            MetroMessageBox.Show(Owner, "Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 5
0
        public IActionResult Post(PHONGTRO pt)
        {
            if (unitOfWork.PhongTro.Add(pt) == 0)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Reponse {
                    Status = "error", Massage = "error"
                }));
            }

            return(Ok(new Reponse {
                Status = "succes", Massage = "succes"
            }));
        }
Ejemplo n.º 6
0
        private void AddRoom()
        {
            PHONGTRO pHONGTRO = new PHONGTRO
            {
                MaPhong     = getID(),
                TenPhong    = txtRoomName.Text,
                MaTrangThai = int.Parse(cboStatus.SelectedValue.ToString()),
                DienTich    = double.Parse(txtCapacity.Text),
                MoTa        = txtDescription.Text,
            };

            mod.PHONGTRO.Add(pHONGTRO);
            mod.SaveChanges();
        }
Ejemplo n.º 7
0
        //private string getID()
        //{
        //    string result = "";
        //    List<HOPDONG> ps = mod.HOPDONG.ToList();
        //    if (ps.Any() == false)
        //    {
        //        result = "HD00000001";
        //    }
        //    else
        //    {
        //        var R = ps.Last();
        //        int i = R.MaHopDong.IndexOf("0");
        //        string first = "HD";
        //        int last = int.Parse(R.MaHopDong.Substring(i + 1)) + 1;
        //        result = first + last.ToString().PadLeft(8, '0');
        //    }

        //    return result;
        //}
        private void updateRoom()
        {
            connectDBEntity mod1     = new connectDBEntity();
            DateTime        now      = DateTime.Now;
            PHONGTRO        pHONGTRO = mod1.PHONGTRO.FirstOrDefault(p => p.MaPhong == cboRoomName.SelectedValue.ToString());

            if (dtpStart.Value <= now)
            {
                pHONGTRO.MaTrangThai = 3;
            }
            else
            {
                pHONGTRO.MaTrangThai = 2;
            }
            mod1.SaveChanges();
        }
Ejemplo n.º 8
0
        private void update()
        {
            PHONGTRO pHONGTRO = mod.PHONGTRO.FirstOrDefault(p => p.MaPhong == ID);

            pHONGTRO.TenPhong    = txtRoomName.Text;
            pHONGTRO.MaPhong     = txtRoomID.Text;
            pHONGTRO.MaTrangThai = int.Parse(cboStatus.SelectedValue.ToString());
            pHONGTRO.DienTich    = double.Parse(txtAcreage.Text.ToString());
            pHONGTRO.SoNguoiO    = int.Parse(txtCapacity.Text);
            pHONGTRO.MoTa        = txtDescription.Text;
            var TY = mod.HOPDONG.FirstOrDefault(a => a.MaPhong == txtRoomID.Text);
            var CT = mod.CHITIETHOPDONG.FirstOrDefault(a => a.MaHopDong == TY.MaHopDong);

            CT.TenPhong = txtRoomName.Text;
            mod.SaveChanges();
        }
Ejemplo n.º 9
0
        public int Add(PHONGTRO phongTro)
        {
            int x;

            using (SqlConnection connection = con())
            {
                connection.Open();

                x = connection.Query <PHONGTRO>($"SELECT UPPER(TenPhongTro) From PHONGTRO Where Replace(dbo.TRIM1(UPPER(dbo.ufn_removeMark(TenPhongTro))),' ','')=REPLACE(dbo.TRIM1(UPPER(dbo.ufn_removeMark(@TenPhongTro))), ' ', '')", phongTro, commandType: CommandType.Text).Count();
                if (x <= 0)
                {
                    connection.Execute("insert PHONGTRO values(@TenPhongTro,@DienTich,@LoaiPhong,@GiaPhongTro,@trangThai)", phongTro);
                    return(1);
                }
                return(0);
            }
        }
Ejemplo n.º 10
0
        private void btnXacNhanThuePhong_Click(object sender, EventArgs e)
        {
            string   diaChiThuongTru = txtDiaChiThuongTru.Text;
            string   gioiTinh        = txtGioiTinh.SelectedItem.ToString();
            string   maKhach         = txtMaKhach.Text;
            DateTime ngaySinh        = txtNgaySinh.Value.Date;
            string   soCMND          = txtsoCMND.Text;
            string   soDienThoai     = txtsoDienThoai.Text;
            string   tenKhach        = txtTenKhach.Text;
            string   maPhong         = lblPhong.Text;

            KHACHTRO khachThuePhong = new KHACHTRO(maKhach, tenKhach, maPhong, ngaySinh, gioiTinh, soDienThoai, diaChiThuongTru, soCMND);
            HOADON   hoaDonThue     = new HOADON(lblMaHoaDon.Text, maKhach, nhanVienDangDangNhap.MANHANVIEN, lblPhong.Text, DateTime.Now.Date, double.Parse(lblTongTienHD.Text));

            bus_hoaDon.themHoaDon(hoaDonThue);
            bus_khachTro.themKhach(khachThuePhong);
            PHONGTRO phong = new PHONGTRO(maPhong, "Đang Ở", float.Parse(lblTienPhong.Text), Int32.Parse(txtSoNguoiO.Text));

            bus_phongTro.capNhatPhong(phong);
            for (int i = 0; i < gridChiTietHoaDon2.RowCount; i++)
            {
                CHITIETHOADON chiTietHoaDon = new CHITIETHOADON(gridChiTietHoaDon2.Rows[i].Cells[0].Value.ToString(), gridChiTietHoaDon2.Rows[i].Cells[1].Value.ToString(), 0, Int32.Parse(gridChiTietHoaDon2.Rows[i].Cells[3].Value.ToString()), float.Parse(gridChiTietHoaDon2.Rows[i].Cells[4].Value.ToString()));
                bus_chiTietHoaDon.themChiTietHoaDon(chiTietHoaDon);
            }
            MetroMessageBox.Show(Owner, "Thue Thanh cong", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

            int             soTang = Int32.Parse(cbbTrang.SelectedIndex.ToString());
            List <PHONGTRO> danhSachPhongTheoTang = bus_phongTro.layPhongTheoTang(soTang * 15, 15);

            resetTrangThai();
            hienThiPhong(danhSachPhongTheoTang);

            txtDiaChiThuongTru.Text  = "";
            txtMaKhach.Text          = "";
            txtTenKhach.Text         = "";
            txtsoDienThoai.Text      = "";
            txtSoNguoiO.Text         = "";
            txtsoCMND.Text           = "";
            lblTienPhong.Text        = "";
            lblTongTienDichVu.Text   = "";
            lblTongTienHD.Text       = "";
            pnlXuLyThuePhong.Visible = false;
        }
Ejemplo n.º 11
0
        public void hienThiTrangThaiPhong(PHONGTRO phong, MetroFramework.Controls.MetroTile nutPhong)
        {
            if (phong != null)
            {
                nutPhong.Text = phong.MAPHONG;
                switch (phong.TRANGTHAI)
                {
                case "Trống":
                    nutPhong.BackColor = Color.Gray;
                    break;

                case "Đang Ở":
                    DateTime ngayHienTai = DateTime.Now.Date;
                    KHACHTRO khachTro    = bus_khachTro.layKhachTheoMaPhong(phong.MAPHONG);
                    if (khachTro != null)
                    {
                        HOADON hoaDon = bus_hoaDon.layHoaDonTheoMaKhach(khachTro.MAKHACH);
                        if (hoaDon != null)
                        {
                            DateTime ngayCuaHoaDon = hoaDon.NGAYLAP.Date;
                            TimeSpan ketQua        = ngayHienTai - ngayCuaHoaDon;
                            if (ketQua.Days >= 30)
                            {
                                nutPhong.BackColor = Color.Red;
                            }
                            else if (ketQua.Days < 30 && ketQua.Days >= 25)
                            {
                                nutPhong.BackColor = Color.Gold;
                            }
                            else if (ketQua.Days < 25)
                            {
                                nutPhong.BackColor = Color.YellowGreen;
                            }
                        }
                    }
                    break;
                }
                nutPhong.Enabled = true;
            }
        }
Ejemplo n.º 12
0
 public bool capNhatPhong(PHONGTRO phong)
 {
     return(dal_phongTro.capNhatPhong(phong));
 }
Ejemplo n.º 13
0
 public bool themPhong(PHONGTRO phong)
 {
     return(dal_phongTro.themPhong(phong));
 }
Ejemplo n.º 14
0
        public void xuLyChonPhong(MetroFramework.Controls.MetroTile nut)
        {
            if (nut.BackColor == Color.YellowGreen)
            {
                gridChiTietHoaDon2.DataSource = null;
                if (gridChiTietHoaDon2.RowCount > 0)
                {
                    gridChiTietHoaDon2.Rows.Clear();
                    gridChiTietHoaDon2.Columns.Clear();
                }
                txtDien.Visible     = false;
                txtNuoc.Visible     = false;
                label12.Visible     = false;
                label17.Visible     = false;
                ckcCap.Enabled      = false;
                ckcRac.Enabled      = false;
                ckcXe.Enabled       = false;
                ckcInternet.Enabled = false;
                lblPhong.Text       = nut.Text;
                KHACHTRO khach = bus_khachTro.layKhachTheoMaPhong(nut.Text);
                if (khach != null)
                {
                    HOADON hoaDon = bus_hoaDon.layHoaDonTheoMaKhach(khach.MAKHACH);
                    lblMaHoaDon.Text        = hoaDon.MAHOADON;
                    txtDiaChiThuongTru.Text = khach.DIACHITHUONGTRU;
                    txtGioiTinh.Text        = khach.GIOITINH;
                    txtMaKhach.Text         = khach.MAKHACH;
                    txtNgaySinh.Text        = khach.NGAYSINH.ToString();
                    txtsoCMND.Text          = khach.SOCMND;
                    txtsoDienThoai.Text     = khach.SODIENTHOAI;
                    txtTenKhach.Text        = khach.TENKHACH;

                    PHONGTRO phong = bus_phongTro.layDoiTuongPhongTheoMaPhong(lblPhong.Text);
                    if (phong != null)
                    {
                        txtSoNguoiO.Text = phong.SONGUOIO.ToString();
                    }


                    gridChiTietHoaDon2.DataSource            = bus_chiTietHoaDon.layChiTietHoaDonTheoMaHoaDon(hoaDon.MAHOADON);
                    gridChiTietHoaDon2.Columns[0].HeaderText = "Mã Hóa Đơn";
                    gridChiTietHoaDon2.Columns[1].HeaderText = "Tên Dịch Vụ";
                    gridChiTietHoaDon2.Columns[2].HeaderText = "Số Cũ";
                    gridChiTietHoaDon2.Columns[3].HeaderText = "Số Lượng";
                    gridChiTietHoaDon2.Columns[4].HeaderText = "Thành Tiền";


                    double tongTienDichvu = 0;
                    for (int i = 0; i < gridChiTietHoaDon2.RowCount; i++)
                    {
                        tongTienDichvu += double.Parse(gridChiTietHoaDon2.Rows[i].Cells[4].Value.ToString());
                    }
                    lblTongTienDichVu.Text = string.Format("{0:n}", double.Parse(tongTienDichvu.ToString()));
                    PHONGTRO phongTam = bus_phongTro.layDoiTuongPhongTheoMaPhong(nut.Text);
                    if (phongTam != null)
                    {
                        lblTienPhong.Text = string.Format("{0:n}", double.Parse(phongTam.TIENPHONG.ToString()));
                    }
                    lblTongTienHD.Text = string.Format("{0:n}", double.Parse(hoaDon.TONGTIEN.ToString()));
                }
                btnTraPhong.Enabled         = true;
                btnThanhToan.Enabled        = false;
                btnXacNhanThuePhong.Enabled = false;
                pnlXuLyThuePhong.Visible    = true;
            }
            else if (nut.BackColor == Color.Gray)
            {
                gridChiTietHoaDon2.DataSource = null;
                if (gridChiTietHoaDon2.RowCount > 0)
                {
                    gridChiTietHoaDon2.Rows.Clear();
                    gridChiTietHoaDon2.Columns.Clear();
                }
                txtDien.Visible             = false;
                txtNuoc.Visible             = false;
                label12.Visible             = false;
                label17.Visible             = false;
                lblPhong.Text               = nut.Text;
                lblMaHoaDon.Text            = tuSinhMaHoaDon(bus_hoaDon.dem());
                btnThanhToan.Enabled        = false;
                btnTraPhong.Enabled         = false;
                btnXacNhanThuePhong.Enabled = true;
                pnlXuLyThuePhong.Visible    = true;
                ckcCap.Enabled              = true;
                ckcRac.Enabled              = true;
                ckcXe.Enabled               = true;
                ckcInternet.Enabled         = true;
                PHONGTRO phong = bus_phongTro.layDoiTuongPhongTheoMaPhong(lblPhong.Text);
                lblTienPhong.Text = phong.TIENPHONG.ToString();
                gridChiTietHoaDon2.Columns.Add("0 ", "Mã hóa đơn");
                gridChiTietHoaDon2.Columns.Add("1", "Tên dịch vụ");
                gridChiTietHoaDon2.Columns.Add("2", "Số cũ");
                gridChiTietHoaDon2.Columns.Add("3", "Số lượng");
                gridChiTietHoaDon2.Columns.Add("4", "Thành tiền");

                gridChiTietHoaDon2.Rows.Add(6);

                dichVu = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Điện");
                gridChiTietHoaDon2.Rows[0].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[0].Cells[1].Value = "Điện";
                gridChiTietHoaDon2.Rows[0].Cells[2].Value = 0;
                gridChiTietHoaDon2.Rows[0].Cells[3].Value = 0;
                gridChiTietHoaDon2.Rows[0].Cells[4].Value = 0;

                dichVu2 = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Nước");
                gridChiTietHoaDon2.Rows[1].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[1].Cells[1].Value = "Nước";
                gridChiTietHoaDon2.Rows[1].Cells[2].Value = 0;
                gridChiTietHoaDon2.Rows[1].Cells[3].Value = 0;
                gridChiTietHoaDon2.Rows[1].Cells[4].Value = 0;

                dichVu3 = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Rác");
                gridChiTietHoaDon2.Rows[2].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[2].Cells[1].Value = "Rác";
                gridChiTietHoaDon2.Rows[2].Cells[2].Value = "";
                gridChiTietHoaDon2.Rows[2].Cells[3].Value = 1;
                gridChiTietHoaDon2.Rows[2].Cells[4].Value = dichVu3.DONGIA * float.Parse(gridChiTietHoaDon2.Rows[2].Cells[3].Value.ToString());

                dichVu4 = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Xe");
                gridChiTietHoaDon2.Rows[3].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[3].Cells[1].Value = "Xe";
                gridChiTietHoaDon2.Rows[3].Cells[2].Value = "";
                gridChiTietHoaDon2.Rows[3].Cells[3].Value = 1;
                gridChiTietHoaDon2.Rows[3].Cells[4].Value = dichVu4.DONGIA * float.Parse(gridChiTietHoaDon2.Rows[3].Cells[3].Value.ToString());

                dichVu5 = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Internet");
                gridChiTietHoaDon2.Rows[4].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[4].Cells[1].Value = "Internet";
                gridChiTietHoaDon2.Rows[4].Cells[2].Value = "";
                gridChiTietHoaDon2.Rows[4].Cells[3].Value = 1;
                gridChiTietHoaDon2.Rows[4].Cells[4].Value = dichVu5.DONGIA * float.Parse(gridChiTietHoaDon2.Rows[4].Cells[3].Value.ToString());

                dichVu6 = bus_dichVu.layDoiTuongDichVuBangTenDichVu("Cáp");
                gridChiTietHoaDon2.Rows[5].Cells[0].Value = lblMaHoaDon.Text;
                gridChiTietHoaDon2.Rows[5].Cells[1].Value = "Cáp";
                gridChiTietHoaDon2.Rows[5].Cells[2].Value = "";
                gridChiTietHoaDon2.Rows[5].Cells[3].Value = 1;
                gridChiTietHoaDon2.Rows[5].Cells[4].Value = dichVu6.DONGIA * float.Parse(gridChiTietHoaDon2.Rows[5].Cells[3].Value.ToString());

                double tongTienDichvu = 0;
                for (int i = 0; i < gridChiTietHoaDon2.RowCount; i++)
                {
                    tongTienDichvu += double.Parse(gridChiTietHoaDon2.Rows[i].Cells[4].Value.ToString());
                }
                lblTongTienDichVu.Text = string.Format("{0:n}", double.Parse(tongTienDichvu + ""));
                lblTongTienHD.Text     = string.Format("{0:n}", double.Parse((tongTienDichvu + double.Parse(lblTienPhong.Text)).ToString()));
            }
            else if (nut.BackColor == Color.Gold || nut.BackColor == Color.Red)
            {
                ckcCap.Enabled      = false;
                ckcRac.Enabled      = false;
                ckcXe.Enabled       = false;
                ckcInternet.Enabled = false;
                txtDien.Visible     = true;
                txtNuoc.Visible     = true;
                label12.Visible     = true;
                label17.Visible     = true;
                lblPhong.Text       = nut.Text;
                KHACHTRO khach = bus_khachTro.layKhachTheoMaPhong(nut.Text);
                if (khach != null)
                {
                    HOADON hoaDon = bus_hoaDon.layHoaDonTheoMaKhach(khach.MAKHACH);
                    lblMaHoaDon.Text        = hoaDon.MAHOADON;
                    txtDiaChiThuongTru.Text = khach.DIACHITHUONGTRU;
                    txtGioiTinh.Text        = khach.GIOITINH;
                    txtMaKhach.Text         = khach.MAKHACH;
                    txtNgaySinh.Text        = khach.NGAYSINH.ToString();
                    txtsoCMND.Text          = khach.SOCMND;
                    txtsoDienThoai.Text     = khach.SODIENTHOAI;
                    txtTenKhach.Text        = khach.TENKHACH;
                    PHONGTRO phong = bus_phongTro.layDoiTuongPhongTheoMaPhong(lblPhong.Text);
                    if (phong != null)
                    {
                        txtSoNguoiO.Text = phong.SONGUOIO.ToString();
                    }
                    gridChiTietHoaDon2.DataSource = null;
                    if (gridChiTietHoaDon2.RowCount > 0)
                    {
                        gridChiTietHoaDon2.Rows.Clear();
                        gridChiTietHoaDon2.Columns.Clear();
                    }
                    gridChiTietHoaDon2.DataSource            = bus_chiTietHoaDon.layChiTietHoaDonTheoMaHoaDon(hoaDon.MAHOADON);
                    gridChiTietHoaDon2.Columns[0].HeaderText = "Mã Hóa Đơn";
                    gridChiTietHoaDon2.Columns[1].HeaderText = "Tên Dịch Vụ";
                    gridChiTietHoaDon2.Columns[2].HeaderText = "Số Cũ";
                    gridChiTietHoaDon2.Columns[3].HeaderText = "Số Lượng";
                    gridChiTietHoaDon2.Columns[4].HeaderText = "Thành Tiền";
                    double tongTienDichvu = 0;
                    for (int i = 0; i < gridChiTietHoaDon2.RowCount; i++)
                    {
                        tongTienDichvu += double.Parse(gridChiTietHoaDon2.Rows[i].Cells[4].Value.ToString());
                    }
                    lblTongTienDichVu.Text = string.Format("{0:n}", double.Parse(tongTienDichvu.ToString()));
                    PHONGTRO phongTam = bus_phongTro.layDoiTuongPhongTheoMaPhong(nut.Text);
                    if (phongTam != null)
                    {
                        lblTienPhong.Text = string.Format("{0:n}", double.Parse(phongTam.TIENPHONG.ToString()));
                    }
                    lblTongTienHD.Text = string.Format("{0:n}", double.Parse(hoaDon.TONGTIEN.ToString()));
                }
                btnTraPhong.Enabled         = false;
                btnXacNhanThuePhong.Enabled = false;
                btnThanhToan.Enabled        = true;
                pnlXuLyThuePhong.Visible    = true;
            }
        }
Ejemplo n.º 15
0
 public IActionResult Put(PHONGTRO pt)
 {
     unitOfWork.PhongTro.Update(pt);
     return(Ok());
 }