private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string ColName = dataGridView1.Columns[e.ColumnIndex].Name; if (ColName == "Edit") { Form2Brand FormTwoBrand = new Form2Brand(this); FormTwoBrand.LabelOfID.Text = dataGridView1[1, e.RowIndex].Value.ToString(); FormTwoBrand.BrandTextBox.Text = dataGridView1[2, e.RowIndex].Value.ToString(); FormTwoBrand.SaveButton.Enabled = false; FormTwoBrand.UpdateButton.Enabled = true; FormTwoBrand.ShowDialog(); } else if (ColName == "Delete") { if (MessageBox.Show("Delete this record?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cn.Open(); cm = new SqlCommand("delete from BrandTable where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", cn); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Done!", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadRecords(); } } }
private void pictureBox2_Click(object sender, EventArgs e) { Form2Brand form2Brand = new Form2Brand(this); form2Brand.SaveButton.Enabled = true; form2Brand.UpdateButton.Enabled = false; form2Brand.ShowDialog(); }
private void pictureBox2_Click(object sender, EventArgs e) { Form2Brand form2Brand = new Form2Brand(); form2Brand.ShowDialog(); }