Пример #1
0
 void PopulateDataGridView()
 {
     using (Dbmodel db = new Dbmodel())
     {
         dataGridView1.DataSource = db.customers.ToList <customer>();
     }
 }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtfname.Text == "" && txtfrom.Text == "" && txtlname.Text == "" && txtto.Text == "" && txtnt.Text == "")
     {
         MessageBox.Show("values cannot be blank");
     }
     else
     {
         model.FirstName = txtfname.Text.Trim();
         model.LastName  = txtlname.Text.Trim();
         model.TicketsNo = txtnt.Text.Trim();
         model.From      = txtfrom.Text.Trim();
         model.To        = txtto.Text.Trim();
         using (Dbmodel db = new Dbmodel())
         {
             db.customers.Add(model);
             db.SaveChanges();
         }
         Clear();
         MessageBox.Show("BOOKING DONE");
         PopulateDataGridView();
     }
 }