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

            if (ColName == "Edit")
            {
                frmVendor f = new frmVendor(this);
                f.lblID.Text        = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                f.txtVendor.Text    = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                f.txtAddress.Text   = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                f.txtContact.Text   = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                f.txtTel.Text       = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                f.txtEmail.Text     = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                f.txtFax.Text       = dataGridView1.Rows[e.RowIndex].Cells[7].Value.ToString();
                f.btnSave.Enabled   = false;
                f.btnUpdate.Enabled = true;
                f.ShowDialog();
            }
            else if (ColName == "Delete")
            {
                if (MessageBox.Show("DELETE THIS RECORDS? CLICK YES TO CONFIRM", "CONFIRM", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    con.Open();
                    cmd = new MySqlCommand("delete from tblvendor where id like '" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("RECORDS DELETED SUCCESSFULLY", "DELETED", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadRecords();
                }
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            frmVendor frm = new frmVendor(this);

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