コード例 #1
0
 private void button_Click(object sender, RoutedEventArgs e)
 {
     using (CRMContext dbContext = new CRMContext())
     {
         var task = new BD.CatalogTasks();
         task.Group = l_id_Copy.Text;
         task.Task  = l_id.Text;
         var results = new List <System.ComponentModel.DataAnnotations.ValidationResult>();
         var context = new ValidationContext(task);
         if (!Validator.TryValidateObject(task, context, results, true))
         {
             foreach (var error in results)
             {
                 MessageBox.Show(error.ErrorMessage);
             }
         }
         else
         {
             try
             {
                 dbContext.CatalogTasks.Add(task);
                 dbContext.SaveChanges();
             }
             catch
             {
                 MessageBox.Show("Ошибка");
             }
         }
         if (Validator.TryValidateObject(task, context, results, true))
         {
             this.Close();
         }
     }
 }
コード例 #2
0
 public Change_cTask(BD.CatalogTasks rt)
 {
     InitializeComponent();
     using (CRMContext dbContext = new CRMContext())
     {
         task           = dbContext.CatalogTasks.Find(rt.Task);
         l_id.Text      = task.Task.ToString();
         l_id_Copy.Text = task.Group.ToString();
     }
 }
コード例 #3
0
 public Delete(BD.CatalogTasks ct)
 {
     InitializeComponent();
     del_obj = ct;
 }