private void button11_Click(object sender, EventArgs e) { if (dataGridView3.SelectedRows.Count > 0) { int index = dataGridView3.SelectedRows[0].Index; int id = (int)dataGridView3[0, index].Value; Registrations row = db.Registrations.Find(id); fRegistration f = new fRegistration(); f.comboBox2.SelectedValue = row.Id_Client; f.comboBox1.SelectedValue = row.Id_Number; f.dateTimePicker1.Text = row.DateInsert.ToString(); f.dateTimePicker2.Text = row.DateOut.ToString(); f.textBox1.Text = row.Cost.ToString(); if (f.ShowDialog() == DialogResult.OK) { row.Id_Client = (int)f.comboBox2.SelectedValue; row.Id_Number = (int)f.comboBox1.SelectedValue; row.DateInsert = Convert.ToDateTime(f.dateTimePicker1.Text); row.DateOut = Convert.ToDateTime(f.dateTimePicker2.Text); row.Cost = Convert.ToInt16(f.textBox1.Text); db.Entry(row).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); LoadDate(); } } }
private void button10_Click(object sender, EventArgs e) { fRegistration f = new fRegistration(); Registrations row = new Registrations(); if (f.ShowDialog() == DialogResult.OK) { row.Id_Client = (int)f.comboBox2.SelectedValue; row.Id_Number = (int)f.comboBox1.SelectedValue; row.DateInsert = Convert.ToDateTime(f.dateTimePicker1.Text); row.DateOut = Convert.ToDateTime(f.dateTimePicker2.Text); row.Cost = Convert.ToInt16(f.textBox1.Text); db.Registrations.Add(row); db.SaveChanges(); LoadDate(); } }