Пример #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string colName = dataGridView1.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                BrandList frm = new BrandList(this);
                frm.lblID.Text        = dataGridView1[1, e.RowIndex].Value.ToString();
                frm.textBox1.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 BRAND?", "DELETE BRAND", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    con.Open();
                    cmd = new MySqlCommand("delete from tblbrand where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", con);
                    cmd.ExecuteNonQuery();

                    con.Close();
                    MessageBox.Show("BRAND DELETED SUCCESSFULLY", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadRcords();
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            BrandList frmbrand = new BrandList(this);

            frmbrand.btnUpdate.Enabled = false;
            frmbrand.btnSave.Enabled   = true;
            frmbrand.ShowDialog();
        }