Пример #1
0
 private async void button1_Click(object sender, EventArgs e)
 {
     using (var db = new AstronomyLogsEntities())
     {
         foreach (AstronomyEntry entry in AstronomyParser.fillSQLEntry(dt))
         {
             db.AstronomyEntries.Add(entry);
         }
         db.SaveChanges();
     }
 }
Пример #2
0
 private void saveBtn_Click(object sender, EventArgs e)
 {
     foreach (DataGridViewRow row in dbGrid.Rows)
     {
         using (var db = new AstronomyLogsEntities())
         {
             int            id    = int.Parse(row.Cells[0].Value.ToString());
             AstronomyEntry entry = db.AstronomyEntries.Where(en => en.IDEntry == id).FirstOrDefault();
             string         name  = row.Cells["Name"].Value.ToString();
             if (!string.IsNullOrEmpty(name))
             {
                 entry.Name            = row.Cells["Name"].Value.ToString();
                 db.Entry(entry).State = EntityState.Modified;
             }
             db.SaveChanges();
         }
     }
 }