Пример #1
0
 private void buttonAddToList_Click(object sender, EventArgs e)
 {
     if ((tabControl1.SelectedTab == tabPage1) && (tabControl2.SelectedTab == tabPage3))
     {
         using (var ctx = new TaskDbContext())
         {
             var imageMail = new ImageCheck(textBoxNamePortal.Text, textBoxKeyWord.Text);
             imageMail.emailAdress = textBoxEmail.Text;
             Program.Tasks.Add(imageMail);
             ctx.Task.Add(imageMail);
             ctx.SaveChanges();
         }
     }
     else if ((tabControl1.SelectedTab == tabPage2) && (tabControl2.SelectedTab == tabPage4))
     {
         using (var ctx = new TaskDbContext())
         {
             Json json          = new Json(textBoxNameCity.Text);
             var  weatherWindow = new WeatherCheck(textBoxNameCity.Text, numericUpDown1.Value);
             Program.Tasks.Add(weatherWindow);
             ctx.Task.Add(weatherWindow);
             ctx.SaveChanges();
         }
     }
     else if ((tabControl1.SelectedTab == tabPage1) && (tabControl2.SelectedTab == tabPage4))
     {
         using (var ctx = new TaskDbContext())
         {
             var imageWindow = new ImageCheck(textBoxNamePortal.Text, textBoxKeyWord.Text);
             Program.Tasks.Add(imageWindow);
             ctx.Task.Add(imageWindow);
             ctx.SaveChanges();
         }
     }
     else if ((tabControl1.SelectedTab == tabPage2) && (tabControl2.SelectedTab == tabPage3))
     {
         using (var ctx = new TaskDbContext())
         {
             var weatherCheck = new WeatherCheck(textBoxNameCity.Text, numericUpDown1.Value);
             weatherCheck.emailAdress = textBoxEmail.Text;
             Program.Tasks.Add(weatherCheck);
             ctx.Task.Add(weatherCheck);
             ctx.SaveChanges();
         }
     }
 }
Пример #2
0
 public void LoadData()
 {
     foreach (var task in Task)
     {
         foreach (var image in ImageCheck)
         {
             if (task.Id == image.Id)
             {
                 var imageMail = new ImageCheck(image.Site, image.Keyword);
                 imageMail.emailAdress = image.emailAdress;
                 Program.Tasks.Add(imageMail);
             }
         }
         foreach (var weather in WeatherCheck)
         {
             if (task.Id == weather.Id)
             {
                 var weatherCheck = new WeatherCheck(weather.City, weather.Temperature);
                 weatherCheck.emailAdress = weather.emailAdress;
                 Program.Tasks.Add(weatherCheck);
             }
         }
     }
 }