Beispiel #1
0
 public WorkersInformation(LibraryOfClasses.Worker theworker)
 {
     InitializeComponent();
     if (theworker != null)
     {
         Name.Text            = theworker.Name;
         BirthDate.Text       = theworker.BirthDate.ToString();
         WorkingPosition.Text = theworker.WorkingPosition;
         Salary.Text          = theworker.Salary.ToString();
     }
     Working = theworker;
 }
Beispiel #2
0
 private void ChangeWorkerInformation_Click(object sender, RoutedEventArgs e)
 {
     {
         string   name;
         DateTime birthday;
         string   position;
         double   salary;
         if (Working == null)
         {
             if (Name.Text.Trim() != "")
             {
                 name = Name.Text.Trim();
                 if (DateTime.TryParse(BirthDate.Text, out birthday))
                 {
                     if (WorkingPosition.Text.Trim() != "")
                     {
                         position = WorkingPosition.Text.Trim();
                         if (double.TryParse(Salary.Text, out salary))
                         {
                             LibraryOfClasses.Worker workers = new LibraryOfClasses.Worker
                             {
                                 Name            = name,
                                 BirthDate       = birthday,
                                 WorkingPosition = position,
                                 Salary          = salary
                             };
                             _repo.AddItem(workers);
                             Worker workerswindow = new Worker();
                             workerswindow.Show();
                             MessageBox.Show("The worker was added");
                             this.Close();
                         }
                         else
                         {
                             MessageBox.Show("Salary should the written with comma");
                         }
                     }
                     else
                     {
                         MessageBox.Show("Enter the working position");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Birthday should be in the following form - YYYY-MM-DD");
                 }
             }
             else
             {
                 MessageBox.Show("Enter the name");
             }
         }
         else
         {
             if (Name.Text.Trim() != "")
             {
                 name = Name.Text.Trim();
                 if (DateTime.TryParse(BirthDate.Text, out birthday))
                 {
                     if (WorkingPosition.Text.Trim() != "")
                     {
                         position = WorkingPosition.Text.Trim();
                         if (double.TryParse(Salary.Text, out salary))
                         {
                             if (!(name == Working.Name & salary == Working.Salary & birthday == Working.BirthDate & position == Working.WorkingPosition))
                             {
                                 LibraryOfClasses.Worker workers = new LibraryOfClasses.Worker
                                 {
                                     Name            = name,
                                     BirthDate       = birthday,
                                     WorkingPosition = position,
                                     Salary          = salary
                                 };
                                 _repo.UpdateItem(Working, workers);
                                 Worker workerswindow = new Worker();
                                 workerswindow.Show();
                                 MessageBox.Show("The worker was changed");
                                 this.Close();
                             }
                             else
                             {
                                 MessageBox.Show("You haven't change anything");
                             }
                         }
                         else
                         {
                             MessageBox.Show("Salary should the written with comma");
                         }
                     }
                     else
                     {
                         MessageBox.Show("Enter the working position");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Birthday should be in the following form - YYYY-MM-DD");
                 }
             }
             else
             {
                 MessageBox.Show("Enter the name");
             }
         }
     }
 }