示例#1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colname = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colname == "Edit")
            {
                formAdd frm = new formAdd(this);

                frm.lblId.Text  = dataGridView1[1, e.RowIndex].Value.ToString();
                frm.txtAdd.Text = dataGridView1[2, e.RowIndex].Value.ToString();
                frm.ShowDialog();
            }
            else if (colname == "Delete")
            {
                if (MessageBox.Show("Are you sure want too delete this item?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    sqlcon.Open();
                    cm = new SqlCommand("delete  from tblbrand where id  like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", sqlcon);

                    cm.ExecuteNonQuery();
                    sqlcon.Close();
                    MessageBox.Show("Item Deleted Successfully", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadRecord();
                }
            }
        }
示例#2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            formAdd frm = new formAdd(this);

            frm.btnUpdate.Enabled = false;

            frm.ShowDialog();
        }