Exemple #1
0
        private void dataGridVendor_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            String colName = dataGridVendor.Columns[e.ColumnIndex].Name;

            if (colName == "Edit")
            {
                frmVendor frm = new frmVendor(this);
                frm.btnSave.Enabled   = false;
                frm.btnUpdate.Enabled = true;
                frm._id                   = frm.txtVendor.Text = dataGridVendor.Rows[e.RowIndex].Cells[1].Value.ToString();
                frm.txtVendor.Text        = dataGridVendor.Rows[e.RowIndex].Cells[2].Value.ToString();
                frm.txtAddress.Text       = dataGridVendor.Rows[e.RowIndex].Cells[3].Value.ToString();
                frm.txtContactPerson.Text = dataGridVendor.Rows[e.RowIndex].Cells[4].Value.ToString();
                frm.txtTelephone.Text     = dataGridVendor.Rows[e.RowIndex].Cells[5].Value.ToString();
                frm.txtEmail.Text         = dataGridVendor.Rows[e.RowIndex].Cells[6].Value.ToString();
                frm.txtFax.Text           = dataGridVendor.Rows[e.RowIndex].Cells[7].Value.ToString();
                frm.ShowDialog();
            }
            else if (colName == "Delete")
            {
                if (MessageBox.Show("Are you sure to delete this Vendor?", "Delete Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    cn.Open();
                    cm = new SqlCommand("delete from tblVendor where id like '" + dataGridVendor.Rows[e.RowIndex].Cells[1].Value.ToString() + "'", cn);
                    cm.ExecuteNonQuery();
                    cn.Close();
                    MessageBox.Show("RECORD SUCCESFLLY DELETED", "DELETED RECORD", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadVandors();
                }
            }
        }
Exemple #2
0
        private void btnAddVandor_Click(object sender, EventArgs e)
        {
            frmVendor f = new frmVendor(this);

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