Пример #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();
            }
        }
Пример #2
0
        private void btHuyPhieu_Click(object sender, EventArgs e)
        {
            if (dataGridPhieuDat.Rows[Id].Cells["colTrangThai"].Value.ToString() == "Đã hủy")
            {
                lbNotify.Visible   = true;
                lbNotify.Text      = "Phiếu đã hủy";
                lbNotify.ForeColor = Color.Red;
                return;
            }
            if (dataGridPhieuDat.Rows[Id].Cells["colTrangThai"].Value.ToString() == "Đã xuất vé")
            {
                lbNotify.Visible   = true;
                lbNotify.Text      = "Phiếu đã xuất không thể hủy";
                lbNotify.ForeColor = Color.Red;
                return;
            }
            DanhSachGhe DSG = new DanhSachGhe();

            DSG.MaChuyenBay = dataGridPhieuDat.Rows[Id].Cells["colMaChuyenBay"].Value.ToString();
            DSG.HangVe      = dataGridPhieuDat.Rows[Id].Cells["colHangVe"].Value.ToString();
            DSG.SoGheTrong  = bllDSG.getSoGheTrong(DSG.MaChuyenBay, DSG.HangVe) + 1;

            bllDSG.UpdateSoGheTrong(DSG);
            bllPDC.HuyPhieuDatCho(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString());

            lbNotify.Visible   = true;
            lbNotify.Text      = "Hủy thành công";
            lbNotify.ForeColor = Color.FromArgb(8, 186, 29);
        }
Пример #3
0
        public void UpdateSoGheTrong(DanhSachGhe DSG)
        {
            string sql = "update DANHSACHGHE set SoGheTrong = " + DSG.SoGheTrong +
                         " where MaChuyenBay = '" + DSG.MaChuyenBay + "' and HangVe = N'" + DSG.HangVe + "'";

            ExcuteNonQuery(sql);
        }
Пример #4
0
        private void btn_Them_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                if (bllCB.CheckTrungChuyenBay(Tbx_MaChuyenBay.Text))
                {
                    lbNotify.ForeColor = Color.Red;
                    lbNotify.Text      = "Mã Chuyến Bay bị trùng";
                    return;
                }
                CB.MaChuyenBay = Tbx_MaChuyenBay.Text;
                CB.DonGia      = decimal.Parse(Tbx_GiaVe.Text);
                CB.MaSanBayDi  = CBox_SanBayDi.SelectedValue.ToString();
                CB.MaSanBayDen = CBox_SanBayDen.SelectedValue.ToString();
                CB.NgayGio     = DateTime.ParseExact(Tbx_NgayGio.Text, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                CB.ThoiGianBay = TimeSpan.Parse(Tbx_ThoiGianBay.Text);
                bllCB.InsertChuyenBay(CB);
                int nHangGhe = DataGrid_SoLuongGheHangVe.RowCount - 1;
                DSG = new DanhSachGhe[nHangGhe];
                for (int i = 0; i < nHangGhe; i++)
                {
                    DSG[i]             = new DanhSachGhe();
                    DSG[i].HangVe      = DataGrid_SoLuongGheHangVe.Rows[i].Cells[0].Value.ToString();
                    DSG[i].MaChuyenBay = CB.MaChuyenBay;
                    DSG[i].TongSoGhe   = Int32.Parse(DataGrid_SoLuongGheHangVe.Rows[i].Cells[1].Value.ToString());
                    DSG[i].SoGheTrong  = DSG[i].TongSoGhe;
                }

                for (int i = 0; i < nHangGhe; i++)
                {
                    bllDSG.InsertDanhSachGhe(DSG[i]);
                }
                int nSanBayTrungGian = DataGrid_SanBayTrungGian.RowCount - 1;
                SBTG = new SanBayTrungGian[nSanBayTrungGian];
                for (int i = 0; i < nSanBayTrungGian; i++)
                {
                    SBTG[i]              = new SanBayTrungGian();
                    SBTG[i].MaChuyenBay  = CB.MaChuyenBay;
                    SBTG[i].MaSanBay     = DataGrid_SanBayTrungGian.Rows[i].Cells[1].Value.ToString();
                    SBTG[i].ThoiGianDung = TimeSpan.Parse(DataGrid_SanBayTrungGian.Rows[i].Cells[2].Value.ToString());
                    SBTG[i].GhiChu       = DataGrid_SanBayTrungGian.Rows[i].Cells[3].Value.ToString();
                }
                for (int i = 0; i < nSanBayTrungGian; i++)
                {
                    bllSBTG.InsertSanBayTrungGian(SBTG[i]);
                }
                lbNotify.ForeColor = Color.Green;
                lbNotify.Text      = "Hệ thống đã tiếp nhận chuyến bay";
            }
        }
