private void Fill() { Product product = new Product(); product.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); product.Quantity = int.Parse(dataGridView1.SelectedRows[0].Cells[2].Value.ToString()); product.Price = float.Parse(dataGridView1.SelectedRows[0].Cells[3].Value.ToString()); FormProductData frm = new FormProductData(); frm.FillForm(product.Name, product.Price, product.Quantity); frm.Show(); }
private void Edit() { Product product = new Product(); product.Name = dataGridView1.SelectedRows[0].Cells[1].Value.ToString(); product.Quantity = int.Parse(dataGridView1.SelectedRows[0].Cells[2].Value.ToString()); product.Price = float.Parse(dataGridView1.SelectedRows[0].Cells[3].Value.ToString()); FormProductData frm = new FormProductData() { Edit = true }; frm.FillForm(product.Name, product.Price, product.Quantity); if (frm.ShowDialog() != DialogResult.None) { var id = Int32.Parse(dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); Db db = new Db(); SqlCommand deleteCommand = new SqlCommand("delete from product where id = @id"); deleteCommand.Parameters.AddWithValue("@id", id); db.executeQuery(deleteCommand); } }
private void btnNew_Click(object sender, EventArgs e) { FormProductData frm = new FormProductData(); frm.Show(); }