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

            if (ColName == "Edit")
            {
                BrandForm form = new BrandForm(this);
                form.IdLabel.Text     = dataGridView1[1, e.RowIndex].Value.ToString();
                form.BrandNameTb.Text = dataGridView1[2, e.RowIndex].Value.ToString();
                form.ShowDialog();
            }
            else if (ColName == "Delete")
            {
                if (MessageBox.Show("Are you sure you want to delete this record?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ;
                }
                {
                    connect.Open();
                    command = new MySqlCommand("DELETE FROM brandtbl where id like '" + dataGridView1[1, e.RowIndex].Value.ToString() + "'", connect);
                    command.ExecuteNonQuery();
                    connect.Close();
                    MessageBox.Show("Brand has been successfully deleted!", "POS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadRecords();
                }
            }
        }
示例#2
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            BrandForm brandF = new BrandForm(this);

            brandF.ShowDialog();
        }