Exemple #1
1
    private void SerializeCollection(string filename)
    {
        // Crear un Employee
        Employees Emps = new Employees();
        Emps.CollectionName = "Employees";
        Employee John100 = new Employee("John", "100xxx");
        Employee juan101 = new Employee("Juan", "101aa");
        // Agrega un Employee a Employees
        Emps.Add(John100);
        Emps.Add(juan101);

        // Serializa
        XmlSerializer x = new XmlSerializer(Emps.GetType());
        TextWriter writer = new StreamWriter(filename);
        x.Serialize(Console.Out, Emps);
    }
Exemple #2
0
        static void Main6()
        {
            //List<int> obj = new List<int>();
            //obj.Add(10);
            //obj.Add(20);
            //foreach (int i in obj)
            //{
            //    Console.WriteLine(i);
            //}
            Employees objEmps = new Employees();

            //List<Employee> objEmps = new List<Employee>();
            objEmps.Add(new Employee {
                Empno = 1, Name = "a"
            });
            objEmps.Add(new Employee {
                Empno = 2, Name = "b"
            });
            objEmps.Add(new Employee {
                Empno = 3, Name = "c"
            });
            objEmps.Add(new Employee {
                Empno = 4, Name = "d"
            });
            foreach (Employee e in objEmps)
            {
                Console.WriteLine(e.Name);
            }

            Console.ReadLine();
        }
Exemple #3
0
        public TestWindow()
        {
            InitializeComponent();

            Employees employees = new Employees();

            Employee employee1 = new Employee();

            employee1.EmployeeID          = 001;
            employee1.EmployeeName        = "Jakaria";
            employee1.EmployeeDesignation = "User Experience";

            employees.Add(employee1);

            Employee employee2 = new Employee();

            employee2.EmployeeID          = 002;
            employee2.EmployeeName        = "Moshiur";
            employee2.EmployeeDesignation = "Development";

            employees.Add(employee2);

            Employee employee3 = new Employee();

            employee3.EmployeeID          = 003;
            employee3.EmployeeName        = "Nazmul";
            employee3.EmployeeDesignation = "Database";

            employees.Add(employee3);

            dataGridEmployees.ItemsSource = employees;
        }
 protected virtual Employees MockEmployeesInShift()
 {
     Employees employees = new Employees();
     employees.Add(1, new Employee() { id = 1, name = "Lanny McDonald" });
     employees.Add(2, new Employee() { id = 2, name = "Allen Pitts" });
     return employees;
 }
 protected override Employees MockEmployeesInShift()
 {
     Employees employees = new Employees();
     //employees.Add(1, new Employee() { id = 1, name = "Lanny McDonald" });
     employees.Add(2, new Employee() { id = 2, name = "Allen Pitts" });
     employees.Add(4, new Employee() { id = 4, name = "Dave Sapunjis" });
     return employees;
 }
Exemple #6
0
        static void Main(string[] args)
        {
            var employees = new Employees();

            employees.Add(new Clerk());
            employees.Add(new Director());
            employees.Add(new President());

            employees.Accept(1.10f, new IncomeVisitor());
            employees.Accept(10, new VacationVisitor());

            Console.ReadLine();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var employees = new Employees();

            employees.Add(new Clerk()); // Visit as Employee (Employee visitor.Visit(context, this as dynamic);
            employees.Add(new Director());
            employees.Add(new President());

            employees.Accept(1.10f, new IncomeVisitor());
            employees.Accept(10, new VacationVisitor());

            Console.ReadLine();
        }
Exemple #8
0
 private void Paste(object paramemter)
 {
     CopyEmployee.ID       = Guid.NewGuid().ToString();
     CopyEmployee.ParentID = SelectedEmployee.ID;
     CopyEmployee.Name     = "(Copy)" + SelectedEmployee.Name;
     Employees.Add(CopyEmployee);
 }
