Exemple #1
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (cbSearch.SelectedValue.ToString() == "MaVe")
     {
         pdcs = BLL_PhieuDatCho.SearchMaVe(tbSearch.Text);
     }
     else if (cbSearch.SelectedValue.ToString() == "MaCB")
     {
         pdcs = BLL_PhieuDatCho.SearchMaCB(tbSearch.Text);
     }
     else if (cbSearch.SelectedValue.ToString() == "TenHK")
     {
         pdcs = BLL_PhieuDatCho.SearchTenHK(tbSearch.Text);
     }
     else if (cbSearch.SelectedValue.ToString() == "CMND")
     {
         pdcs = BLL_PhieuDatCho.SearchCMND(tbSearch.Text);
     }
     else if (cbSearch.SelectedValue.ToString() == "TG")
     {
         pdcs = BLL_PhieuDatCho.SearchThoiGian(tbSearch.Text);
     }
     bl = new SortableBindingList <PhieuDatCho>(pdcs);
     dgvBuyTicket.DataSource = bl;
 }
Exemple #2
0
        private void Edit(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 1 && (((DateTime)row.Cells["ThoiGian"].Value) - DateTime.Now).Hours < ThamSo.TGHuyDatVe)
            {
                Notification.Show("Phiếu đặt chỗ đã quá thời gian", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã quá thời gian\n-->Tiến hành hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán không thể chỉnh sửa", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán không thể chỉnh sửa");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy không thể chỉnh sửa", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy không thể chỉnh sửa");
                dialog1.ShowDialog();
                return;
            }
            AppState.state = Actions.EDIT;
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);

            var          dialog = new frmPhieuDatChoEditing(pdc);
            DialogResult res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                if (BLL_PhieuDatCho.UpdatePhieuDatCho(dialog.pdc))
                {
                    Notification.Show("Chỉnh sửa phiếu đặt chỗ thành công", Status.SUCCESS);
                }
                reloadData();
            }
            AppState.state = Actions.NOTHING;
        }
Exemple #3
0
        private void frmBookTicket_Load(object sender, EventArgs e)
        {
            cbSearch.DataSource    = sources();
            cbSearch.DisplayMember = "Name";
            cbSearch.ValueMember   = "ID";

            pdcs = BLL_PhieuDatCho.GetPhieuDatChos();
            bl   = new SortableBindingList <PhieuDatCho>(pdcs);
            dgvBuyTicket.DataSource = bl;
            CustomDgv();

            //Update scrollbar
            scrollHelper = new PanelScrollHelper(pnScroll, sb, false);
            scrollHelper.UpdateScrollBar();
        }
Exemple #4
0
        private void Sale(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 1 && (((DateTime)row.Cells["ThoiGian"].Value) - DateTime.Now).Hours < ThamSo.TGHuyDatVe)
            {
                Notification.Show("Phiếu đặt chỗ đã quá thời gian", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã quá thời gian\n-->Tiến hành hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy không thể bán", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy không thể bán");
                dialog1.ShowDialog();
                return;
            }
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc    = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);
            var         dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn bán vé không?");
            var         res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                pdc.tinhTrang = 2;
                if (BLL_PhieuDatCho.SalePhieuDatCho(pdc))
                {
                    Notification.Show("Bán vé thành công", Status.SUCCESS);
                }
                BLL_PhieuDatCho.UpdatePhieuDatCho(pdc);
                reloadData();
            }
        }
Exemple #5
0
        public override void Create()
        {
            AppState.state = Actions.ADD;
            var          dialog = new frmPhieuDatChoEditing();
            DialogResult res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                int newMave = BLL_IdenMaVe.GetNewMaVe();
                if (BLL_PhieuDatCho.InsertPhieuDatCho(dialog.pdc, newMave))
                {
                    Notification.Show("Thêm phiếu đặt chỗ thành công", Status.SUCCESS);
                    BLL_IdenMaVe.ClearIden();
                }
                reloadData();
            }
            AppState.state = Actions.NOTHING;
        }
