Exemplo n.º 1
0
        private void dataGridCategory_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            String colName = dataGridCategory.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                frmCategory frmCategory = new frmCategory(this);
                frmCategory.lblID.Text        = dataGridCategory.Rows[e.RowIndex].Cells[1].Value.ToString();
                frmCategory.txtCategory.Text  = dataGridCategory.Rows[e.RowIndex].Cells[2].Value.ToString();
                frmCategory.btnSave.Enabled   = false;
                frmCategory.btnUpdate.Enabled = true;

                frmCategory.ShowDialog();
            }
            if (colName == "Delete")
            {
                try
                {
                    if (MessageBox.Show("Are you sure to delete this Category?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        cn.Close();
                        cn.Open();
                        cm = new SqlCommand("DELETE FROM tblCategory WHERE id like'" + dataGridCategory[1, e.RowIndex].Value.ToString() + "'", cn);
                        cm.ExecuteNonQuery();
                        cn.Close();
                        MessageBox.Show("Record has been successfully Deleted.", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loadRecords();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void btnAddCategory_Click(object sender, EventArgs e)
        {
            frmCategory frmCategory = new frmCategory(this);

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

            frm.ShowDialog();
        }