private void Window_Loaded(object sender, RoutedEventArgs e) { LeaseCompanies.SelectedValuePath = "Id"; LeaseCompanies.DisplayMemberPath = "Name"; LeaseCompanies.ItemsSource = _leaseCompanyBusiness.GetAll(); LoadDetails(); Details.ItemsSource = _details; Deductions.ItemsSource = _deductions; Reimbursements.ItemsSource = _reimbursements; Rates.ItemsSource = _rates; DateTime nextFriday = DateTime.Now.NextFriday(); DateTime toPayment = nextFriday.AddDays(business.Constant.PayrollLeaseCompany.LastThreeFridayPayrollLeaseCompany); DateTime fromPayment = toPayment.AddDays(business.Constant.Payroll.DaysWeek * -1); Date.SelectedDate = nextFriday; ToPayment.SelectedDate = toPayment; FromPayment.SelectedDate = fromPayment; _percentLeaseFeeValue = business.Constant.PayrollLeaseCompany.PercentLeaseFeeValue; _percentWorkerCompValue = business.Constant.PayrollLeaseCompany.PercentWorkerCompValue; PercentLeaseFeeValue.Text = _percentLeaseFeeValue.ToString(); PercentWorkerCompValue.Text = _percentWorkerCompValue.ToString(); }
public void LoadDataBySelectedRow(User user) { _idUserSelected = user.Id; Username.Text = user.Username; LastLogin.SelectedDate = user.LastLogin; Fullname.Text = user.Fullname; Email.Text = user.Email; IsActive.IsChecked = user.IsActive; List <Role> roles = _roleBusiness.GetAll(); _rolesView.Clear(); Roles.ItemsSource = null; roles.ForEach(x => { _rolesView.Add(new RoleDetailView() { Id = x.Id, Role = x.Name, IsActive = user.Roles.Where(y => y.Id == x.Id).Count() > 0 }); }); Roles.ItemsSource = _rolesView; }
private void Window_Loaded(object sender, RoutedEventArgs e) { Employees.SelectedValuePath = "Id"; Employees.DisplayMemberPath = "Fullname"; Employees.ItemsSource = _employeeBusiness.GetAll(); Clear(); }
public void SaveView() { if (IsViewValid()) { ChangeControlsEnabled(false); var id = _userBusiness.GetAll() .Where(x => x.Username == Username.Text) .DefaultIfEmpty(new User() { Id = string.Empty }) .FirstOrDefault() .Id; User user = new User() { Id = id, Username = Username.Text, Email = Email.Text, Fullname = Fullname.Text, IsActive = IsActive.IsChecked.Value, Password = Passsword.Text }; _rolesView.Where(x => x.IsActive) .ToList() .ForEach(x => user.Roles.Add(new Role() { Id = x.Id, Name = x.Role })); _userBusiness.Update(user); MessageBox.Show("The information was correctly saved!", "Save", MessageBoxButton.OK, MessageBoxImage.Information); ClearView(); FillGrid(); } else { MessageBox.Show(ValidationMessage, "Validations", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { Drivers.SelectedValuePath = "Id"; Drivers.DisplayMemberPath = "Fullname"; Drivers.ItemsSource = ((business.Driver)_driverBusiness).GetActives(); ((CollectionViewSource)Details.FindResource("OilCompanies")).Source = _companyBusiness.GetAll(); Details.ItemsSource = _details; RegularHour.Text = business.Constant.Payroll.RegularHour.ToString(); }
public void FillGrid() { _companiesModel = _companyBusiness.GetAll(); ListCompanies.ItemsSource = _companiesModel; List <Truck> trucks = _truckBusiness.GetAll(); _trucksView.Clear(); Trucks.ItemsSource = null; trucks.ForEach(x => { _trucksView.Add(new TruckDetailView() { Id = x.Id, IsActive = false, Truck = x.Number }); }); Trucks.ItemsSource = _trucksView; }
public void SaveView() { if (IsViewValid()) { ChangeControlsEnabled(false); var id = _truckBusiness.GetAll() .Where(x => x.Number == Number.Text) .DefaultIfEmpty(new Truck() { Id = string.Empty }) .FirstOrDefault() .Id; Truck truck = new Truck() { Id = id, Inspection = Inspection.SelectedDate.HasValue? Inspection.SelectedDate.Value : DateTime.MinValue, Make = Make.Text, Number = Number.Text, Plate = Plate.Text, Registration = Registration.SelectedDate.HasValue? Registration.SelectedDate.Value : DateTime.MinValue, Vin = Vin.Text, Year = int.Parse(Year.Text) }; _truckBusiness.Update(truck); MessageBox.Show("The information was correctly saved!", "Save", MessageBoxButton.OK, MessageBoxImage.Information); ClearView(); FillGrid(); } else { MessageBox.Show(ValidationMessage, "Validations", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void FillGrid() { _rolesModel = _roleBusiness.GetAll(); ListRoles.ItemsSource = _rolesModel; }
public void SaveView() { if (IsViewValid()) { ChangeControlsEnabled(false); var id = _employeeBusiness.GetAll() .Where(x => x.SocialSecurity == SocialSecurity.Text.ToSocialSecurity()) .DefaultIfEmpty(new Employee() { Id = string.Empty }) .FirstOrDefault() .Id; PaymentType paymentMethod = PaymentType.NA; Enum.TryParse(((ComboBoxItem)PaymentMethod.SelectedItem).Content.ToString(), out paymentMethod); TaxType taxForm = TaxType.NA; Enum.TryParse(((ComboBoxItem)TaxForm.SelectedItem).Content.ToString(), out taxForm); Employee employee = new Employee() { Address = Address.Text, Birthdate = Birthdate.SelectedDate.HasValue?Birthdate.SelectedDate.Value:DateTime.MinValue, Id = id, LastName = LastName.Text, License = new DriverLicense() { Expiration = ExpirationDate.SelectedDate.Value, Number = DriverLicense.Text, State = StateDriverLicense.Text }, Name = Name.Text, PaymentMethod = paymentMethod, PhoneNumber = PhoneNumber.Text, Rate = 0.0, SocialSecurity = SocialSecurity.Text.ToSocialSecurity(), State = State.Text, TaxForm = taxForm, City = City.Text, ZipCode = ZipCode.Text, Email = Email.Text, Job = JobDescription.Text, IsWeeklyPayment = CheckWeeklyPayment.IsChecked.Value }; if (CheckRate.IsChecked.Value) { employee.Rate = double.Parse(Rate.Text.Replace("$", string.Empty)); } else if (CheckWeeklyPayment.IsChecked.Value) { employee.Rate = double.Parse(WeeklyPayment.Text.Replace("$", string.Empty)); } _employeeBusiness.Update(employee); MessageBox.Show("The information was correctly saved!", "Save", MessageBoxButton.OK, MessageBoxImage.Information); ClearView(); FillGrid(); } else { MessageBox.Show(ValidationMessage, "Validations", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void FillGrid() { _companiesModel = _companyBusiness.GetAll(); ListCompanies.ItemsSource = _companiesModel; }
public void SaveView() { if (IsViewValid()) { ChangeControlsEnabled(false); var id = _driverBusiness.GetAll() .Where(x => x.SocialSecurity == SocialSecurity.Text.ToSocialSecurity()) .DefaultIfEmpty(new Driver() { Id = string.Empty }) .FirstOrDefault() .Id; PaymentType paymentMethod = PaymentType.NA; Enum.TryParse(((ComboBoxItem)PaymentMethod.SelectedItem).Content.ToString(), out paymentMethod); TaxType taxForm = TaxType.NA; Enum.TryParse(((ComboBoxItem)TaxForm.SelectedItem).Content.ToString(), out taxForm); Driver driver = new Driver() { Address = Address.Text, Birthdate = Birthdate.SelectedDate.HasValue? Birthdate.SelectedDate.Value:DateTime.MinValue, Contract = new Contract() { HireDate = HireDate.SelectedDate.HasValue?HireDate.SelectedDate.Value:DateTime.MinValue, TerminationDate = Actually.IsChecked.Value ? TerminationDate.SelectedDate : null }, Id = id, LastName = LastName.Text, License = new DriverLicense() { Expiration = ExpirationDate.SelectedDate.Value, Number = DriverLicense.Text, State = StateDriverLicense.Text }, Name = Name.Text, PaymentMethod = paymentMethod, PhoneNumber = PhoneNumber.Text, Rate = double.Parse(Rate.Text.Replace("$", string.Empty)), SocialSecurity = SocialSecurity.Text.ToSocialSecurity(), State = State.Text, TaxForm = taxForm, Truck = new Truck() { Id = (Trucks.SelectedItem as Truck).Id, Inspection = Inspection.SelectedDate.Value, Make = Make.Text, Number = (Trucks.SelectedItem as Truck).Number, Plate = Plate.Text, Registration = Registration.SelectedDate.Value, Vin = Vin.Text, Year = int.Parse(Year.Text) }, City = City.Text, ZipCode = ZipCode.Text, Email = Email.Text }; _driverBusiness.Update(driver); MessageBox.Show("The information was correctly saved!", "Save", MessageBoxButton.OK, MessageBoxImage.Information); ClearView(); FillGrid(); } else { MessageBox.Show(ValidationMessage, "Validations", MessageBoxButton.OK, MessageBoxImage.Error); } }