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

            if (colname == "Edit")
            {
                FormVendor frm = new FormVendor(this);
                frm.btnSave.Enabled      = false;
                frm.btnUpdate.Enabled    = true;
                frm.lblID.Text           = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.textBoxVendor.Text   = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.textBoxVAdress.Text  = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
                frm.textBoxVContact.Text = dataGridView1.Rows[e.RowIndex].Cells[4].Value.ToString();
                frm.textBoxVEmail.Text   = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString();
                frm.textBoxVFax.Text     = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString();
                frm.ShowDialog();
            }
            else if (colname == "Delete")
            {
                if (MessageBox.Show("You want to remove this Vendor?", "Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("delete from tableVendor where id like '" + dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("Vendor removed sucessfully.", "Removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadRecords();
                }
            }
        }
示例#2
0
        private void btnCreateNew_Click(object sender, EventArgs e)
        {
            FormVendor frm = new FormVendor(this);

            frm.Show();
        }