예제 #1
0
        private void dataGridBrand_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            String colName = dataGridBrand.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                frmBrand frm = new frmBrand(this, false);
                frm.lblID.Text    = dataGridBrand[1, e.RowIndex].Value.ToString();
                frm.txtBrand.Text = dataGridBrand[2, e.RowIndex].Value.ToString();
                frm.ShowDialog();
            }
            if (colName == "Delete")
            {
                try
                {
                    if (MessageBox.Show("Are you sure to delete this brand?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        cn.Close();
                        cn.Open();
                        cm = new SqlCommand("DELETE FROM tblBrand WHERE id like'" + dataGridBrand[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);
                }
            }
        }
예제 #2
0
        private void btnAddBrand_Click(object sender, EventArgs e)
        {
            frmBrand frm = new frmBrand(this, true);

            frm.ShowDialog();
        }