private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (LakeTextBox.SelectedValue != null)
            {
                STREAMS_CONTEXT.Dispose();
                STREAMS_CONTEXT = new Data_Model.Portable_Traps_Entities();
                CollectionViewSource StreamListViewSource = ((CollectionViewSource)(this.FindResource("StreamListViewSource")));
                decimal lake    = System.Convert.ToDecimal(LakeTextBox.SelectedValue.ToString());
                var     Streams = STREAMS_CONTEXT.QRY_PORTABLE_TRAP_SITES_STREAM_LIST
                                  .Where(QRY_PORTABLE_TRAP_SITES_STREAM_LIST => QRY_PORTABLE_TRAP_SITES_STREAM_LIST.LAKE == lake)
                                  .ToList();

                StreamListViewSource.Source = STREAMS_CONTEXT.QRY_PORTABLE_TRAP_SITES_STREAM_LIST.Local;
            }
            if (LakeTextBox.SelectedValue != null && streamcomboBox.SelectedValue != null)
            {
                decimal lake   = System.Convert.ToDecimal(LakeTextBox.SelectedValue.ToString());
                decimal stream = System.Convert.ToDecimal(streamcomboBox.SelectedValue.ToString());

                SITE_CONTEXT.Dispose();
                SITE_CONTEXT = new Data_Model.Portable_Traps_Entities();

                var Sites = SITE_CONTEXT.PORTABLE_TRAP_SITES
                            .Where(PORTABLE_TRAP_SITES => PORTABLE_TRAP_SITES.LAKE == lake)
                            .Where(PORTABLE_TRAP_SITES => PORTABLE_TRAP_SITES.STREAM == stream)
                            .OrderBy(PORTABLE_TRAP_SITES => PORTABLE_TRAP_SITES.TRAP_SITE)
                            .ToList();

                CollectionViewSource SiteListViewSource = ((CollectionViewSource)(this.FindResource("SiteListViewSource")));
                SiteListViewSource.Source = SITE_CONTEXT.PORTABLE_TRAP_SITES.Local;
            }
        }
 private void Window_Closed(object sender, EventArgs e)
 {
     PA_PAT_ASSESSMENTS_CONTEXT.Dispose();
     PA_PERSONNEL_CONTEXT.Dispose();
     PA_FIN_CLIPS_CONTEXT.Dispose();
     PA_INDIVIDUALS_CONTEXT.Dispose();
     PA_SPECIES_CONTEXT.Dispose();
 }
예제 #3
0
        private void SaveChangesPAPersonnel()
        {
            foreach (var person in PA_PERSONNEL_CONTEXT.PA_PERSONNEL.Local.ToList())
            {
                if (person.EMPID == null)
                {
                    PA_PERSONNEL_CONTEXT.PA_PERSONNEL.Remove(person);
                }
            }


            PA_PERSONNEL_CONTEXT.SaveChanges();

            DataChangedEventHandler handler = DataChanged;

            if (handler != null)
            {
                handler(this, new EventArgs());
            }

            PA_PERSONNEL_CONTEXT.Dispose();
            PA_PERSONNEL_CONTEXT = new Data_Model.Portable_Traps_Entities();
            System.Windows.Data.CollectionViewSource pA_PERSONNELViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("pA_PERSONNELViewSource")));
            PA_PERSONNEL_CONTEXT.PA_PERSONNEL.Local.Add(new Data_Model.PA_PERSONNEL()
            {
                ID = ROWID
            });

            pA_PERSONNELViewSource.Source = PA_PERSONNEL_CONTEXT.PA_PERSONNEL.Local;
        }
예제 #4
0
        private void SaveChangesPASpecies()
        {
            foreach (var species in SPECIES_CONTEXT.PA_SPECIES.Local.ToList())
            {
                if (species.ID == 0)
                {
                    SPECIES_CONTEXT.PA_SPECIES.Remove(species);
                }
            }

            try
            {
                SPECIES_CONTEXT.SaveChanges();
            }
            catch (DbUpdateException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine("DbUpdateException error details - {ex?.InnerException?.InnerException?.Message}");

                foreach (var eve in ex.Entries)
                {
                    sb.AppendLine("Entity of type {eve.Entity.GetType().Name} in state {eve.State} could not be updated");
                }



                var error = sb.ToString();
                MessageBox.Show(error);
                //throw;
            }
            catch (Exception ex1)
            {
                var error1 = ex1.ToString();
                MessageBox.Show(error1);
            }


            DataChangedEventHandler handler = DataChanged;

            if (handler != null)
            {
                handler(this, new EventArgs());
            }
            if (OfficeUseID == 0)
            {
                SPECIES_CONTEXT.Dispose();
                SPECIES_CONTEXT = new Data_Model.Portable_Traps_Entities();
                System.Windows.Data.CollectionViewSource pA_SPECIESViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("pA_SPECIESViewSource")));
                SPECIES_CONTEXT.PA_SPECIES.Local.Add(new Data_Model.PA_SPECIES()
                {
                    ID = ROWID
                });
                pA_SPECIESViewSource.Source = SPECIES_CONTEXT.PA_SPECIES.Local;

                textBoxspecies.Text = "";
                textBoxAlive.Text   = "";
                textBoxDead.Text    = "";
            }
        }
