Beispiel #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.btnSave.Enabled   = false;
                frm.btnUpdate.Enabled = true;

                frm.lblID.Text    = dataGridView1[1, e.RowIndex].Value.ToString();
                frm.txtBrand.Text = dataGridView1[2, e.RowIndex].Value.ToString();
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this brand?", eTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    connString.Open();
                    cm = new SqlCommand("delete from tblBrand where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", connString);
                    cm.ExecuteNonQuery();
                    MessageBox.Show("Brand deleted successfuly", eTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    connString.Close();
                    loadRecords();
                }
            }
        }
Beispiel #2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            frmBrand frm = new frmBrand(this);

            frm.btnSave.Enabled   = true;
            frm.btnUpdate.Enabled = false;
            frm.ShowDialog();
        }
Beispiel #3
0
        private void editButton1_Click(object sender, EventArgs e)
        {
            frmBrand frm = new frmBrand(this);

            frm.ShowDialog();
        }