private async void CheckDateButton_Click_Async(object sender, RoutedEventArgs e) { try { choosingControls.Visibility = Visibility.Collapsed;// CheckDateButton.Visibility = ChooseLabel.Visibility = Visibility.Collapsed; //busyIndicator.Visibility = Visibility.Visible; DateTime dt = dateTimePicker.DateTime; Exception exception = null; await Task.Run(new Action(() => { try { alternateDate = bl.AddTest(trainee, dt, trainee.Address, trainee.VehicleTypeTraining); } catch (Exception ex) { exception = ex; } })); //busyIndicator.Visibility = Visibility.Collapsed; if (exception != null) { throw exception; } //Thread thread = new Thread(delegate () { AlternateDate = bl.AddTest(trainee, dateTimePicker.DateTime, /*new DateTime(),*/ trainee.Address, trainee.VehicleTypeTraining); }); if (alternateDate == null) { DetailsOfMyTest.MyTestDadaGrid.ItemsSource = bl.GetTests(t => t.TraineeID == trainee.ID && t.Vehicle == trainee.VehicleTypeTraining && t.IsPass == null); detailsControls.Visibility = Visibility.Visible; return; } else { //SuggestAlternateDateOfTest.Date.Text = alternateDate.Value.ToString("g"); SuggestAlternateDateOfTest.calendar.SelectedDate = alternateDate; suggestControls.Visibility = Visibility.Visible; } } catch (CasingException ex) when(ex.DisplayToUser) { Functions.ShowMessageToUser(ex); choosingControls.Visibility = Visibility.Visible; //dateTimePicker.Visibility = CheckDateButton.Visibility = ChooseLabel.Visibility = Visibility.Visible; } catch (Exception ex) { Functions.SendMailToAdmin(ex); Close(); } }
/// <summary> /// Ad dButton Click to save the test /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddButton_Click(object sender, RoutedEventArgs e) { if (errorMessages.Any()) { string err = ":יש לתקן את השגיאות"; foreach (var item in errorMessages) { err += "\n" + item; } MessageBox.Show(err); return; } try { bl.AddTest(test); this.Closing -= Window_Closing; this.DialogResult = true; bl.SendEmail(test.TestID, BE.EmailType.TestAdded); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main(string[] args) { try { MapReq(new Address(), new Address()); Debug.WriteLine("jvnrfvnjrkl"); Console.WriteLine("FrEf"); //WriteLine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); ReadKey(); ForegroundColor = ConsoleColor.Green; bl.AddTester(new Tester("323947747", new Person.PersonName { FirstName = "Shmuel", LastName = "Garber" }, new DateTime(1950, 7, 13), Gender.male, "0547424870", new Address { Street = "Hganenet", HouseNumber = 5, City = "Jerusalem" }, "1234", 10, 30, Vehicle.tractor, new Schedule(new bool[, ] { { true, false, false, false, false, false, true, false }, { true, false, false, true, false, false, false, false }, { true, false, false, false, false, false, false, false }, { true, false, false, false, false, false, false, false }, { true, false, false, false, false, false, false, false } }), 20)); bl.AddTester(new Tester("322680083", new Person.PersonName { FirstName = "Refael", LastName = "Goldis" }, new DateTime(1949, 5, 12), Gender.male, "0556824870", new Address { Street = "Gordon", HouseNumber = 22, City = "Tel-Aviv" }, "1234", 6, 16, Vehicle.heavyTruck, new Schedule(new bool[, ] { { true, true, false, true, false, false, false, true }, { true, false, false, true, false, true, false, false }, { true, false, false, false, false, false, false, true }, { true, false, false, true, false, false, false, false }, { true, false, false, false, false, false, false, false } }), 16)); bl.AddTrainee(new Trainee("212384507", new Person.PersonName { FirstName = "Yael", LastName = "katri" }, new DateTime(1995, 10, 6), Gender.female, "0541234567", new Address { Street = "Franco", HouseNumber = 16, City = "Hadera" }, "1234", Vehicle.tractor, Gearbox.manual, "TheBest", new Person.PersonName { FirstName = "Shmuel", LastName = "Garber" }, 34, default)); bl.AddTrainee(new Trainee("323947739", new Person.PersonName { FirstName = "Asaf", LastName = "Levi" }, new DateTime(1948, 10, 6), Gender.female, "0541234567", new Address { Street = "Hatmarim", HouseNumber = 16, City = "Eilat" }, "1234", Vehicle.heavyTruck, Gearbox.manual, "TheBest", new Person.PersonName { FirstName = "Shmuel", LastName = "Garber" }, 34, default)); bl.AddTest(bl.GetTrainee("212384507"), new DateTime(2019, 1, 2, 8, 0, 0), /*new DateTime(2019, 1, 2),*/ new Address { Street = "Hganenet", HouseNumber = 7, City = "Jerusalem" }, Vehicle.tractor); bl.AddTest(bl.GetTrainee("323947739"), new DateTime(2019, 1, 2, 8, 0, 0), /*new DateTime(2019, 1, 2),*/ new Address { Street = "Hatmarim", HouseNumber = 18, City = "Eilat" }, Vehicle.heavyTruck); bl.UpdateTester(new Tester("323947747", new Person.PersonName { FirstName = "Samuel", LastName = "Garber" }, new DateTime(1950, 7, 13), Gender.male, "0566824871", new Address { Street = "Jorg", HouseNumber = 9, City = "Jerusalem" }, "1234", 10, 30, Vehicle.tractor, new Schedule(new bool[, ] { { true, false, false, false, false, false, true, false }, { true, false, false, true, false, false, false, false }, { true, false, false, false, false, false, false, false }, { true, false, false, false, false, false, false, false }, { true, false, false, false, false, false, false, false } }), 20)); bl.UpdateTrainee(new Trainee("212384507", new Person.PersonName { FirstName = "Yosepa", LastName = "katri" }, new DateTime(1995, 10, 6), Gender.female, "054124545", new Address { Street = "Franco", HouseNumber = 16, City = "KiriatShmona" }, "1234", Vehicle.tractor, Gearbox.manual, "TheBest", new Person.PersonName { FirstName = "Shmuel", LastName = "Garber" }, 34, default)); foreach (var test in bl.GetSortedFutureTests()) { Console.WriteLine(test.ToString()); } Console.WriteLine("--------------------------------------------------"); //bl.UpdateTest("212384507", Vehicle.tractor, true, true, false, true, true, false, true, "Good!"); //bl.UpdateTest("323947739", Vehicle.heavyTruck, false, false, false, true, true, false, false, "Not good!"); Console.WriteLine(bl.NumberOfDoneTests(bl.GetTrainee("212384507"))); Console.WriteLine("--------------------------------------------------"); foreach (var test in bl.GetTests(t => t.IsPass ?? false)) { Console.WriteLine(test.ToString()); } Console.WriteLine("--------------------------------------------------"); foreach (var t in bl.GetTesters()) { Console.WriteLine(t.ToString()); } Console.WriteLine("--------------------------------------------------"); foreach (var t in bl.GetTrainees()) { Console.WriteLine(t.ToString()); } Console.WriteLine("--------------------------------------------------"); foreach (var t in bl.GetTests()) { Console.WriteLine(t.ToString()); } Console.WriteLine("--------------------------------------------------"); foreach (var item in bl.TestersByExpertise(true)) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } Console.WriteLine("--------------------------------------------------"); foreach (var item in bl.TraineesByDrivingSchool(true)) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } Console.WriteLine("--------------------------------------------------"); foreach (var item in bl.TraineesByNumberOfTests(true)) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } Console.WriteLine("--------------------------------------------------"); foreach (var item in bl.TraineesByTeacher(true)) { Console.WriteLine(item.Key); foreach (var item2 in item) { Console.WriteLine(item2); } } Console.WriteLine("--------------------------------------------------"); bl.RemoveTester(bl.GetTester("323947747")); bl.RemoveTester(bl.GetTester("322680083")); bl.RemoveTrainee(bl.GetTrainee("212384507")); bl.RemoveTrainee(bl.GetTrainee("323947739")); } catch (Exception e) { Console.WriteLine(e.Message); } Console.Read(); //DateTimeOffset }
private void Button_Click(object sender, RoutedEventArgs e) { if (TimeComboBox.SelectedIndex == -1) { // gif.Close(); MessageBox.Show("אנא בחר שעה", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); return; } if (SearchComboBox.SelectedIndex == -1) { MessageBox.Show("אנא בחר תלמיד", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); return; } if (dateDatePicker.SelectedDate.Value.DayOfWeek == DayOfWeek.Friday || // if chosen day is friday dateDatePicker.SelectedDate.Value.DayOfWeek == DayOfWeek.Saturday) // or saturday { MessageBox.Show("ימי העבודה הינם בין ראשון - חמישי", "", MessageBoxButton.OK, // prompting to user and adding two days to date MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); dateDatePicker.SelectedDate = dateDatePicker.SelectedDate.Value.AddDays(2); return; } if (cityTextBox.Text.Length == 0 || streetTextBox.Text.Length == 0 || buildingNumberTextBox.Text.Length == 0) { MessageBox.Show("אנא מלא את 3 השדות של הכתובת", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); return; } TempTest.Date = ((DateTime)dateDatePicker.SelectedDate).AddHours(TimeComboBox.SelectedIndex + Configuration.StartHour); if (Data.UserType != Data.Usertype.תלמיד) // if user type isn't trainee - pull id from combobox { TempTest.TraineeId = SearchComboBox.SelectedValue.ToString().Split(' ')[0]; } else // if user is a trainee - we "pull" his id from DATA class { TempTest.TraineeId = Data.UserID; } TempTest.CarType = bl.FindTrainee(TempTest.TraineeId).CarType; image.Visibility = Visibility.Visible; // showing an image during the looking for tester button.IsEnabled = false; // disabling the button during the waiting Message.Visibility = Visibility.Visible; //Window gif = new gif //{ // ShowActivated = true //}; //gif.Show(); new Thread(() => // Activating the bl layer by thread { try { bl.AddTest(TempTest); } catch (MyExceptions ex) { if (ex.SuggestedTest == null) { MessageBox.Show(ex._message); } else // there is a suggested test to offer to user { int choice = (int)MessageBox.Show(ex._message, "", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.No, MessageBoxOptions.RtlReading); if (choice == 6) { try { bl.AddTest(ex.SuggestedTest); } catch (MyExceptions Mex) { MessageBox.Show(Mex._message, "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); Data.MainUserControl = new AddTest(); } } else { MessageBox.Show("נסה להוסיף טסט אחר ידנית", "", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.RtlReading); Data.MainUserControl = new AddTest(); } } } Dispatcher.Invoke(new Action(() => { try { image.Visibility = Visibility.Hidden; button.IsEnabled = true; Data.MainUserControl = new AddTest(); } catch (Exception n) { MessageBox.Show(n.Message); } })); }).Start(); }
public static void AddTest() { string TesterId, TraineeId, City, Street, note; int result, year, month, day, hour, typeOfcar, gear, NumberHouse; DateTime Date; bool flag; Console.WriteLine("Enter: All Information"); TesterId = Console.ReadLine(); TesterId = CheckId(TesterId); TraineeId = Console.ReadLine(); TraineeId = CheckId(TraineeId); City = Console.ReadLine(); Street = Console.ReadLine(); NumberHouse = int.Parse(Console.ReadLine()); year = int.Parse(Console.ReadLine()); month = int.Parse(Console.ReadLine()); day = int.Parse(Console.ReadLine()); hour = int.Parse(Console.ReadLine()); Date = CheckDate(year, month, day, hour); note = Console.ReadLine(); do { Console.WriteLine("Private Car = 0, Two Wheeled Vehicles = 1, Medium Truck = 2, Heavy Truck = 3, CarService = 4, SecurityVehicl = 5"); typeOfcar = int.Parse(Console.ReadLine()); } while ((typeOfcar < 0) || (typeOfcar > 5)); do { Console.WriteLine("Manual=0, Automatic=1"); gear = int.Parse(Console.ReadLine()); } while ((gear < 0) || (gear > 1)); Test mytest = new Test { TestNumber = Configuration.NumOfTEST++, TesterId = TesterId, TraineeId = TraineeId, DateTimeOfTest = Date, //TestExitAddress = new Address(Street, NumberHouse, City), TestCriterion = new Criterion(), TestResult = PassOrFail.Nun, TestTypeOfCar = (TypeOfCar)typeOfcar, TestTypeOfGearbox = (TypeOfGearbox)gear, TesterNote = note, }; DateTime now = DateTime.Now; TimeSpan HasPass = mytest.DateTimeOfTest - now; // עבר תאריך הטסט if (HasPass.TotalDays < 0) { Console.WriteLine("If you whant to update test Criterion enter TRUE, else enter FALSE"); flag = bool.Parse(Console.ReadLine()); if (flag == true) { setCriterion(mytest.TestCriterion); } result = bl.sumOfCriterion(mytest); if (result > 3) { mytest.TestResult = PassOrFail.Fail; } else { mytest.TestResult = PassOrFail.Pass; } } try { bl.AddTest(mytest); } catch (Exception e) { Console.WriteLine(e.Message); } }