private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            if (Check())
            {
                if (tab.SelectedItem == tabItemChuyenBay) // Chuyến bay
                {
                    switch (cmbSearchFilter.SelectedIndex)
                    {
                    case 0:
                    {
                        int macb = int.Parse(txtSearchBox.Text);
                        FlightMngController.SearchFlightForMACB(ref FlightData, macb);
                        dataChuyenBay.ItemsSource = FlightData;
                        break;
                    }

                    case 1:
                    {
                        StringBuilder sbdi = new StringBuilder(txtSearchBox.Text);
                        int           l    = sbdi.Length;
                        while (l < 5)
                        {
                            l++;
                            sbdi.Append(" ");
                        }
                        int length = sbdi.Length;
                        FlightMngController.SearchFlightForSBDI(ref FlightData, sbdi.ToString());
                        dataChuyenBay.ItemsSource = FlightData;
                        break;
                    }

                    case 2:
                    {
                        StringBuilder sbden = new StringBuilder(txtSearchBox.Text);
                        int           l     = sbden.Length;
                        while (l < 5)
                        {
                            l++;
                            sbden.Append(" ");
                        }
                        FlightMngController.SearchFlightForSBDI(ref FlightData, sbden.ToString());
                        dataChuyenBay.ItemsSource = FlightData;
                        break;
                    }

                    default: break;
                    }
                }
                else
                {
                    // Lịch bay
                    switch (cmbSearchFilter.SelectedIndex)
                    {
                    case 0:
                    {
                        int macb = int.Parse(txtSearchBox.Text);
                        FlightMngController.SearchForMACB(ref SheduleData, macb);
                        dataLichBay.ItemsSource = SheduleData;
                        break;
                    }

                    case 1:
                    {
                        StringBuilder sbdi = new StringBuilder(txtSearchBox.Text);
                        int           l    = sbdi.Length;
                        while (l < 5)
                        {
                            l++;
                            sbdi.Append(" ");
                        }
                        FlightMngController.SearchForSBDI(ref SheduleData, sbdi.ToString());
                        dataLichBay.ItemsSource = SheduleData;

                        break;
                    }

                    case 2:
                    {
                        StringBuilder sbden = new StringBuilder(txtSearchBox.Text);
                        int           l     = sbden.Length;
                        while (l < 5)
                        {
                            l++;
                            sbden.Append(" ");
                        }
                        FlightMngController.SearchForSBDEN(ref SheduleData, sbden.ToString());
                        dataLichBay.ItemsSource = SheduleData;

                        break;
                    }

                    case 3:
                    {
                        DateTime ngaydi = dpSearchBox.SelectedDate.Value;
                        FlightMngController.SearchForNGAYDI(ref SheduleData, ngaydi);
                        dataLichBay.ItemsSource = SheduleData;
                        break;
                    }

                    case 4:
                    {
                        TimeSpan giobay = new TimeSpan(int.Parse(hourSearchBox.Text), int.Parse(minSearchBox.Text), 0);
                        FlightMngController.SearchForGIOBAY(ref SheduleData, giobay);
                        dataLichBay.ItemsSource = SheduleData;
                        break;
                    }

                    default: break;
                    }
                }
            }
            else
            {
                // do nothing
            }
        }
Beispiel #2
0
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            switch (cmbFilter.SelectedIndex)
            {
            case 0:
            {
                if (txtSearchBox.Text.Length > 9)
                {
                    MessageBox.Show("Mã khách hàng chỉ gồm 9 ký tự");
                }
                else
                {
                    StringBuilder makh = new StringBuilder(txtSearchBox.Text);
                    int           l    = makh.Length;
                    while (l < 9)
                    {
                        l++;
                        makh.Append(" ");
                    }
                    receiptMngController.SearchForMAKH(ref receiptData, makh.ToString());
                    dataHoaDon.ItemsSource = receiptData;
                }
                break;
            }

            case 1:
            {
                DateTime ngaydi = dpSearchBox.SelectedDate.Value;
                FlightMngController.SearchForNGAYDI(ref receiptData, ngaydi);
                dataHoaDon.ItemsSource = receiptData;
                break;
            }

            case 2:
            {
                if (txtSearchBox.Text.Length > 5)
                {
                    MessageBox.Show("Mã sân bay chỉ gồm 5 ký tự");
                }
                else
                {
                    StringBuilder sbdi = new StringBuilder(txtSearchBox.Text);
                    int           l    = sbdi.Length;
                    while (l < 5)
                    {
                        l++;
                        sbdi.Append(" ");
                    }
                    FlightMngController.SearchForSBDI(ref receiptData, sbdi.ToString());
                    dataHoaDon.ItemsSource = receiptData;
                }
                break;
            }

            case 3:
            {
                if (txtSearchBox.Text.Length > 5)
                {
                    MessageBox.Show("Mã sân bay chỉ gồm 5 ký tự");
                }
                else
                {
                    StringBuilder sbden = new StringBuilder(txtSearchBox.Text);
                    int           l     = sbden.Length;
                    while (l < 5)
                    {
                        l++;
                        sbden.Append(" ");
                    }
                    FlightMngController.SearchForSBDEN(ref receiptData, sbden.ToString());
                    dataHoaDon.ItemsSource = receiptData;
                }
                break;
            }

            default: break;
            }
        }