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

            if (colName == "Edit")
            {
                frmCategory frm = new frmCategory(this);
                frm.btnSave.Enabled   = false;
                frm.btnUpdate.Enabled = true;
                frm.lblID.Text        = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.txtCategory.Text  = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this category?", eTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    connString.Open();
                    cm = new SqlCommand("delete from tblCategory where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", connString);
                    cm.ExecuteNonQuery();
                    MessageBox.Show("Category deleted successfully", eTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    connString.Close();
                    loadCategory();
                }
            }
        }
Esempio n. 2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmCategory frm = new frmCategory(this);

            frm.btnSave.Enabled   = true;
            frm.btnUpdate.Enabled = false;
            frm.ShowDialog();
        }
Esempio n. 3
0
        private void editButton1_Click(object sender, EventArgs e)
        {
            frmCategory frm = new frmCategory(this);

            frm.ShowDialog();
        }