Exemple #9
0
 /// <summary>
 /// Dodanie nowego pracownika do firmy
 /// </summary>
 /// <param name="em">Nowy pracownik</param>
 public void AddEditEmployee(Employee em)
 {
     if (!Employees.Exists(e => e.Name.Equals(em.Name)))
     {
         if (em.Roles.Exists(r => r.Priority == 6))
         {
             CEO = em;
         }
         Employees.Add(em);
     }
     else
     {
         Employee emp = Employees.Find(e => e.Name.Equals(em.Name));
         emp.EmploymentDate = em.EmploymentDate;
         emp.Roles.Clear();
         foreach (Role r in em.Roles)
         {
             emp.AddRole(r);
         }
         if (emp.Roles.Exists(r => r.Priority == 6))
         {
             CEO = emp;
         }
     }
 }
Exemple #10
0
        private void ButtonSearch_Click(object sender, RoutedEventArgs e)
        {
            string enteredName = TextBoxName.Text;

            if (string.IsNullOrEmpty(enteredName) ||
                string.IsNullOrWhiteSpace(enteredName))
            {
                MessageBox.Show(this, "Введите имя для поиска", "", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            Employees.Clear();

            List <ItemEmployee> employees = mySqlClient.GetEmployees(TextBoxName.Text);

            if (employees.Count == 0)
            {
                Employees.Add(new ItemEmployee()
                {
                    FullName = "Нет результатов"
                });
                return;
            }

            foreach (ItemEmployee item in employees)
            {
                Employees.Add(item);
            }
        }
Exemple #11
0
        /// <summary>
        /// Разбивает сотрудников из json на классы
        /// </summary>
        private void ListToObservableCollection()
        {
            foreach (var emp in _listEmployees)
            {
                switch (emp.EEmployee)
                {
                case EnEmployee.Intern:
                    Intern intern = new Intern(emp.FirstName, emp.LastName, emp.Age, emp.DepartmentId);
                    Employees.Add(intern);
                    break;

                case EnEmployee.Worker:
                    Worker worker = new Worker(emp.FirstName, emp.LastName, emp.Age, emp.DepartmentId);
                    Employees.Add(worker);
                    break;

                case EnEmployee.Manager:
                    Manager manager = new Manager(emp.FirstName, emp.LastName, emp.Age, emp.DepartmentId);
                    Employees.Add(manager);
                    break;

                default:
                    break;
                }
            }
        }
Exemple #12
0
 public string TryAddEmployee(string firstName, string lastName, string middleName, string phone, string series, string number, int idUser, int idPosition)
 {
     try
     {
         int id = 0;
         foreach (var Id in Employees.ToList())
         {
             id = Id.EmployeeID;
         }
         Employees.Add(new Employee
         {
             EmployeeID = id + 1,
             FirstName  = firstName,
             LastName   = lastName,
             MiddleName = middleName,
             Phone      = phone,
             Series     = series,
             Number     = number,
             PositonID  = idPosition
         });
         SaveChanges();
         return("Запись добавлена");
     }
     catch (Exception ex) { return(ex.Message); }
 }
        private void RepositoryEmployeeChanged(object sender, ItemChangedEventArgs <Employee> e)
        {
            if (e.Item.Person.Id != Model.Id)
            {
                return;
            }

            if (e.Action == ItemChangedEventArgs <Employee> .ActionType.Add)
            {
                Employees.Add(e.Item);
            }

            if (e.Action == ItemChangedEventArgs <Employee> .ActionType.Remove)
            {
                var emploee = Employees.FirstOrDefault(x => x.Organization.Id == e.Item.Organization.Id);
                if (emploee != null)
                {
                    Employees.Remove(emploee);
                }
            }

            if (e.Action == ItemChangedEventArgs <Employee> .ActionType.Update)
            {
                var emploee = Employees.FirstOrDefault(x => x.Organization.Id == e.Item.Organization.Id);
                if (emploee != null)
                {
                    Employees.Remove(emploee);
                }
                Employees.Add(e.Item);
            }
        }
Exemple #14
0
        private void InitializeResources()
        {
            Random random = new Random();

            for (int i = 0; i < 15; i++)
            {
                Employees.Add(new Employee()
                {
                    Name           = nameCollection[random.Next(0, 14)],
                    Color          = Color.FromRgb(random.Next(0, 255), random.Next(10, 255), random.Next(100, 255)),
                    Id             = "560" + i.ToString(),
                    DisplayPicture = i < 9 ? "employee" + i.ToString() + ".png" : null
                });
            }

            // Adding dummy resource for unallocated events
            Employees.Add(new Employee()
            {
                Name           = "Unallocated",
                Color          = Color.FromRgb(random.Next(0, 255), random.Next(10, 255), random.Next(100, 255)),
                Id             = "4731",
                DisplayPicture = "unallocated.png"
            });

            for (int i = 0; i < 10; i++)
            {
                this.selectedEmployees.Add(Employees[random.Next(Employees.Count)]);
            }
        }
Exemple #15
0
        public EmployeeListViewModel()
        {
            employeeService = new EmployeeService();
            LoadEmployees(string.Empty);

            MessagingCenter.Subscribe <AddOrEditEmployeePage, Employee>(this, "AddOrEditEmployee",
                                                                        (page, employee) =>
            {
                if (employee.EmployeeId == 0)
                {
                    employee.EmployeeId = Employees.Count + 1;
                    Employees.Add(employee);
                }
                else
                {
                    Employee employeeToEdit = Employees.Where(emp => emp.EmployeeId == employee.EmployeeId).FirstOrDefault();

                    int newIdex = Employees.IndexOf(employeeToEdit);
                    Employees.Remove(employeeToEdit);

                    Employees.Add(employee);
                    int oldIndex = Employees.IndexOf(employee);

                    Employees.Move(oldIndex, newIdex);
                }
            }
                                                                        );
        }
Exemple #16
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Employees.Clear();
                var employees = await DataStore.GetItemsAsync(true);

                foreach (var item in employees)
                {
                    Employees.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #17
0
        public EmployeesViewModel()
        {
            ActivateItem(new AddEmployeeViewModel());


            DateTime hire  = new DateTime(2011, 09, 12);
            DateTime hire2 = new DateTime(2018, 09, 12);
            DateTime hire3 = new DateTime(2015, 02, 27);
            DateTime hire4 = new DateTime(2016, 10, 31);

            Employees.Add(new EmployeeModel {
                FirstName = "James", MiddleInitial = "J", LastName = "Foster", HireDate = hire
            });
            Employees.Add(new EmployeeModel {
                FirstName = "Jane", MiddleInitial = "L", LastName = "Doe", HireDate = hire2
            });
            Employees.Add(new EmployeeModel {
                FirstName = "John", MiddleInitial = " ", LastName = "Doe", HireDate = hire3
            });
            Employees.Add(new EmployeeModel {
                FirstName = "Jack", MiddleInitial = "O", LastName = "Walker", HireDate = hire4
            });
            Employees.Add(new EmployeeModel {
                FirstName = "Jim", MiddleInitial = "K", LastName = "Doe", HireDate = hire2
            });
            Employees.Add(new EmployeeModel {
                FirstName = "Frank", MiddleInitial = "M", LastName = "Joker", HireDate = hire
            });

            Employees[0].VacationDays.Add(new VacationDayModel {
                UsedVacationTime = 8, DateVacationUsed = hire
            });
            Employees[0].Totals.VacationTimeTotal = 70;
            Employees[0].Totals.SickTimeTotal     = 40;
        }
Exemple #18
0
        partial void createEmployee(Foundation.NSObject sender)
        {
            NSUndoManager undo = this.UndoManager;

            // Has an edit occurred already in this event?
            if (undo.GroupingLevel > 0)
            {
                // Close the last group
                undo.EndUndoGrouping();
                // Open a new group
                undo.BeginUndoGrouping();
            }

            Person newEmployee = new Person();

            Console.WriteLine("Adding {0} to {1}", newEmployee, Employees);

            // Undo add
            NSArray args = NSArray.FromObjects(new object[] { newEmployee });

            undo.RegisterUndoWithTarget(this, new Selector("undoAdd:"), args);
            undo.SetActionname(NSBundle.MainBundle.LocalizedString("ADD_PERSON", null));

            Employees.Add(newEmployee);
            StartObservingPerson(newEmployee);
            tableView.ReloadData();

            int row = Employees.IndexOf(newEmployee);

            Console.WriteLine("Starting edit of {0} in row {1}", newEmployee, row);

            // Begin the edit of the first column
            tableView.SelectRow(row, false);
            tableView.EditColumn(0, row, null, true);
        }
Exemple #19
0
        private static void LoadEmployees(IRepository repository)
        {
            if (Employees == null)
            {
                Employees = new Dictionary <string, IList <Employee> >();
            }

            var schoolCodes = repository.OfType <Unit>().Queryable.Select(x => x.DeansOfficeSchoolCode).Distinct().ToArray();

            SchoolCodes = schoolCodes;  // For future use in checking what schools employees have been loaded for.

            var deptCodes =
                repository.OfType <Department>().Queryable.Where(
                    x => schoolCodes.Contains(x.DeansOfficeSchoolCode)).Select(y => y.Id).ToList();

            var allEmployees = repository.OfType <Employee>().GetAll();

            //MaxLastChangeDate = allEmployees.Select(x => x.LastChangeDate).Max();
            //LastRefreshed = DateTime.Now;

            foreach (var code in schoolCodes)
            {
                // Add all employees who have a home department within the school:
                Employees.Add(code, allEmployees.Where(d => deptCodes.Contains(d.HomeDepartmentID)).OrderBy(x => x.FullName).ToList());
            }
        }
Exemple #20
0
        public void AddEmployee(Employee employee)
        {
            Employees.Add(employee);
            employee.Company = this;

            employee.RefreshReferencedIds();
        }
        public void AddEmployee(DateTime birthDate, string dni, string email, string name, int telephon, String Iban, int Pin, String Position, Decimal Salary)
        {
            Employee employee = new Employee(birthDate, dni, email, name, telephon, Iban, Pin, Position, Salary);

            People.Add(employee);
            Employees.Add(employee);
        }
        static void MainOLD()
        {
            Employees employees = new Employees();

            Employee jesse = new DistributionManager();
            Employee walt  = new Cook();

            IVisitor payRise       = new IncomeVisitor();
            IVisitor extraVacation = new VacationVisitor();

            employees.Add(jesse);
            employees.Add(walt);

            employees.Accept(payRise);
            walt.Accept(extraVacation);
        }
        private void NewEmployee()
        {
            Employee e = new Employee();

            Employees.Add(e);
            SelectedEmployee = e;
        }
        /// <summary>
        /// Добавление работника.
        /// </summary>
        private void AddEmployee()
        {
            var empl = new Employee();

            Employees.Add(empl);
            SelectedEmployee = empl;
        }
Exemple #25
0
 public MainWindow()
 {
     InitializeComponent();
     Employees.Add(new Employee {
         Name = "sa_ddam213"
     });
 }
Exemple #26
0
        public async void AddEmployee()
        {
            Employee newEmployee = new Employee()
            {
                Name = "Nieuwe medewerker", Address = "Straat en nummer", Email = "*****@*****.**", Phone = "056 55 66 44"
            };

            using (HttpClient client = new HttpClient())
            {
                client.SetBearerToken(ConfigurationManager.AppSettings["token"]);
                string employee = JsonConvert.SerializeObject(newEmployee);
                HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["apiUrl"] + "api/employee", new StringContent(employee, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    string json = await response.Content.ReadAsStringAsync();

                    Employee emp = JsonConvert.DeserializeObject <Employee>(json);
                    if (emp != null)
                    {
                        Employees.Add(emp);
                        SelectedEmployee = emp;
                    }
                }
            }
        }
Exemple #27
0
        async Task ExecuteLoadEmployeesCommand()
        {
            IsBusy = true;

            try
            {
                Employees.Clear();
                var employees = await DataStore.GetEmployeesAsync(true);

                foreach (var employee in employees)
                {
                    var model = new EmployeeViewModel();
                    await model.FillEmployeeAsync(employee);

                    Employees.Add(model);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #28
0
        private async void ServiceCallback_AuthorizedEvent(DeviceModel device)
        {
            await Dispatcher.RunTaskAsync(async() =>
            {
                var d = new MessageDialog("SUCCESS");
                await d.ShowAsync();

                var list = await Proxy.GetAllEmployeesByDevice();
                foreach (var item in list)
                {
                    Employees.Add(item);
                }
            });

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                this.IsEnabled = true;
                DisableLoadingControl();

                if (device.Employee != null)
                {
                    NotificationControl.Show($"Willkommen, {device.Employee.Alias}", 3500);
                    SetCurrentEmployee(device.Employee);
                    Proxy.Device = device;
                }

                if (device.Division != null)
                {
                    SetCurrentDivision(device.Division);
                }
            });
        }
Exemple #29
0
        async Task ExecuteLoadItemsCommand()
        {
            //if (IsBusy)
            //    return;

            IsBusy = true;

            try
            {
                Employees.Clear();
                var items = await App.Database._employee.GetEmployeesAsync();

                //var items = await DataStore.GetItemsAsync(true);
                foreach (var item in items)
                {
                    Employees.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    IsBusy = false;
                });
                //IsBusy = false;
            }
        }
Exemple #30
0
 public override void AfterConstruction()
 {
     base.AfterConstruction();
     StartOn = DateTime.Now;
     EndOn   = StartOn.AddHours(1);
     Employees.Add(Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId));
 }
        private void Save(SideButton sideButton)
        {
            if (!Employee.HasErrors)
            {
                switch (sideButton)
                {
                case SideButton.Add:
                    Employee.Insert();
                    Employees.Add(Employee);
                    break;

                case SideButton.Edit:
                    Employee.Update();
                    OldEmployee.Copy(Employee);
                    break;
                }
                ReturnState(sideButton);
            }
            else
            {
                RadWindow.Alert(new DialogParameters
                {
                    Content = "Ada data yg masih kosong",
                    Owner   = Application.Current.MainWindow
                });
            }
        }
Exemple #32
0
 public void Add(Employee employee)
 {
     if (Capicity + 1 <= Employees.Count)
     {
         Employees.Add(employee);
     }
 }
Exemple #33
0
        /// <summary>
        /// Method to invoke when the AddEmployee command is executed.
        /// </summary>
        private void OnAddEmployeeExecute()
        {
            var employee = new Employee()
            {
                Department = SelectedDepartment
            };

            var typeFactory = TypeFactory.Default;
            var viewModel   = typeFactory.CreateInstanceWithParametersAndAutoCompletion <EmployeeViewModel>(employee);

            if (!(_uiVisualizerService.ShowDialog(viewModel) ?? false))
            {
                return;
            }

            _employeeRepository.AddEmployee(employee);

            if (employee.Department == SelectedDepartment)
            {
                Employees.Add(employee);
            }

            MessageMediator.SendMessage(employee.Department, "UpdateSelectedDepartmentFromEM");
            Mediator.SendMessage(string.Format("Employee {0} {1} is added in department {2}", employee.FirstName, employee.LastName, employee.Department.Name), "UpdateNotification");
        }
Exemple #34
0
	private void Create(string filename)
	{
		Employees emps=new Employees();

		/* Note that only the collection is serialized, not
		 * the CollectionName or any other public property of
		 * the class.
		 */
		emps.CollectionName="Employees";
		Employee john100=new Employee("John", "100xxx");
		emps.Add(john100);

		XmlSerializer ser=new XmlSerializer(typeof(Employees));
		TextWriter writer=new StreamWriter(filename);
		ser.Serialize(writer, emps);
		writer.Close();
	}