Exemplo n.º 1
0
        private void dgNationality_RowEditEnding(object sender, Microsoft.Windows.Controls.DataGridRowEditEndingEventArgs e)
        {
            BeaCukai cukai = new BeaCukai();
            NationalityAttention nationality = e.Row.Item as NationalityAttention;

            if (nationality != null)
            {
                var existing = (from p in cukai.NationalityAttention where p.ID == nationality.ID select p).First();

                existing.Nationality = nationality.Nationality;

                cukai.SubmitChanges();
            }


        }
Exemplo n.º 2
0
        private void ButtonDropDown_Click(object sender, RoutedEventArgs e)
        {
            if (tbNationality.Text.Trim() == "")
            {
                MessageBox.Show("Isikan Nationality (WN)", "Invalid", MessageBoxButton.OK);
                return;
            }

            DialogResult = true;

            BeaCukai cukai = new BeaCukai();
            NationalityAttention att = new NationalityAttention();
            att.Nationality = tbNationality.Text;

            cukai.NationalityAttention.InsertOnSubmit(att);
            cukai.SubmitChanges();
        }
Exemplo n.º 3
0
        private void dgDPO_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            BeaCukai cukai = new BeaCukai();
            PAUDPO dpo = e.Row.Item as PAUDPO;

            if (dpo != null)
            {
                var existing = (from p in cukai.PAUDPO where p.ID == dpo.ID select p).First();

                existing.Name = dpo.Name;
                existing.FirstName = dpo.FirstName;
                existing.LastName = dpo.LastName;
                existing.Passport = dpo.Passport;

                cukai.SubmitChanges();
            }

        }
Exemplo n.º 4
0
        private void ButtonDropDown_Click(object sender, RoutedEventArgs e)
        {
            if (tbFirstName.Text.Trim() == "")
            {
                MessageBox.Show("Isikan First Name", "Invalid", MessageBoxButton.OK);
                return;
            }

            DialogResult = true;

            BeaCukai cukai = new BeaCukai();
            PAUDPO dpo = new PAUDPO();
            dpo.FirstName = FirstName;
            dpo.LastName = LastName;
            dpo.Passport = Passport;

            cukai.PAUDPO.InsertOnSubmit(dpo);
            cukai.SubmitChanges();
            
        }
Exemplo n.º 5
0
        private void UpdatePassenger(PAUPassenger passenger)
        {
            BeaCukai cukai = new BeaCukai();

            if (passenger != null)
            {
                try
                {
                    var existing = (from p in cukai.PAUPassenger
                                    where
                                        p.ID == passenger.ID
                                    select p).First();

                    existing.Name = passenger.Name;
                    existing.BirthDate = passenger.BirthDate;
                    existing.CDst = passenger.CDst;
                    existing.Date = passenger.Date;
                    existing.FareClass = passenger.FareClass;
                    existing.FirstName = passenger.FirstName;
                    existing.FlightDate = passenger.FlightDate;
                    existing.FlightNo = passenger.FlightNo;
                    existing.Gender = passenger.Gender;
                    existing.LastName = passenger.LastName;
                    existing.Nationality = passenger.Nationality;
                    existing.Passport = passenger.Passport;
                    existing.PNR = passenger.PNR;
                    existing.SeatNo = passenger.SeatNo;
                    existing.SEQNo = passenger.SEQNo;
                    existing.Notes = passenger.Notes;
                    existing.Picture = passenger.Picture;
                }
                catch (Exception)
                {
                    return;
                }

                cukai.SubmitChanges();
            }
        }
