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

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

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

                    cm.ExecuteNonQuery();
                    sqlcon.Close();
                    MessageBox.Show("Category Deleted Successfully", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadCategory();
                }
            }
        }
Ejemplo n.º 2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            formCategory frm = new formCategory(this);

            frm.btnUpdate.Enabled = false;
            frm.btnSave.Enabled   = true;
            frm.ShowDialog();
        }