Exemplo n.º 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();
     }
 }
Exemplo n.º 2
0
        public constellationForm()
        {
            InitializeComponent();
            using (var db = new AstronomyLogsEntities())
            {
                top10Entries = db.AstronomyEntries.Take(10).ToList();
            }

            PointF sunPoint = new PointF(this.ClientSize.Width / 5F, this.ClientSize.Height / 2F);

            sun = new RectangleF(sunPoint, new SizeF(10 * 2F, 10 * 2F));
        }
Exemplo n.º 3
0
        public EditForm()
        {
            InitializeComponent();
            using (var db = new AstronomyLogsEntities())
            {
                dbGrid.DataSource = db.AstronomyEntries.Where(e => !String.IsNullOrEmpty(e.Proper)).ToList();

                dbGrid.Columns["Name"].DisplayIndex = 1;

                for (int i = 0; i < dbGrid.Columns.Count; i++)
                {
                    dbGrid.Columns[i].ReadOnly = dbGrid.Columns[i].Name != "Name";
                }
            }
        }
Exemplo n.º 4
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();
         }
     }
 }