Пример #5
0
        public bool UpdateDanhSachGhe(DataTable tbDSG)
        {
            if (tbDSG.Rows.Count == 0)
            {
                return(true);
            }
            string         MaChuyenBay = tbDSG.Rows[0][0].ToString();
            DanhSachGheDAL dalDSG      = new DanhSachGheDAL();

            dalDSG.Delete(MaChuyenBay);
            for (int i = 0; i < tbDSG.Rows.Count; i++)
            {
                string sql = "insert into DANHSACHGHE(MaChuyenBay, HangVe, TongSoGhe, SoGheTrong)" +
                             " VALUES(@MaChuyenBay, @HangVe, @TongSoGhe, @SoGheTrong)";
                using (SqlConnection con = dc.getConnect())
                {
                    try
                    {
                        cmd = new SqlCommand(sql, con);
                        con.Open();
                        DanhSachGhe DSG = new DanhSachGhe();
                        DSG.MaChuyenBay = tbDSG.Rows[i][0].ToString();
                        DSG.HangVe      = tbDSG.Rows[i][1].ToString();
                        DSG.TongSoGhe   = Int32.Parse(tbDSG.Rows[i][2].ToString());
                        DSG.SoGheTrong  = DSG.TongSoGhe;
                        cmd.Parameters.Add("@MaChuyenBay", SqlDbType.VarChar).Value = DSG.MaChuyenBay;
                        cmd.Parameters.Add("@HangVe", SqlDbType.NVarChar).Value     = DSG.HangVe;
                        cmd.Parameters.Add("@TongSoGhe", SqlDbType.Int).Value       = DSG.TongSoGhe;
                        cmd.Parameters.Add("@SoGheTrong", SqlDbType.Int).Value      = DSG.SoGheTrong;
                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            return(true);
        }
Пример #6
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";
                }
            }
        }
Пример #7
0
        DataTable CapNhatDanhSachGhe()
        {
            DataTable dt = new DataTable();

            dt.Clear();
            dt.Columns.Add("MaChuyenBay");
            dt.Columns.Add("HangVe");
            dt.Columns.Add("TongSoGhe");
            dt.Columns.Add("SoGheTrong");
            DanhSachGhe DSG = new DanhSachGhe();
            int         n   = DataGrid_DanhSachGheP2.RowCount - 1;

            for (int i = 0; i < n; i++)
            {
                DataRow dtr = dt.NewRow();
                dtr["MaChuyenBay"] = DataGrid_DanhSachChuyenBay.Rows[Index].Cells[2].Value.ToString();
                dtr["HangVe"]      = DataGrid_DanhSachGheP2.Rows[i].Cells[0].Value.ToString();
                dtr["TongSoGhe"]   = DataGrid_DanhSachGheP2.Rows[i].Cells[1].Value.ToString();
                dtr["SoGheTrong"]  = DSG.TongSoGhe;
                dt.Rows.Add(dtr);
            }
            return(dt);
        }
Пример #8
0
        public void insertDanhSachGhe(DanhSachGhe DSG)
        {
            string sql = "insert into DANHSACHGHE(MaChuyenBay, HangVe, TongSoGhe, SoGheTrong)" +
                         " VALUES(@MaChuyenBay, @HangVe, @TongSoGhe, @SoGheTrong)";

            using (SqlConnection con = dc.getConnect())
            {
                try
                {
                    cmd = new SqlCommand(sql, con);
                    con.Open();
                    cmd.Parameters.Add("@MaChuyenBay", SqlDbType.VarChar).Value = DSG.MaChuyenBay;
                    cmd.Parameters.Add("@HangVe", SqlDbType.NVarChar).Value     = DSG.HangVe;
                    cmd.Parameters.Add("@TongSoGhe", SqlDbType.Int).Value       = DSG.TongSoGhe;
                    cmd.Parameters.Add("@SoGheTrong", SqlDbType.Int).Value      = DSG.SoGheTrong;
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #9
0
        bool CheckInputDanhSachGhe(DanhSachGhe DSG)

        {
            if (string.IsNullOrEmpty(DSG.MaChuyenBay))
            {
                lbNotify.ForeColor = Color.Red;
                lbNotify.Text      = "Mã Chuyến Bay của Danh Sách Ghế chưa được nhập";
                return(false);
            }
            if (string.IsNullOrEmpty(DSG.HangVe))
            {
                lbNotify.ForeColor = Color.Red;
                lbNotify.Text      = "Hạng Vé chưa được nhập";
                return(false);
            }
            if (string.IsNullOrEmpty(DSG.TongSoGhe.ToString()))
            {
                lbNotify.ForeColor = Color.Red;
                lbNotify.Text      = "Tổng Số Ghế chưa được nhập";
                return(false);
            }
            lbNotify.ForeColor = Color.FromArgb(8, 186, 29);
            return(true);
        }
Пример #10
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";
                    }
                }
            }
        }