Exemple #6
0
        private void cancel(DataGridViewRow row)
        {
            if ((int)row.Cells["TinhTrang"].Value == 2)
            {
                Notification.Show("Phiếu đặt chỗ đã bán không thể hủy", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã bán không thể hủy");
                dialog1.ShowDialog();
                return;
            }
            else if ((int)row.Cells["TinhTrang"].Value == 3)
            {
                Notification.Show("Phiếu đặt chỗ đã hủy", Status.WARNING);
                var dialog1 = new frmWarning("Thông Báo", "Phiếu đặt chỗ đã hủy");
                dialog1.ShowDialog();
                return;
            }
            int      maVe      = (int)row.Cells["MaVe"].Value;
            int      maCB      = (int)row.Cells["MaCB"].Value;
            string   tenHK     = (string)row.Cells["TenHK"].Value;
            string   cmnd      = (string)row.Cells["CMND"].Value;
            string   dienThoai = (string)row.Cells["DienThoai"].Value;
            DateTime thoiGian  = (DateTime)row.Cells["ThoiGian"].Value;
            HangVe   hv        = (HangVe)row.Cells["HV"].Value;
            int      giaVe     = (int)row.Cells["GiaVe"].Value;
            int      tt        = (int)row.Cells["TinhTrang"].Value;

            PhieuDatCho pdc    = new PhieuDatCho(maVe, maCB, tenHK, cmnd, dienThoai, thoiGian, hv, giaVe, tt);
            var         dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn hủy phiếu đặt ghế không?");
            var         res    = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                pdc.tinhTrang = 3;
                if (BLL_PhieuDatCho.UpdatePhieuDatCho(pdc))
                {
                    Notification.Show("Hủy phiếu đặt chỗ thành công", Status.SUCCESS);
                }
                reloadData();
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!BLL_ChuyenBay.CheckGhe((int)cbMaCB.SelectedValue))
            {
                lbNoti.Text = "Chuyến bay này đã hết ghế";
                lbNoti.Show();
                return;
            }
            if (!BLL_CTHV.CheckGhe((int)cbMaCB.SelectedValue, (int)cbHangVe.SelectedValue))
            {
                lbNoti.Text = "Hạng vé này đã hết ghế";
                lbNoti.Show();
                return;
            }
            if ((((ChuyenBay)cbMaCB.SelectedItem).ThoiGian - DateTime.Now).Days < ThamSo.TGDatVeChamNhat)
            {
                lbNoti.Text = "Chỉ được đặt vé chậm nhất trước " + ThamSo.TGDatVeChamNhat + " ngày trước ngày xuất phát";
                lbNoti.Show();
                return;
            }
            if (tbTenHK.Text == "")
            {
                lbNoti.Text = "Tên khách hàng không được bỏ trống";
                lbNoti.Show();
                return;
            }
            if (tbCMND.Text == "")
            {
                lbNoti.Text = "CMND không được bỏ trống";
                lbNoti.Show();
                return;
            }
            if (tbDienThoai.Text == "")
            {
                lbNoti.Text = "Điện thoại không được bỏ trống";
                lbNoti.Show();
                return;
            }

            pdc.maCB      = (int)cbMaCB.SelectedValue;
            pdc.GiaVe     = Convert.ToInt32(((ChuyenBay)cbMaCB.SelectedItem).DonGia * ((HangVe)cbHangVe.SelectedItem).TiLe);
            pdc.ThoiGian  = DateTime.ParseExact(tbNgayGio.Text, "hh:mm tt dd/MM/yyyy", null);
            pdc.TenHK     = tbTenHK.Text;
            pdc.HV        = cbHangVe.SelectedItem as HangVe;
            pdc.CMND      = tbCMND.Text;
            pdc.DienThoai = tbDienThoai.Text;

            if (rbDat.Checked)
            {
                pdc.tinhTrang = 1;
            }
            else if (rbDaBan.Checked)
            {
                pdc.tinhTrang = 2;
                var dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn bán vé không?");
                var res    = dialog.ShowDialog();
                if (res == DialogResult.OK)
                {
                    BLL_PhieuDatCho.SalePhieuDatCho(pdc);
                }
                else if (res == DialogResult.Cancel)
                {
                    return;
                }
            }
            else if (rbDaHuy.Checked)
            {
                pdc.tinhTrang = 3;
                var dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn hủy phiếu đặt ghế không?");
                var res    = dialog.ShowDialog();
                if (res == DialogResult.OK)
                {
                }
                else if (res == DialogResult.Cancel)
                {
                    return;
                }
            }


            button1.PerformClick();
        }
Exemple #8
0
 private void reloadData()
 {
     pdcs = BLL_PhieuDatCho.GetPhieuDatChos();
     bl   = new SortableBindingList <PhieuDatCho>(pdcs);
     dgvBuyTicket.DataSource = bl;
 }