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

            if (colName == "Edit")
            {
                frmBrand frm = new frmBrand(this);
                frm.lblID.Text        = dataGridView1[1, e.RowIndex].Value.ToString();
                frm.txtBrand.Text     = dataGridView1[2, e.RowIndex].Value.ToString();
                frm.btnSave.Enabled   = false;
                frm.btnUpdate.Enabled = true;
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this record?", "Delete Record",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SQLiteCommand("delete form tblbrand where id like '" +
                                           dataGridView1[1, e.RowIndex].Value.ToString() + "'", cn);
                    cn.Close();
                    MessageBox.Show("Brand has been successfully deleted.", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadRecords();
                }
            }
        }
Ejemplo n.º 2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmBrand frm = new frmBrand(this);

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