Пример #11
0
 public void InsertDanhSachGhe(DanhSachGhe CB)
 {
     dalDSG.insertDanhSachGhe(CB);
 }
Пример #12
0
 public void UpdateSoGheTrong(DanhSachGhe DSG)
 {
     dalDSG.UpdateSoGheTrong(DSG);
 }
Пример #13
0
        private void btn_Excel_Click(object sender, EventArgs e)
        {
            Excel.Application ExcelObj = new Excel.Application();
            OpenFileDialog    dlg      = new OpenFileDialog();

            dlg.Filter = "Excel files|*.xls; *.xlsx";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(dlg.FileName, 0, true, 5,
                                                                     "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);
                Excel.Sheets    sheets      = theWorkbook.Worksheets;
                Excel.Worksheet worksheet   = (Excel.Worksheet)sheets.get_Item(1);
                Excel.Range     UsedRange   = worksheet.UsedRange;
                int             lastUsedRow = UsedRange.Row + UsedRange.Rows.Count - 1;
                for (int i = 2; i <= lastUsedRow; i++)
                {
                    ChuyenBay       CB   = new ChuyenBay();
                    DanhSachGhe     DSG  = new DanhSachGhe();
                    SanBayTrungGian SBTG = new SanBayTrungGian();
                    if (!string.IsNullOrEmpty(worksheet.Cells[i, 1].Value))
                    {
                        CB.MaChuyenBay = worksheet.Cells[i, 1].Value.ToString();
                        CB.DonGia      = decimal.Parse(worksheet.Cells[i, 2].Value.ToString());
                        CB.MaSanBayDi  = worksheet.Cells[i, 3].Value.ToString();
                        CB.MaSanBayDen = worksheet.Cells[i, 4].Value.ToString();
                        CB.NgayGio     = DateTime.Parse(worksheet.Cells[i, 5].Value.ToString());
                        CB.ThoiGianBay = TimeSpan.Parse(worksheet.Cells[i, 6].Value.ToString());
                        if (!bllCB.CheckTrungChuyenBay(CB.MaChuyenBay))
                        {
                            if (CheckInputChuyenBay(CB))
                            {
                                bllCB.InsertChuyenBay(CB);
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(worksheet.Cells[i, 7].Value))
                    {
                        DSG.MaChuyenBay = worksheet.Cells[i, 7].Value.ToString();
                        DSG.HangVe      = worksheet.Cells[i, 8].Value.ToString();
                        DSG.TongSoGhe   = Int32.Parse(worksheet.Cells[i, 9].Value.ToString());
                        DSG.SoGheTrong  = DSG.TongSoGhe;
                        if (!bllDSG.CheckTrungDanhSachGhe(DSG.MaChuyenBay, DSG.HangVe))
                        {
                            if (CheckInputDanhSachGhe(DSG))
                            {
                                bllDSG.InsertDanhSachGhe(DSG);
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(worksheet.Cells[i, 10].Value))
                    {
                        SBTG.MaChuyenBay  = worksheet.Cells[i, 10].Value.ToString();
                        SBTG.MaSanBay     = worksheet.Cells[i, 11].Value.ToString();
                        SBTG.ThoiGianDung = TimeSpan.Parse(worksheet.Cells[i, 12].Value.ToString());
                        SBTG.GhiChu       = worksheet.Cells[i, 13].Value.ToString();
                        if (!bllSBTG.CheckTrungSanBayTrungGian(SBTG.MaChuyenBay, SBTG.MaSanBay))
                        {
                            if (CheckIntputSanBayTrungGian(SBTG))
                            {
                                bllSBTG.InsertSanBayTrungGian(SBTG);
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                }
            }
            lbNotify.Visible   = true;
            lbNotify.ForeColor = Color.Green;
            lbNotify.Text      = "Đã Thêm Danh Sách Các Chuyến Bay Từ File Excel Thành Công";
        }