コード例 #1
0
 private void btnOk_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (fromSelectedID == -1)
         {
             using (DataClasses1DataContext cnt = new DataClasses1DataContext())
             {
                 if (fromComboBox == "Book")
                 {
                     Book book = new Book()
                     {
                         Title = textBox2.Text
                     };
                     cnt.Book.InsertOnSubmit(book);
                     cnt.SubmitChanges();
                 }
                 if (fromComboBox == "Sage")
                 {
                     Sage sage = new Sage()
                     {
                         Name = textBox2.Text, Age = DateTime.Parse(textBox3.Text)
                     };
                     cnt.Sage.InsertOnSubmit(sage);
                     cnt.SubmitChanges();
                 }
                 if (fromComboBox == "SageBook")
                 {
                     Book book = new Book()
                     {
                         Title = textBox2.Text
                     };
                     cnt.Book.InsertOnSubmit(book);
                     cnt.SubmitChanges();
                 }
             }
         }
         else
         {
             using (DataClasses1DataContext cnt = new DataClasses1DataContext())
             {
                 if (fromComboBox == "Book")
                 {
                     var book = cnt.Book.Where(x => x.Id == fromSelectedID).FirstOrDefault();
                     book.Title = textBox2.Text;
                     cnt.SubmitChanges();
                 }
             }
         }
         this.Close();
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
 partial void UpdateSage(Sage instance);
コード例 #3
0
 partial void DeleteSage(Sage instance);
コード例 #4
0
 partial void InsertSage(Sage instance);