Exemplo n.º 6
0
        private void ProcessManifestPAX(string filename)
        {
            BackgroundWorker worker = new BackgroundWorker();
            worker.WorkerReportsProgress = true;
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (s, e) =>
                {
                    BackgroundWorker sender = s as BackgroundWorker;
                    DateTime date;
                    string no;
                    List<PAUPassenger> pass;
                    ReadAirAsia(sender, filename, out date, out no, out pass);
                    sender.ReportProgress(-1, new PAXObj(no, date, pass));
                };

            worker.ProgressChanged += (s, e) =>
                {
                    if (e.ProgressPercentage >= 0)
                    {
                        StatusText = "Processing line: " + e.ProgressPercentage + " => " + (e.UserState as string);
                    }
                    else if (e.ProgressPercentage == -1)
                    {
                        PAXObj obj = e.UserState as PAXObj;
                        DateTime flightDate = obj.flightDate;
                        string flightNo = obj.flightNo;
                        List<PAUPassenger> passengers = obj.passengers;

                        DataGrid importGrid;
                        SpawnNewDockWindow("Recent Import", out importGrid);

                        filename = Path.GetFileName(filename);

                        StatusText = "Please wait... import process might take a while...";

                        if (importGrid != null)
                        {
                            BeaCukai cukai = new BeaCukai();

                            if (passengers.Count > 0)
                            {
                                foreach (PAUPassenger passenger in passengers)
                                {
                                    int count = (from p in cukai.PAUPassenger select p).Where(p => p.FirstName.ToLower() == passenger.FirstName.ToLower()).
                                        Where(p => p.LastName.ToLower() == passenger.LastName.ToLower()).
                                        Where(p => p.FlightNo.ToLower() == passenger.FlightNo.ToLower()).
                                        Where(p => p.FlightDate.Value.Date.Day == passenger.FlightDate.Value.Date.Day && p.FlightDate.Value.Date.Month == passenger.FlightDate.Value.Date.Month &&
                                                   p.FlightDate.Value.Date.Year == passenger.FlightDate.Value.Date.Year).
                                        Distinct().Count();

                                    if (count == 0)
                                    {
                                        cukai.PAUPassenger.InsertOnSubmit(passenger);
                                    }
                                }
                                cukai.SubmitChanges();
                            }

                            ImportedPassengers = new ObservableCollection<PAUPassenger>(passengers);
                            ObservableCollection<PAUPassenger> attentions = new ObservableCollection<PAUPassenger>();
                            ObservableCollection<PAUPassenger> dpos = new ObservableCollection<PAUPassenger>();
                            ObservableCollection<PAUPassenger> wnAttentions = new ObservableCollection<PAUPassenger>();

                            int index = 1;
                            foreach (PAUPassenger p in ImportedPassengers)
                            {
                                TimeSpan span = p.FlightDate.Value.Subtract(p.Date.Value);
                                if (span <= TimeSpan.FromDays(BookingDateRange))
                                {
                                    attentions.Add(p);
                                }

                                p.No = index++;

                                int count = (from dpo in cukai.PAUDPO
                                             where
                                             (p.FirstName.ToLower().Contains(dpo.FirstName.ToLower()) &&
                                              p.LastName.ToLower().Contains(dpo.LastName.ToLower()))
                                             select dpo).Count();

                                if (count > 0)
                                {
                                    dpos.Add(p);
                                }

                                count = (from nat in cukai.NationalityAttention
                                         where
                                         (nat.Nationality.ToLower() == p.Nationality.ToLower())
                                         select nat).Distinct().Count();

                                if (count > 0)
                                {
                                    if (wnAttentions.Contains(p) == false)
                                    {
                                        wnAttentions.Add(p);
                                    }
                                }
                            }

                            importGrid.ItemsSource = CollectionViewSource.GetDefaultView(ImportedPassengers);

                            if (attentions.Count > 0)
                            {
                                DataGrid attentionGrid;
                                SpawnNewDockWindow(string.Format("Attentions ({0})", filename), out attentionGrid);
                                if (attentionGrid != null)
                                {
                                    attentionGrid.ItemsSource = CollectionViewSource.GetDefaultView(attentions);
                                }
                            }

                            if (wnAttentions.Count > 0)
                            {
                                DataGrid wnAttGrid;
                                SpawnNewDockWindow(string.Format("WN Att ({0})", filename), out wnAttGrid);
                                if (wnAttGrid != null)
                                {
                                    wnAttGrid.ItemsSource = CollectionViewSource.GetDefaultView(wnAttentions);
                                }
                            }

                            if (dpos.Count > 0)
                            {
                                DataGrid dpoGrid;
                                SpawnNewDockWindow(string.Format("Name(s) On DPO ({0})", filename), out dpoGrid);
                                if (dpoGrid != null)
                                {
                                    dpoGrid.ItemsSource = CollectionViewSource.GetDefaultView(dpos);
                                }
                            }

                            ResetDatabases();

                            MessageBox.Show("Import Data Selesai", "Infomasi", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                            _isReady = true;
                            StatusText = "Ready";
                        }
                    }
                };

            _isReady = false;

            worker.RunWorkerAsync();

        }
Exemplo n.º 7
0
        private void Passengers_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                //if (MessageBox.Show("Are you sure you want to delete the record(s)?", "Warning", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    BeaCukai cukai = new BeaCukai();

                    foreach (PAUPassenger passenger in e.OldItems)
                    {
                        cukai.PAUPassenger.DeleteOnSubmit(passenger);
                    }
                    cukai.SubmitChanges();
                }
            }
        }
Exemplo n.º 8
0
        private void Nationalities_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                BeaCukai cukai = new BeaCukai();

                foreach (NationalityAttention att in e.OldItems)
                {
                    cukai.NationalityAttention.DeleteOnSubmit(att);
                }
                cukai.SubmitChanges();
            }
        }
Exemplo n.º 9
0
        private void dgPassenger_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            BeaCukai cukai = new BeaCukai();
            PAUPassenger passenger = e.Row.Item as PAUPassenger;

            if (passenger != null)
            {
                try
                {
                    var existing = (from p in cukai.PAUPassenger
                                    where
                                        /*p.Name == passenger.Name &&
                                        p.CDst == passenger.CDst &&
                                        p.FareClass == passenger.FareClass &&
                                        p.FirstName == passenger.FirstName &&
                                        p.FlightNo == passenger.FlightNo &&
                                        p.Gender == passenger.Gender &&
                                        p.LastName == passenger.LastName &&
                                        p.Nationality == passenger.Nationality &&
                                        p.Passport == passenger.Passport &&
                                        p.PNR == passenger.PNR &&
                                        p.SeatNo == passenger.SeatNo &&
                                        p.SEQNo == passenger.SEQNo &&
                                        p.Notes == passenger.Notes
                                        */
                                    p.ID == passenger.ID
                                    select p).First();

                    existing.Name = passenger.Name;
                    existing.BirthDate = passenger.BirthDate;
                    existing.CDst = passenger.CDst;
                    existing.Date = passenger.Date;
                    existing.FareClass = passenger.FareClass;
                    existing.FirstName = passenger.FirstName;
                    existing.FlightDate = passenger.FlightDate;
                    existing.FlightNo = passenger.FlightNo;
                    existing.Gender = passenger.Gender;
                    existing.LastName = passenger.LastName;
                    existing.Nationality = passenger.Nationality;
                    existing.Passport = passenger.Passport;
                    existing.PNR = passenger.PNR;
                    existing.SeatNo = passenger.SeatNo;
                    existing.SEQNo = passenger.SEQNo;
                    existing.Notes = passenger.Notes;
                    existing.Picture = passenger.Picture;
                }
                catch (Exception)
                {
                    return;
                }

                cukai.SubmitChanges();
            }


        }