Exemple #1
0
        private void btCapNhat_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            HoaDon          hoaDon          = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);
            int             pos;

            foreach (MatHang matHang in matHangChoList)
            {
                pos = kiemTraChiTietHoaDon(matHang.id);
                if (pos == -1)
                {
                    ChiTietHoaDonBUS.addChiTietHoaDon(new ChiTietHoaDon(0, hoaDon.id, matHang.id, matHang.soLuong, matHang.donGia));
                }
                else
                {
                    ((ChiTietHoaDon)chiTietHoaDonList[pos]).soLuong = matHang.soLuong;
                    ChiTietHoaDonBUS.updateChiTietHoaDon((ChiTietHoaDon)chiTietHoaDonList[pos]);
                }
            }
            hoaDon.tenKhachHang = tbTenKhachHang.Text;
            HoaDonBUS.updateHoaDon(hoaDon);
            phieuDatSanBong.thoiGianBatDau = dtpGioVao.Value;
            phieuDatSanBong.soGioDat       = (int)nudSoGio.Value;

            PhieuDatSanBongBUS.updatePhieuDatSanBong(phieuDatSanBong);
        }
        public static ArrayList getAllPhieuDatSanBong()
        {
            ArrayList dataList = new ArrayList();

            try
            {
                DataSet dataSet = PhieuDatSanBongDAO.getAllPhieuDatSanBong();

                foreach (DataRow row in dataSet.Tables[0].Rows)
                {
                    int      id             = Convert.ToInt32(row["id"]);
                    int      idSanBong      = Convert.ToInt32(row["idSanBong"]);
                    DateTime thoiGianBatDau = (DateTime)row["thoiGianBatDau"];
                    int      soGioDat       = Convert.ToInt32(row["soGioDat"]);
                    float    donGia         = (float)Convert.ToDouble(row["donGia"]);
                    int      idHoaDon       = 0;
                    idHoaDon = Convert.ToInt32(row["idHoaDon"]);

                    PhieuDatSanBong phieuDatSanBong = new PhieuDatSanBong(id, idSanBong, thoiGianBatDau, soGioDat, donGia, idHoaDon);
                    dataList.Add(phieuDatSanBong);
                }
            }
            catch (SqlException e)
            {
            }
            return(dataList);
        }
        public static PhieuDatSanBong getLatestPhieuDatSanBong(int idSanBong)
        {
            PhieuDatSanBong phieuDatSanBong = null;

            try
            {
                DataSet dataSet = PhieuDatSanBongDAO.getAllPhieuDatSanBong(idSanBong);

                DataRow row = dataSet.Tables[0].Rows[dataSet.Tables[0].Rows.Count - 1];

                int      id             = Convert.ToInt32(row["id"]);
                DateTime thoiGianBatDau = (DateTime)row["thoiGianBatDau"];
                //int idNganhHang1 = Convert.ToInt32(row["idNganhHang"]);
                int   soGioDat = Convert.ToInt32(row["soGioDat"]);
                float donGia   = (float)Convert.ToDouble(row["donGia"]);
                int   idHoaDon = 0;
                idHoaDon = Convert.ToInt32(row["idHoaDon"]);

                phieuDatSanBong = new PhieuDatSanBong(id, idSanBong, thoiGianBatDau, soGioDat, donGia, idHoaDon);
            }
            catch (SqlException e)
            {
            }
            return(phieuDatSanBong);
        }
Exemple #4
0
        private void btThuTien_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            HoaDon          hoaDon          = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);

            hoaDon.daThanhToan = true;
            HoaDonBUS.updateHoaDon(hoaDon);
            btThuTien.Enabled = false;
        }
Exemple #5
0
        private void btDoiSan_Click(object sender, EventArgs e)
        {
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
            SanBong         sanBongDoi      = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];

            phieuDatSanBong.idSanBong = sanBongDoi.id;


            if (!PhieuDatSanBongBUS.updatePhieuDatSanBong(phieuDatSanBong))
            {
                MessageBox.Show("That Bai");
            }
            this.Close();
        }
        public static bool addPhieuDatSanBong(PhieuDatSanBong phieuDatSanBong)
        {
            bool kt = true;

            try
            {
                PhieuDatSanBongDAO.addPhieuDatSanBong(phieuDatSanBong.idSanBong, phieuDatSanBong.thoiGianBatDau,
                                                      phieuDatSanBong.soGioDat, phieuDatSanBong.donGia, phieuDatSanBong.idHoaDon);
            }
            catch (SqlException e)
            {
                kt = false;
            }
            return(kt);
        }