예제 #5
0
        private void textBoxCaptureCode_DropDownOpened(object sender, EventArgs e)
        {
            CAPTURE_CODE_Context.Dispose();
            CAPTURE_CODE_Context = new Data_Model.Portable_Traps_Entities();
            System.Windows.Data.CollectionViewSource CaptureListViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("CaptureListViewSource")));
            var CaptureCode = SPECIES_CONTEXT.CAPTURE_DESCRIPTIONS
                              .ToList();

            CaptureListViewSource.Source = SPECIES_CONTEXT.CAPTURE_DESCRIPTIONS.Local;
        }
        private void textBoxSex_DropDownOpened(object sender, EventArgs e)
        {
            GENDER_List_Context.Dispose();
            GENDER_List_Context = new Data_Model.Portable_Traps_Entities();
            CollectionViewSource GenderListViewSource = ((CollectionViewSource)(this.FindResource("GenderListViewSource")));
            var Gender = GENDER_List_Context.GENDERS
                         .ToList();

            GenderListViewSource.Source = GENDER_List_Context.GENDERS.Local;
        }
예제 #7
0
        private void textBoxspecies_DropDownOpened(object sender, EventArgs e)
        {
            SPECIES_LIST_CONTEXT.Dispose();
            SPECIES_LIST_CONTEXT = new Data_Model.Portable_Traps_Entities();
            CollectionViewSource SpeciesListViewSource = ((CollectionViewSource)(this.FindResource("SpeciesListViewSource")));
            var Species = SPECIES_LIST_CONTEXT.QRY_PA_SPECIES_USAGE_FREQUENCY
                          .OrderByDescending(QRY_PA_SPECIES_USAGE_FREQUENCY => QRY_PA_SPECIES_USAGE_FREQUENCY.Count)
                          .ToList();

            SpeciesListViewSource.Source = SPECIES_LIST_CONTEXT.QRY_PA_SPECIES_USAGE_FREQUENCY.Local;
        }
예제 #8
0
        private void fIRSTNAMEComboBox_DropDownOpened(object sender, EventArgs e)
        {
            string officeval   = oFFICE_NAMEComboBox.SelectedValue.ToString();
            string lastnameval = lASTNAMEComboBox.Text.ToString();

            EMPLOYEE_CONTEXT.Dispose();
            EMPLOYEE_CONTEXT = new Data_Model.Portable_Traps_Entities();

            var Employees = EMPLOYEE_CONTEXT.EMPLOYEES
                            .Where(EMPLOYEES => EMPLOYEES.OFFICE == officeval)
                            .Where(EMPLOYEES => EMPLOYEES.LASTNAME == lastnameval)
                            .ToList();

            System.Windows.Data.CollectionViewSource eMPLOYEEViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("eMPLOYEEViewSource")));
            eMPLOYEEViewSource.Source = EMPLOYEE_CONTEXT.EMPLOYEES.Local;
        }
예제 #9
0
        private void lASTNAMEComboBox_DropDownOpened(object sender, EventArgs e)
        {
            string officeval = oFFICE_NAMEComboBox.SelectedValue.ToString();

            OfficeCode = officeval;

            //LAST_NAME_CONTEXT.QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE.RemoveRange(LAST_NAME_CONTEXT.QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE.ToList());
            LAST_NAME_CONTEXT.Dispose();
            LAST_NAME_CONTEXT = new Data_Model.Portable_Traps_Entities();

            var LastNames = LAST_NAME_CONTEXT.QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE
                            .Where(QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE => QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE.OFFICE == OfficeCode)
                            .ToList();

            System.Windows.Data.CollectionViewSource qRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICEViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("qRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICEViewSource")));
            // Load data by setting the CollectionViewSource.Source property:
            qRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICEViewSource.Source = LAST_NAME_CONTEXT.QRY_EMPLOYEES_LAST_NAME_LIST_WITH_OFFICE.Local;
        }