示例#1
0
 /// <summary>
 /// Create a new Species object.
 /// </summary>
 /// <param name="speciesId">Initial value of the SpeciesId property.</param>
 public static Species CreateSpecies(global::System.Int32 speciesId)
 {
     Species species = new Species();
     species.SpeciesId = speciesId;
     return species;
 }
示例#2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Species EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSpecies(Species species)
 {
     base.AddObject("Species", species);
 }
示例#3
0
        private void LoadSpecies()
        {
            this.cbKingdom.SelectedIndexChanged -= new System.EventHandler(this.cbKingdom_SelectedIndexChanged);
            this.cbFamily.SelectedIndexChanged -= new System.EventHandler(this.cbFamily_SelectedIndexChanged);
            this.cbOrder.SelectedIndexChanged -= new System.EventHandler(this.cbOrder_SelectedIndexChanged);
            this.cbClass.SelectedIndexChanged -= new System.EventHandler(this.cbClass_SelectedIndexChanged);
            this.cbPhylum.SelectedIndexChanged -= new System.EventHandler(this.cbPhylum_SelectedIndexChanged);

            CurrentSpecies = SpeciesDataAccess.GetSpeciesById(_speciesId);
            try
            {
                pOrder = new PopupInfo((int)CurrentSpecies.OrderId, Enum.TreeOfLiveType.Order);
            }
            catch { }
            try
            {
                pFamily = new PopupInfo((int)CurrentSpecies.FamilyId, Enum.TreeOfLiveType.Family);
            }
            catch { }
            pOrderVis = false;
            pFamilyVis = false;
            if (CurrentSpecies.SpeciesStatu == null)
            {
                cbStatus.SelectedIndex = -1;
            }
            else
            {
                cbStatus.SelectedValue = CurrentSpecies.SpeciesStatu.StatusId;
            }

            txtName.Text = CurrentSpecies.SpeciesName;
            txtLatin.Text = CurrentSpecies.SpeciesLatin;
            txtSpeciesId.Text = CurrentSpecies.SpeciesId.ToString();
            rtBehaviour.Text = CurrentSpecies.Behaviour;
            rtBreeding.Text = CurrentSpecies.Breeding;
            rtDescription.Text = CurrentSpecies.Description;
            rtDistribution.Text = CurrentSpecies.Distribution;
            rtFood.Text = CurrentSpecies.Food;
            rtHabitat.Text = CurrentSpecies.Habitat;
            txtStatus.Text = CurrentSpecies.Status;

            FillKingdom(CurrentSpecies.KingdomId);
            cbKingdom_SelectedIndexChanged(this, new EventArgs());

            //kpcofg
            if (CurrentSpecies.PhylumId != null)
            {
                FillPhylum(CurrentSpecies.PhylumId);
                cbPhylum_SelectedIndexChanged(this, new EventArgs());
                if (CurrentSpecies.ClassId != null)
                {
                    FillClass(CurrentSpecies.ClassId);
                    cbClass_SelectedIndexChanged(this, new EventArgs());
                    if (CurrentSpecies.OrderId != null)
                    {
                        FillOrder(CurrentSpecies.OrderId);
                        cbOrder_SelectedIndexChanged(this, new EventArgs());
                        if (CurrentSpecies.FamilyId != null)
                        {
                            FillFamily(CurrentSpecies.FamilyId);
                            cbFamily_SelectedIndexChanged(this, new EventArgs());
                            if (CurrentSpecies.GenusId != null)
                            {
                                FillGenus(CurrentSpecies.GenusId);
                            }
                        }
                    }
                }
            }

            speciesFlags1.LoadData(CurrentSpecies.Flags);
            monthPicker1.LoadData(CurrentSpecies.Seasons);
            distributionPicker1.LoadData(CurrentSpecies.DistributionFlags);

            speciesColourUC1.SetSelectedColour(CurrentSpecies.Colour);

            this.cbKingdom.SelectedIndexChanged += new System.EventHandler(this.cbKingdom_SelectedIndexChanged);
            this.cbFamily.SelectedIndexChanged += new System.EventHandler(this.cbFamily_SelectedIndexChanged);
            this.cbOrder.SelectedIndexChanged += new System.EventHandler(this.cbOrder_SelectedIndexChanged);
            this.cbClass.SelectedIndexChanged += new System.EventHandler(this.cbClass_SelectedIndexChanged);
            this.cbPhylum.SelectedIndexChanged += new System.EventHandler(this.cbPhylum_SelectedIndexChanged);

            if (SpeciesDataAccess.HasMapReferences(CurrentSpecies.SpeciesId)) btnMap.Text += "\n\n(Seen in YVP)";

            LoadImage();
            LoadSimilarSpecies();
            SetCustomURL();
        }
示例#4
0
        private void CreateNewSpecies()
        {
            CurrentSpecies = SpeciesDataAccess.AddNewSpecies();
            _speciesId = CurrentSpecies.SpeciesId;

            try
            {
                Directory.CreateDirectory(GetPicturePath() + "\\" + CurrentSpecies.SpeciesId.ToString());
            }
            catch { }
        }
示例#5
0
 public static int SaveSpecies(Species SelectedSpecies)
 {
     return DataAccessLayer.SaveChanges();
 }
示例#6
0
        public static int GetSpeciesIdFromSimilarSpecies(Species CurrentSpecies, int SimilarId)
        {
            int speciesid = 0;

            var sp = from x in DataAccessLayer.SimilarSpecies
                     where x.SimilarId == SimilarId
                     select x;
            if (sp.ToList()[0].SpeciesToId1.SpeciesId == CurrentSpecies.SpeciesId)
            {
                speciesid = Int32.Parse(sp.ToList()[0].SpeciesId2.ToString());
            }
            else
            {
                speciesid = Int32.Parse(sp.ToList()[0].SpeciesId1.ToString());
            }
            return speciesid;
        }
示例#7
0
        public static int DeleteSpecies(Species SelectedSpecies)
        {
            int cnt = 0;

            try
            {
                IEnumerable<SimilarSpecy> s1 = from s in DataAccessLayer.SimilarSpecies
                                               where s.SpeciesId1 == SelectedSpecies.SpeciesId
                                               select s;
                foreach (SimilarSpecy item in s1)
                {
                    DataAccessLayer.DeleteObject(item);
                    cnt += DataAccessLayer.SaveChanges();
                }
                IEnumerable<SimilarSpecy> s2 = from s in DataAccessLayer.SimilarSpecies
                                               where s.SpeciesId2 == SelectedSpecies.SpeciesId
                                               select s;

                foreach (SimilarSpecy item in s2)
                {
                    DataAccessLayer.DeleteObject(item);
                    cnt += DataAccessLayer.SaveChanges();
                }
                IEnumerable<MapRef> m = from s in DataAccessLayer.MapRefs
                                               where s.SpeciesId == SelectedSpecies.SpeciesId
                                               select s;

                foreach (MapRef item in m)
                {
                    DataAccessLayer.DeleteObject(item);
                    cnt += DataAccessLayer.SaveChanges();
                }
            }
            catch { }
            try
            {
                DataAccessLayer.DeleteObject(SelectedSpecies);
                cnt += DataAccessLayer.SaveChanges(System.Data.Objects.SaveOptions.None);
            }
            catch (Exception ex)
            {
                string s = ex.ToString();
                DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedSpecies);
                return -1;
            }
            DataAccessLayer.Refresh(System.Data.Objects.RefreshMode.StoreWins, SelectedSpecies);
            return cnt;
        }