Exemple #7
0
        private void btHuySan_Click(object sender, EventArgs e)
        {
            SanBong         sanBong         = (SanBong)sanBongList[lvSanBong.SelectedIndices[0]];
            PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);

            if (HoaDonBUS.deleteHoaDon(phieuDatSanBong.idHoaDon))
            {
                statusBarAddText("Hủy sân thành công");
                updateListViewSan();
            }
            else
            {
                MessageBox.Show("Không thể hủy sân!" + lvSanBong.SelectedItems[0].Text, "Lỗi khi hủy sân",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                statusBarAddText("Lỗi khi hủy sân!");
            }
        }
Exemple #8
0
        private void lvSanBong_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvSanBong.SelectedItems.Count > 0)
            {
                tbTenSan.Text       = (lvSanBong.SelectedItems[0]).Text;
                nudDonGia.Value     = (decimal)((SanBong)sanBongList[lvSanBong.SelectedIndices[0]]).donGia;
                btSuaSan.Enabled    = true;
                btXoaSan.Enabled    = true;
                tabTinhTien.Enabled = true;

                SanBong sanBong = ((SanBong)sanBongList[lvSanBong.SelectedIndices[0]]);
                if (sanBong.dangThue)
                {
                    PhieuDatSanBong phieuDatSanBong = PhieuDatSanBongBUS.getLatestPhieuDatSanBong(sanBong.id);
                    tbTenKhachHang.Text = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon).tenKhachHang;
                    dtpGioVao.Value     = phieuDatSanBong.thoiGianBatDau;
                    nudSoGio.Value      = phieuDatSanBong.soGioDat;
                    dtpGioRa.Value      = phieuDatSanBong.thoiGianBatDau.AddHours((double)phieuDatSanBong.soGioDat);
                    btDatSan.Enabled    = false;
                    loadLvChiTietHoaDon(phieuDatSanBong.idHoaDon);
                    btDoiSan.Enabled  = true;
                    btCapNhat.Enabled = true;
                    btHuySan.Enabled  = true;
                    HoaDon hoaDon = HoaDonBUS.getHoaDon(phieuDatSanBong.idHoaDon);
                    if (hoaDon.daThanhToan)
                    {
                        btThuTien.Enabled = false;

                        btDoiSan.Enabled          = false;
                        btCapNhat.Enabled         = false;
                        gbMatHangTinhTien.Enabled = false;

                        lbThanhToan.Text = "ĐÃ THANH TOÁN";
                    }
                    else
                    {
                        btThuTien.Enabled         = true;
                        lbThanhToan.Text          = "CHƯA THANH TOÁN";
                        btDoiSan.Enabled          = true;
                        btCapNhat.Enabled         = true;
                        gbMatHangTinhTien.Enabled = true;
                    }
                }
                else
                {
                    btDatSan.Enabled = true;
                    matHangChoList.Clear();
                    btDoiSan.Enabled  = false;
                    btCapNhat.Enabled = false;
                    btHuySan.Enabled  = false;
                    btThuTien.Enabled = false;


                    gbMatHangTinhTien.Enabled = true;
                }
                tbTenSanTT.Text = sanBong.tenSan;
            }
            else
            {
                tbTenSan.Text       = "";
                btSuaSan.Enabled    = false;
                btXoaSan.Enabled    = false;
                tabTinhTien.Enabled = false;
                tbTenSanTT.Text     = "";
                tbTenKhachHang.Text = "";
                nudSoGio.Value      = 0;
                dtpGioVao.Value     = DateTime.Now;
                dtpGioRa.Value      = DateTime.Now;
                tbTienSan.Text      = "";
                tbTienHang.Text     = "";
                nudGiamGia.Value    = 0;
                nudTienKhac.Value   = 0;
                lvChiTietHoaDon.Items.Clear();
                nudDonGia.Value  = 0;
                btDoiSan.Enabled = false;
                lbThanhToan.Text = "CHƯA THANH TOÁN";
            }
            loadTinhTien();
        }