private void ContractFillListView(bool sort, int range) { if (Contracts_Grouping_ListView != null) { Contracts_Grouping_ListView.Items.Clear(); wait_image.Visibility = Visibility.Visible; } int sliderValue = (int)DistanceGrouper_Slider.Value; new Thread(() => { List <IGrouping <int, Contract> > v = BlTools.GroupContractByDistance(sort, sliderValue).ToList(); Dispatcher.Invoke(new Action(() => { try { wait_image.Visibility = Visibility.Collapsed; Contracts_Grouping_ListView.Visibility = Visibility.Visible; foreach (var item in v) { Contracts_Grouping_ListView.Items.Add(item); } } catch (Exception n) { MessageBox.Show(n.Message); } })); }).Start(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { int Momid = (int)value; Mother mother = BlTools.GetMother(Momid); return(mother.MomFirstName + " " + mother.MomFamilyName); }
private void CalculateSalary() { Child child = BlTools.GetChild(int.Parse(Update_Child_ID_TextBlock.Text)); Nanny nanny = BlTools.GetNanny(int.Parse(Update_Nanny_ID_TextBlock.Text)); double salary; if (!nanny.NannyIsHourlySalary) { Payment_Method_ComboBox.IsEnabled = false; Hourly_ComboBoxItem.Visibility = Visibility.Collapsed; Payment_Method_ComboBox.SelectedItem = Monthly_ComboBoxItem; salary = BlTools.CalculateMonthlySalary(nanny, child); finalSalary = salary; Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS"; } else { Hourly_ComboBoxItem.Visibility = Visibility.Visible; if (Payment_Method_ComboBox.SelectedItem != null) { if (Payment_Method_ComboBox.SelectedIndex == 1) { salary = BlTools.CalculateMonthlySalary(nanny, child); Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS"; finalSalary = salary; } if (Payment_Method_ComboBox.SelectedIndex == 0) { salary = BlTools.CalculateHourlySalary(nanny, child); Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS"; finalSalary = salary; } } } }
private void Filter_Btn_Click(object sender, RoutedEventArgs e) { bool[] filterDaysNeedNannyArr = new bool[6]; if (Sunday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[0] = true; } if (Monday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[1] = true; } if (Tuesday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[2] = true; } if (Wednesday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[3] = true; } if (Thursday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[4] = true; } if (Friday_ListBoxItem.IsSelected) { filterDaysNeedNannyArr[5] = true; } Mothers_DataGrid.ItemsSource = BlTools.FilterMothers(filterDaysNeedNannyArr); }
public void AddMom(Mother inputMother) { if (!BlTools.IsCorrectId(inputMother.MomID)) { throw new Exception("Error ID, please enter ID with 6 to 9 numbers"); } dal.AddMom(inputMother); }
private void RefreshDataGridOfChilds() { if (MinAgeFilter_Slider.Value > MaxAgeFilter_Slider.Value) { throw new Exception("Error, The minimum age must be less than the maximum age"); } bool?isHaveNanny; switch (isHaveNannyFilter_ComboBox.SelectedIndex) { case (0): isHaveNanny = null; break; case (1): isHaveNanny = true; break; case (2): isHaveNanny = false; break; default: isHaveNanny = null; break; } bool?isHaveSpecialNeeds; switch (SpecialNeedsFilter_ComboBox.SelectedIndex) { case (0): isHaveSpecialNeeds = null; break; case (1): isHaveSpecialNeeds = true; break; case (2): isHaveSpecialNeeds = false; break; default: isHaveSpecialNeeds = null; break; } Mother mother = null; if (MotherFilter_ComboBox.SelectedIndex != 0) { mother = MotherFilter_ComboBox.SelectedItem as Mother; } Childs_DataGrid.ItemsSource = BlTools.FilterChilds(isHaveNanny, isHaveSpecialNeeds, (int)MaxAgeFilter_Slider.Value, (int)MinAgeFilter_Slider.Value, mother); }
//threading private void ThreadAndFillDataGrid(IEnumerable <Nanny> IEnanny) { try { int momId = BlTools.GetMomIdOfChildId((All_Childs_ComboBox.SelectedItem as Child).ChildID); new Thread(() => { List <Nanny> l = IEnanny.ToList(); List <NannyWithDis> fiveAppropriateNanniesList = null; //if there is no fully fit nanny if (l.Count == 0) { Mother mother; Dispatcher.BeginInvoke(new Action(() => { try { Nannies_warning.Visibility = Visibility.Visible; Column_Distance.Visibility = Visibility.Visible; Order_ComboBox.IsEnabled = false; } catch (Exception c) { MessageBox.Show(c.Message); } })); mother = BlTools.GetMother(momId); fiveAppropriateNanniesList = BlTools.FiveAppropriateNannies(mother); } Dispatcher.Invoke(new Action(() => { try { wait_image.Visibility = Visibility.Collapsed; if (fiveAppropriateNanniesList == null) { Nannies_Fit_Mom_DataGrid.ItemsSource = l; } else { Nannies_Fit_Mom_DataGrid.ItemsSource = fiveAppropriateNanniesList; } } catch (Exception n) { MessageBox.Show(n.Message); } })); }).Start(); } catch (Exception n) { MessageBox.Show(n.Message); } }
public bool DeleteNanny(int inputNannyId) { Nanny tempNanny = BlTools.GetNanny(inputNannyId); if (tempNanny != null && tempNanny.IsNannyInContract()) { throw new Exception("Nanny with the same id found in contract. please delete all contracts the nanny is connected to, and then delete the child"); } return(dal.DeleteNanny(inputNannyId)); }
private void NannyFillListView(bool max, bool sort) { Nannies_Grouping_ListView.Items.Clear(); IEnumerable <IGrouping <int, Nanny> > v = BlTools.GroupNanniesByChildMonths(max, sort); foreach (var item in v) { Nannies_Grouping_ListView.Items.Add(item); } }
public bool DeleteContract(int inputContractId) { Child child = BlTools.GetChild(BL.BlTools.GetContract(inputContractId).ChildID); if (dal.DeleteContract(inputContractId)) { child.IsHaveNanny = false; return(true); } return(false); }
public bool DeleteChild(int inputChildId) { Child tempChild = BlTools.GetChild(inputChildId); if (tempChild != null && tempChild.IsChildInContract()) { throw new Exception("Child with the same id found in contract. please delete all contracts the child is connected to, and then delete the child"); } return(dal.DeleteChild(inputChildId)); }
public void UpdateContractDetails(Contract inputContract) { Contract oldContract = BlTools.GetContract(inputContract.ContID); if (oldContract.IsIntroductoryMeeting == false && inputContract.IsContractSigned == true) { throw new Exception("You can not sign a contract before a meeting"); } // צריך לעשות בדיקה שאם שינינו תאריך או שיטת תשלום אך החוזה לא נחתם אז אי אפשר dal.UpdateContractDetails(inputContract); }
private void Order_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //reset Nannies_Fit_Mom_DataGrid.ItemsSource = null; Column_NannyMonthlySalary.Visibility = Visibility.Collapsed; Column_NannyHourlySalary.Visibility = Visibility.Collapsed; Column_NannyYearsOfExperience.Visibility = Visibility.Collapsed; Column_Distance.Visibility = Visibility.Collapsed; if (Nannies_warning.Visibility == Visibility.Visible) { Nannies_warning.Visibility = Visibility.Collapsed; } int distance; if (int.TryParse(Distance_TextBox.Text, out distance)) { if (All_Childs_ComboBox.SelectedItem != null) { Child child = All_Childs_ComboBox.SelectedItem as Child; wait_image.Visibility = Visibility.Visible; switch (Order_ComboBox.SelectedIndex) { case 0: ThreadAndFillDataGrid(BlTools.MostAppropriateNanniesByDistance(child, distance)); break; case 1: ThreadAndFillDataGrid(BlTools.MostAppropriateNanniesByMonthlyPrice(child, distance)); Column_NannyMonthlySalary.Visibility = Visibility.Visible; break; case 2: ThreadAndFillDataGrid(BlTools.MostAppropriateNanniesByHourlyPrice(child, distance)); Column_NannyHourlySalary.Visibility = Visibility.Visible; break; case 3: ThreadAndFillDataGrid(BlTools.MostAppropriateNanniesByYearsOfExperience(child, distance)); Column_NannyYearsOfExperience.Visibility = Visibility.Visible; break; } } } }
private void Show_Nanny_Card_Button_Click(object sender, RoutedEventArgs e) { //Show_Nanny_Card Nanny nanny; if (Nannies_Fit_Mom_DataGrid.SelectedItem is Nanny) { nanny = Nannies_Fit_Mom_DataGrid.SelectedItem as Nanny; } else { nanny = BlTools.GetNanny((Nannies_Fit_Mom_DataGrid.SelectedItem as NannyWithDis).NannyId); } NannyCard nannyCard = new NannyCard(nanny, dataGridToRefresh); nannyCard.Show(); }
public void AddContract(Contract inputContract) { Nanny nanny = DalTools.GetNanny(inputContract.NannyID); Child child = DalTools.GetChild(inputContract.ChildID); //cheak if the age of the infant is under 3 month DateTime age = (DalTools.GetChild(inputContract.ChildID)).ChildAge; age.AddMonths(3); if (DateTime.Now < age) { throw new Exception("Can't add Child to Contract under 3 months"); } //checks if nanny capacity is full if (nanny.IsNannyCapacityIsFull()) { throw new Exception("Nanny hace reached the maximum infants capacity..."); } //checks if child age is not over the maximum/minimum nanny accepts int childAgeInMonths = child.AgeInMonths(); if (childAgeInMonths < nanny.NannyMinInfantAge || childAgeInMonths > nanny.NannyMaxInfantAge) { throw new Exception("Nanny can't accept this age"); } if (inputContract.IsContractSigned) { //checks if contract salary calculated by month or by hour and updates the salary nanny if (inputContract.PaymentMethod == Payment_method.hourly) { inputContract.HourlySalary = BlTools.CalculateHourlySalary(nanny, child); } else { inputContract.MonthlySalary = BlTools.CalculateMonthlySalary(nanny, child); } } BlTools.GetChild(inputContract.ChildID).IsHaveNanny = true; dal.AddContract(inputContract); }
private void Filter_Btn_Click(object sender, RoutedEventArgs e) { bool[] filterWorkDayArr = new bool[6]; if (Sunday_ListBoxItem.IsSelected) { filterWorkDayArr[0] = true; } if (Monday_ListBoxItem.IsSelected) { filterWorkDayArr[1] = true; } if (Tuesday_ListBoxItem.IsSelected) { filterWorkDayArr[2] = true; } if (Wednesday_ListBoxItem.IsSelected) { filterWorkDayArr[3] = true; } if (Thursday_ListBoxItem.IsSelected) { filterWorkDayArr[4] = true; } if (Friday_ListBoxItem.IsSelected) { filterWorkDayArr[5] = true; } int MaxNumberOfChilds = 1000; if (MaxNumberOfChildren_ComboBox.SelectedIndex < 7) { MaxNumberOfChilds = 2 + MaxNumberOfChildren_ComboBox.SelectedIndex * 2; } Nannys_DataGrid.ItemsSource = BlTools.FilterNannys((int)MinAgeFilter_Slider.Value, (int)MinExperienceFilter_Slider.Value, (int)MinAgeOfChilds_Slider.Value, (int)MaxAgeOfChilds_Slider.Value, MaxNumberOfChilds, filterWorkDayArr); SimpleFilter_ComboBox.SelectedIndex = -1; }
public void AddChild(Child inputChild) { if (inputChild.ChildAge > DateTime.Now) { throw new Exception("Error, The date of birth can not be greater than the current date"); } if (inputChild.ChildAge < DateTime.Now.AddYears(-13)) { throw new Exception("Error, The child should be younger than 13 years of age"); } if (!BlTools.IsCorrectId(inputChild.ChildID)) { throw new Exception("Error ID, please enter ID with 6 to 9 numbers"); } dal.AddChild(inputChild); }
public void AddNanny(Nanny inputNanny) { DateTime age = inputNanny.NannyDateOfBirth; age.AddYears(18); if (DateTime.Now < age) { throw new Exception("Can't add Nanny under 18 age"); } //checks if id is correct if (!BlTools.IsCorrectId(inputNanny.NannyId)) { throw new Exception("Error ID, please enter ID with 6 to 9 numbers"); } dal.AddNanny(inputNanny); }
public void UpdateNannyDetails(Nanny inputNanny) { Nanny oldNanny = BlTools.GetNanny(inputNanny.NannyId); DateTime tempDate = inputNanny.NannyDateOfBirth; tempDate.AddYears(18); if (DateTime.Now < tempDate) { throw new Exception("Can't add Nanny under 18 age"); } //now will check if nanny have properties in contracts //that the new updates not fit to them var allNannyContracts = GetAllContracts(s => s.NannyID == inputNanny.NannyId); int numOfChildsNannyHave = allNannyContracts.Count(); if (numOfChildsNannyHave > inputNanny.NannyMaxInfants) { throw new Exception("Nanny have actual more infants then the new maximum she asking to update to. " + "please remove some contracts until the new maximum will be good."); } foreach (var item in allNannyContracts) { Child child = BlTools.GetChild(item.ChildID); int childAgeInMonths = child.AgeInMonths(); if (childAgeInMonths > inputNanny.NannyMaxInfantAge || childAgeInMonths < inputNanny.NannyMinInfantAge) { throw new Exception("Nanny have contracts with childs that not match to " + "new max/min age policy. please remove those childs"); } if (item.PaymentMethod == Payment_method.hourly && inputNanny.NannyIsHourlySalary == false) { throw new Exception("Nanny have contracts with hourly payments, cant change to monthly salary"); } } dal.UpdateNannyDetails(inputNanny); }
private void Select_Button_Click(object sender, RoutedEventArgs e) { //will show the nanny inthe nanny combobox when nanny chosen Nanny nanny; if (Nannies_Fit_Mom_DataGrid.SelectedItem is Nanny) { nanny = BlTools.GetNanny((Nannies_Fit_Mom_DataGrid.SelectedItem as Nanny).NannyId); } else { nanny = BlTools.GetNanny((Nannies_Fit_Mom_DataGrid.SelectedItem as NannyWithDis).NannyId); } if (nanny == null) { throw new Exception("Error, The nanny was deleted"); } All_Nannies_ComboBox.SelectedItem = nanny; }
private void CalculateSalary() { Payment_Method_ComboBox.IsEnabled = true; Child child = All_Childs_ComboBox.SelectedItem as Child; Nanny nanny = All_Nannies_ComboBox.SelectedItem as Nanny; double salary; if (!nanny.NannyIsHourlySalary) { Payment_Method_ComboBox.IsEnabled = false; Hourly_ComboBoxItem.Visibility = Visibility.Collapsed; Payment_Method_ComboBox.SelectedItem = Monthly_ComboBoxItem; salary = BlTools.CalculateMonthlySalary(nanny, child); Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS"; newContract.MonthlySalary = salary; } else { Hourly_ComboBoxItem.Visibility = Visibility.Visible; if (Payment_Method_ComboBox.SelectedItem != null) { if (Payment_Method_ComboBox.SelectedIndex == 1) { salary = BlTools.CalculateMonthlySalary(nanny, child); Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS"; newContract.MonthlySalary = salary; } if (Payment_Method_ComboBox.SelectedIndex == 0) { salary = BlTools.CalculateHourlySalary(nanny, child); Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS"; newContract.HourlySalary = salary; } } } }
private void SimpleFilter_ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { MaxNumberOfChildren_ComboBox.SelectedIndex = 7; MinAgeFilter_Slider.Value = 18; MinAgeOfChilds_Slider.Value = 3; MaxAgeOfChilds_Slider.Value = 156; MinExperienceFilter_Slider.Value = 0; Sunday_ListBoxItem.IsSelected = false; Monday_ListBoxItem.IsSelected = false; Tuesday_ListBoxItem.IsSelected = false; Wednesday_ListBoxItem.IsSelected = false; Thursday_ListBoxItem.IsSelected = false; Friday_ListBoxItem.IsSelected = false; if (SimpleFilter_ComboBox.SelectedIndex == 0) { Nannys_DataGrid.ItemsSource = bl.GetAllNannies(); } if (SimpleFilter_ComboBox.SelectedIndex == 1) { Nannys_DataGrid.ItemsSource = BlTools.AllNanniesAllowsHourlySalary(); } }