private void AddWorkStatus(object sender, RoutedEventArgs e)
        {
            if (EmployeeIDBox.Text.Length == 0 || monthBox.Text.Length == 0 || yearBox.Text.Length == 0 || MaxHoursBox.Text.Length == 0 || ActualHoursBox.Text.Length == 0 || MaxSalaryBox.Text.Length == 0)
            {
                MessageBox.Show("Fill all fields!");
            }
            else
            {
                using (AccountingSystemContext repository = new AccountingSystemContext())
                {
                    Months currentMonth       = (Months)Enum.Parse(typeof(Months), monthBox.Text);
                    int    currentEmployeeId  = Int32.Parse(EmployeeIDBox.Text);
                    int    currentYear        = Int32.Parse(yearBox.Text);
                    int    currentMaxHours    = Int32.Parse(MaxHoursBox.Text);
                    int    currentMaxSalary   = Int32.Parse(MaxSalaryBox.Text);
                    int    currentActualHours = Int32.Parse(ActualHoursBox.Text);
                    var    currentEmployee    = repository.Employees.First(x => x.ID == currentEmployeeId);
                    currentWorkHours = new WorkHours(currentEmployee, currentMonth, currentYear, currentMaxHours, currentMaxSalary, currentActualHours);
                    repository.WorkHourses.Add(currentWorkHours);

                    repository.SaveChanges();
                }
                ActualSalaryBlock.Text = currentWorkHours.ActualSalary.ToString();
            }
        }
        public WorkHoursStatus()
        {
            InitializeComponent();
            using (AccountingSystemContext context = new AccountingSystemContext())
            {
                var objectList = context.WorkHourses.ToList();

                foreach (WorkHours obj in objectList)
                {
                    headerBlock.Text         = " ID" + "\tEmployee ID" + "\tCurrennt Month" + "\t Year" + "\t Max hours per month" + "\t Actual hours per month" + "\t Max salary" + "\t Actual Salary" + "\n";
                    WorkHoursListBlock.Text += " " + obj.ID + "\t " + obj.EmployeeID + "\t" + obj.Month + "\t\t" + obj.Year + "\t\t" + obj.MaxHours + "\t\t" + obj.ActualHours + "\t\t" + obj.MaxSalary + "\t\t" + obj.ActualSalary + "\n";
                }
            }
        }
        public EmployeeList()
        {
            InitializeComponent();
            using (AccountingSystemContext context = new AccountingSystemContext())
            {
                var employeeList = context.Employees.ToList();

                foreach (Employee employee in employeeList)
                {
                    HeaderList.Text = " Employee ID" + "\tFirst name" + "\tLast Name" + "\t\tStart working date\n";
                    string info = $" {employee.ID,-20} \t{employee.LastName,-20} \t{employee.FirstName,-25} \t{employee.StartWorkingDate,-25}  \n";
                    EmpListBlock.Text += info;
                }
            }
        }
        private void AddNewEmpl(object sender, RoutedEventArgs e)
        {
            if (FirstNameBox.Text.Length == 0 || LastNameBox.Text.Length == 0 || StartDateBox.Text.Length == 0)
            {
                MessageBox.Show("Fill all fields!");
            }
            else
            {
                using (AccountingSystemContext repository = new AccountingSystemContext())
                {
                    repository.Employees.Add(new Employee(FirstNameBox.Text, LastNameBox.Text, StartDateBox.Text));

                    repository.SaveChanges();
                    logger.Info($"User [{FirstNameBox.Text}] [{LastNameBox.Text}] has been added!");
                }

                MainWindow main = new MainWindow();
                main.Show();
                Close();
            }
        }
Example #5
0
 /// <summary>
 /// Public constructor
 /// </summary>
 /// <param name="serviceProvider">Service provider</param>
 /// <param name="dbContext">Database context</param>
 public UserController(IServiceProvider serviceProvider, AccountingSystemContext dbContext)
 {
     _serviceProvider = serviceProvider;
     _dbContext       = dbContext;
 }
Example #6
0
 /// <summary>
 /// Public constructor
 /// </summary>
 /// <param name="dbContext">Database context</param>
 public EmployeeManager(AccountingSystemContext dbContext)
 {
     _dbContext = dbContext;
 }