Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            fNumber f = new fNumber();

            if (f.ShowDialog() == DialogResult.OK)
            {
                Numbers row = new Numbers();
                row.Type_number = f.textBox1.Text;
                row.Cost        = Convert.ToInt16(f.textBox2.Text);
                db.Numbers.Add(row);
                db.SaveChanges();
                LoadDate();
            }
        }
Exemplo n.º 2
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (dataGridView2.SelectedRows.Count > 0)
     {
         int     index = dataGridView2.SelectedRows[0].Index;
         int     id    = (int)dataGridView2[0, index].Value;
         Numbers row   = db.Numbers.Find(id);
         fNumber f     = new fNumber();
         f.textBox1.Text = row.Type_number;
         f.textBox2.Text = row.Cost.ToString();
         if (f.ShowDialog() == DialogResult.OK)
         {
             row.Type_number     = f.textBox1.Text;
             row.Cost            = Convert.ToInt16(f.textBox2.Text);
             db.Entry(row).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             LoadDate();
         }
     }
 }