Exemplo n.º 1
0
        private void UniverseTreeViewSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            var node = e.NewValue;

            if (node is Station)
            {
                var sector = Sectors.First(sect => sect.Systems.Any(sys => sys.Stations.Contains(node as Station)));
                var system = sector.Systems.First(sys => sys.Stations.Contains(node as Station));
                cboSector.SelectedValue  = sector;
                cboSys.SelectedValue     = system;
                cboStation.SelectedValue = node as Station;
            }
            else if (node is SolarSystem)
            {
                var sector = Sectors.First(sect => sect.Systems.Contains(node as SolarSystem));
                cboSector.SelectedValue  = sector;
                cboSys.SelectedValue     = node as SolarSystem;
                cboStation.SelectedValue = null;
            }
            else if (node is Sector)
            {
                cboSector.SelectedValue  = node as Sector;
                cboSys.SelectedValue     = null;
                cboStation.SelectedValue = null;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Resets the PVC allocation wait timer.
 /// The value is reset to the <see cref="MaxPVCAllocateWait"/> number of
 /// complete turn cycles (w/ adjustment). This means that if it is 1, then all players
 /// have to complete their turn once, and the player who got found the PVC
 /// has to complete their turn twice, before it is reallocated. This is to give
 /// an advantage to the other players.
 /// </summary>
 public void ResetPVCAllocateWait()
 {
     _lastPvcSector = Sectors.First(s => s.HasPVC).Id;
     Sectors[_lastPvcSector.Value].Stats.RemoveEffect <EffectImpl.PVCEffect>();
     Debug.Log("Previous sector de-allocated");
     _pvcAllocateWait = Game.Instance.Players.Count * MaxPVCAllocateWait;
     Debug.LogFormat("pvc allocate wait set to {0}", _pvcAllocateWait);
 }
        private void SaveExecute()
        {
            try
            {
                var db = new DataAccess();
                Employee.Surname            = Surname;
                Employee.GivenName          = GivenName;
                Employee.LocationID         = Location.LocationID;
                Employee.Sex                = Sex.ToLower();
                Employee.PersonalNo         = PersonalNo;
                Employee.DateOfBirth        = GeneratingData.GenerateBirthdate(Employee.PersonalNo);
                EmployeeAge                 = GeneratingData.CalculateAge(Employee.DateOfBirth);
                Employee.Manager            = Manager;
                Employee.Telephone          = Telephone;
                Employee.RegistrationNumber = RegistrationNumber;
                if (Sectors.Any(s => s.Name == SectorName))
                {
                    Employee.SectorID = Sectors.First(s => s.Name == SectorName).SectorID;
                }
                else
                {
                    var newSector = new tblSector()
                    {
                        Name = SectorName
                    };
                    //adding new sector to database
                    db.AddNewSector(newSector);
                    Sectors           = LoadSectors();
                    Employee.SectorID = Sectors.FirstOrDefault(s => s.Name == SectorName).SectorID;
                }

                //updating employee
                db.UpdateEmployee(Employee.EmployeeID, Employee);

                workerUpdate.RunWorkerAsync();

                IsUpdatedEmployee = true;
                updateEmployeeView.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void SaveExecute()
        {
            try
            {
                var db = new DataAccess();
                Employee.Sex = Sex.ToLower();
                Employee.RegistrationNumber = RegistrationNumber;
                Employee.PersonalNo         = PersonalNo;
                Employee.LocationID         = Location.LocationID;
                Employee.DateOfBirth        = GeneratingData.GenerateBirthdate(Employee.PersonalNo);
                if (Sectors.Any(s => s.Name == SectorName))
                {
                    Employee.SectorID = Sectors.First(s => s.Name == SectorName).SectorID;
                }
                else
                {
                    var newSector = new tblSector()
                    {
                        Name = SectorName
                    };
                    //adding new sector to database
                    db.AddNewSector(newSector);
                    Sectors           = LoadSectors();
                    Employee.SectorID = Sectors.FirstOrDefault(s => s.Name == SectorName).SectorID;
                }


                //adding new employee to database
                db.AddNewEmployee(Employee);

                workerAddNew.RunWorkerAsync();

                IsAddedNewEmployee = true;

                addNewEmployeeView.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }