Example #1
0
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                branddata frm = new branddata(this);
                frm.lblID.Text    = dataGridView1[1, e.RowIndex].Value.ToString();
                frm.txtbrand.Text = dataGridView1[2, e.RowIndex].Value.ToString();
                //frm.btnSave.Enabled = false;
                //frm.btnUpdate.Enabled = true;

                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this record?", "Delete Records", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    conn.Open();
                    comm = new SqlCommand("delete from tblbrand where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", conn);
                    comm.ExecuteNonQuery();
                    conn.Close();
                    MessageBox.Show("Record has been deleted!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadrecords();
                }
            }
        }
Example #2
0
        private void PictureBox2_Click_1(object sender, EventArgs e)
        {
            branddata frm = new branddata(this);

            frm.ShowDialog();
        }