Example #1
0
        private void CategoryDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string ColName = CategoryDataGridView.Columns[e.ColumnIndex].Name;

            if (ColName == "Edit")
            {
                CategoryForm form = new CategoryForm(this);
                form.CatIdLabel.Text     = CategoryDataGridView[1, e.RowIndex].Value.ToString();
                form.CategoryNameTb.Text = CategoryDataGridView[2, e.RowIndex].Value.ToString();
                form.ShowDialog();
            }
            else // (ColName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this record?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ;
                }
                {
                    connect.Open();
                    command = new MySqlCommand("DELETE FROM categorytbl where id like '" + CategoryDataGridView[1, e.RowIndex].Value.ToString() + "'", connect);
                    command.ExecuteNonQuery();
                    connect.Close();
                    LoadRecords();
                }
            }
        }
Example #2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            CategoryForm cf = new CategoryForm(this);

            //cf.SaveBtn.Enabled = true;
            cf.ShowDialog();
        }