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

            if (ColName == "Edit")
            {
                CategoryAdd cade = new CategoryAdd(this);
                cade.LabelOfID.Text       = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                cade.CategoryTextBox.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                cade.SaveButton.Enabled   = false;
                cade.UpdateButton.Enabled = true;
                cade.ShowDialog();
            }
            else if (ColName == "Delete")
            {
                if (MessageBox.Show("Delete this record?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("delete from CategoryTable where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Done!", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadCategory();
                }
            }
        }
Exemplo n.º 2
0
        private void AddItemButton_Click(object sender, EventArgs e)
        {
            CategoryAdd cadd = new CategoryAdd(this);

            cadd.SaveButton.Enabled   = true;
            cadd.UpdateButton.Enabled = false;
            cadd.ShowDialog();
        }