Beispiel #1
0
        public void procedure_UpdatePhieuDat()
        {
            while (isRunning)
            {
                if (bllTS.getQuyDinhHuy() <= 0)
                {
                    return;
                }
                DataTable dt = bllPDC.getThongTinPhieuHuy();
                if (dt == null)
                {
                    return;
                }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DanhSachGhe DSG = new DanhSachGhe();
                    DSG.MaChuyenBay = dt.Rows[i][1].ToString();
                    DSG.HangVe      = dt.Rows[i][2].ToString();
                    DSG.SoGheTrong  = bllDSG.getSoGheTrong(DSG.MaChuyenBay, DSG.HangVe) + 1;

                    bllDSG.UpdateSoGheTrong(DSG);
                    bllPDC.HuyPhieuDatCho(dt.Rows[i][0].ToString());
                }
                dt.Dispose();
            }
        }
Beispiel #2
0
        private void btReservate_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                PhieuDatCho PDC = new PhieuDatCho();

                PDC.MaChuyenBay   = tbMaChuyenBay.Text;
                PDC.HangVe        = cbHangVe.Text;
                PDC.GiaTien       = decimal.Parse(lbGiaTien.Text);
                PDC.TrangThai     = "Chưa xuất vé";
                PDC.HoTen         = tbHoTen.Text;
                PDC.CMND          = tbCMND.Text;
                PDC.SDT           = tbSDT.Text;
                PDC.Email         = tbEmail.Text;
                PDC.NgayHuy       = bllCB.getNgayKhoiHanh(tbMaChuyenBay.Text);
                PDC.MaPhieuDatCho = bllPDC.getMaPhieuDatCho();

                if (bllPDC.insertPhieuDatCho(PDC))
                {
                    lbNotify.Text      = "Thành công, vui lòng kiểm tra mail để xác nhận thông tin";
                    lbNotify.ForeColor = Color.FromArgb(8, 186, 29);

                    DanhSachGhe DSG = new DanhSachGhe();
                    DSG.MaChuyenBay = PDC.MaChuyenBay;
                    DSG.HangVe      = PDC.HangVe;
                    DSG.SoGheTrong  = bllDSG.getSoGheTrong(tbMaChuyenBay.Text, cbHangVe.Text) - 1;

                    bllDSG.UpdateSoGheTrong(DSG);

                    SendMail(PDC);
                }
                else
                {
                    lbNotify.ForeColor = Color.Red;
                    lbNotify.Text      = "Đã có lỗi xảy ra, vui lòng thử lại sau";
                }
            }
        }
Beispiel #3
0
        private void btPrintTicket_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                DialogResult result = MessageBox.Show("Vé đã in sẽ không được thay đổi, bạn chắc chắn thông tin đã chính xác", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    if (btEdit.Text != "Hủy" && btSell.Text != "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            bllPDC.UpdateTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString(), "Đã xuất vé");
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            return;
                        }
                    }
                    else
                    if (btEdit.Text == "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            PhieuDatCho PDC = new PhieuDatCho();

                            PDC.MaPhieuDatCho = dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString();
                            PDC.MaChuyenBay   = tbMaChuyenBay.Text;
                            PDC.HangVe        = cbHangVe.Text;
                            PDC.GiaTien       = decimal.Parse(lbGiaTien.Text);
                            PDC.TrangThai     = "Đã xuất vé";
                            PDC.HoTen         = tbHoTen.Text;
                            PDC.CMND          = tbCMND.Text;
                            PDC.SDT           = tbSDT.Text;
                            PDC.Email         = tbEmail.Text;
                            bllPDC.UpdatePhieuDatCho(PDC);

                            btEdit.Text    = "Chỉnh sửa";
                            btSell.Enabled = true;
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            btEdit.Text        = "Chỉnh sửa";
                            btSell.Enabled     = true;
                            return;
                        }
                    }
                    else if (btSell.Text == "Hủy")
                    {
                        LockCotrol();
                        btSell.Text    = "Bán vé";
                        btEdit.Enabled = true;
                    }

                    VeChuyenBay VCB = new VeChuyenBay();

                    VCB.MaChuyenBay = tbMaChuyenBay.Text;
                    VCB.HangVe      = cbHangVe.Text;
                    VCB.GiaTien     = decimal.Parse(lbGiaTien.Text);
                    VCB.HoTen       = tbHoTen.Text;
                    VCB.CMND        = tbCMND.Text;
                    VCB.SDT         = tbSDT.Text;
                    VCB.Email       = tbEmail.Text;

                    if (bllVCB.insertVeChuyenBay(VCB))
                    {
                        lbNotify.Visible   = true;
                        lbNotify.Text      = "Thành công";
                        lbNotify.ForeColor = Color.FromArgb(8, 186, 29);

                        DanhSachGhe DSG = new DanhSachGhe();
                        DSG.MaChuyenBay = VCB.MaChuyenBay;
                        DSG.HangVe      = VCB.HangVe;
                        DSG.SoGheTrong  = bllDSG.getSoGheTrong(tbMaChuyenBay.Text, cbHangVe.Text) - 1;

                        bllDSG.UpdateSoGheTrong(DSG);
                        tbMaChuyenBay.Text = "";
                        tbHoTen.Text       = "";
                        tbSDT.Text         = "";
                        tbCMND.Text        = "";
                        tbEmail.Text       = "";
                        lbGiaTien.Text     = "0";
                    }
                    else
                    {
                        lbNotify.ForeColor = Color.Red;
                        lbNotify.Text      = "Đã có lỗi xảy ra, vui lòng thử lại sau";
                    }
                }
            }
        }