Ejemplo n.º 1
0
        public NhanLichChuyenBay()
        {
            InitializeComponent();
            dc                  = new DataConnection();
            busQuyDinh          = new BLL.QuydinhBLL();
            busChuyenbay        = new ChuyenbayBLL();
            busChitietchuyenbay = new BLL.ChitietchuyenbayBLL();
            busTinhtrangve      = new BLL.TinhtrangveBLL();
            busHangve           = new BLL.HangveBLL();

            dtoQuyDinh          = new DTO.Quydinh(0, 0, 0, 0, 0, 0, 0, 0);
            dtoChuyenBay        = new DTO.Chuyenbay("0", "0", DateTime.Now, 1, "0");
            dtoChitietchuyenbay = new DTO.Chitietchuyenbay("", "", "", 0, "");
            dtoTinhtrangve      = new DTO.Tinhtrangve("", "", "", 0, 0, 0);


            busQuyDinh.Get_Infor(dtoQuyDinh);
        }
Ejemplo n.º 2
0
        private void button_nhan_lich_Click(object sender, EventArgs e)
        {
            DataTable dt_hangve = (DataTable)dataGridView_hangve.DataSource;

            //Check điều kiện

            if (dataGridView_hangve.Rows.Count == 0 && dataGridView_hangve.Rows.Count == 0)
            {
                MessageBox.Show("Bạn chưa nhập thời gian bay hoặc các hạng vé của chuyến bay!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (dataGridView_hangve.Rows.Count == 0)
            {
                MessageBox.Show("Bạn chưa nhập các hạng vé!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (Convert.ToDateTime(dateTimePicker_ngaygio.Text) <= DateTime.Now)
            {
                MessageBox.Show("Ngày khởi hành phải sau ngày giờ hiện tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (comboBox_sbdi.Text == "" || comboBox_sbden.Text == "")
            {
                MessageBox.Show("Bạn chưa chọn sân bay đến hoặc sân bay đi!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (comboBox_sbdi.Text == comboBox_sbden.Text)
            {
                MessageBox.Show("Sân bay đến phải khác sân bay đi!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (textBox_thoigianbay.Text == "")// dataGridView_hangve.Rows.Count==0)
            {
                MessageBox.Show("Bạn chưa nhập thời gian bay!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (int.Parse(textBox_thoigianbay.Text) < dtoQuyDinh.tgbaytoithieu)
            {
                string message = $"Bạn nhập thời gian bay chưa đúng!\r\nThời gian bay bạn nhập là {textBox_thoigianbay.Text} phút, NHỎ HƠN thời gian bay tối thiểu là {dtoQuyDinh.tgbaytoithieu} phút.";
                MessageBox.Show(message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            // Check END

            dtoChuyenBay = new DTO.Chuyenbay(textBox_macb.Text, Get_maTB_by_maSB(comboBox_sbdi.SelectedValue.ToString(), comboBox_sbden.SelectedValue.ToString()), Convert.ToDateTime(dateTimePicker_ngaygio.Text), float.Parse(textBox_thoigianbay.Text), comboBox_giave.SelectedValue.ToString());
            if (busChuyenbay.InsertChuyenbay(dtoChuyenBay))
            {
                //MessageBox.Show("Nhận lịch chuyến bay B1 thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                // Xóa trống lại
            }
            else
            {
                MessageBox.Show("Có lỗi xảy ra! Nhận lịch chuyến bay thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int check_count = 0;

            foreach (DataGridViewRow row in dataGridView_sbtrunggian.Rows)
            {
                dtoChitietchuyenbay = new DTO.Chitietchuyenbay("", textBox_macb.Text, Get_maSBTG_by_tenSB(row.Cells[2].Value.ToString()),
                                                               float.Parse(row.Cells[3].Value.ToString()), row.Cells[4].Value.ToString());
                if (busChitietchuyenbay.InsertCTChuyenBay(dtoChitietchuyenbay))
                {
                    check_count++;
                }
            }

            if (check_count == dataGridView_sbtrunggian.Rows.Count)
            {
                check_count = 0;
                //MessageBox.Show("Nhận lịch chuyến bay B2 thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Nhận lịch chuyến bay B2 thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            foreach (DataGridViewRow row in dataGridView_hangve.Rows)
            {
                dtoTinhtrangve = new DTO.Tinhtrangve("", textBox_macb.Text, busHangve.Get_MAVE_by_TENHV(row.Cells[1].Value.ToString()), int.Parse(row.Cells[2].Value.ToString()), int.Parse(row.Cells[2].Value.ToString()), 0);

                if (busTinhtrangve.InsertTinhtrangve(dtoTinhtrangve))
                {
                    check_count++;
                }
            }

            if (check_count == dataGridView_hangve.Rows.Count)
            {
                check_count = 0;
                MessageBox.Show("Nhận lịch chuyến bay thành công\r\n Hoàn tất nhận lịch chuyến bay!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NhanLichChuyenBay_Load(sender, e);
                textBox_thoigianbay.Clear();
                textBox_thoigiandung.Clear();
                textBox_slghe.Clear();

                pictureBox_check.Visible       = false;
                label_tuyenbay_khadung.Visible = false;

                textBox_thoigianbay.Clear();

                dataGridView_hangve.Rows.Clear();
                dataGridView_hangve.Refresh();

                dataGridView_sbtrunggian.Rows.Clear();
                dataGridView_sbtrunggian.Refresh();
            }
            else
            {
                MessageBox.Show("Nhận lịch chuyến bay B3 thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }