private void bindgridDmp() { try { DataTable dt = null; BLDMPLinking objBL = new BLDMPLinking(); dt = objBL.BindFullGrid(); if (dt.Rows.Count > 0) { dgvDMP.DataSource = dt; } else { dgvDMP.DataSource = null; } dgvDMP.Refresh(); dgvDMP.Show(); { dgvDMP.DataSource = dt; dgvDMP.Columns[0].HeaderCell.Value = "Doctor Name "; dgvDMP.Columns[1].HeaderCell.Value = "Medical Shop"; dgvDMP.Columns[2].HeaderCell.Value = "Product"; dgvDMP.Columns[3].HeaderCell.Value = "Price Type"; dgvDMP.Columns[3].Visible = false; dgvDMP.Columns[4].HeaderCell.Value = "Price"; dgvDMP.AllowUserToDeleteRows = false; dgvDMP.AllowUserToAddRows = false; dgvDMP.Refresh(); dgvDMP.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void dgvDMP_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvDMP.SelectedRows.Count > 0) { cbDoctor.Text = Convert.ToString(dgvDMP.SelectedRows[0].Cells[0].Value); cbMedicalShop.Text = Convert.ToString(dgvDMP.SelectedRows[0].Cells[1].Value); cbProduct.Text = Convert.ToString(dgvDMP.SelectedRows[0].Cells[2].Value); int Doctor = Convert.ToInt32(cbDoctor.SelectedValue); int medical = Convert.ToInt32(cbMedicalShop.SelectedValue); int product = Convert.ToInt32(cbProduct.SelectedValue); string Product = cbProduct.Text; BLDMPLinking objdmp = new BLDMPLinking(); DataTable dt = objdmp.getdmpId(Doctor, medical, product); if (dt.Rows.Count != 0) { lbldmpId.Text = dt.Rows[0]["DmpID"].ToString(); } string Type = Convert.ToString(dgvDMP.SelectedRows[0].Cells[3].Value); if (Type == "Price Per Unit") { rdoPriceperunit.Checked = true; } else rdoPercentage.Checked = true; txtPrice.Text = Convert.ToString(dgvDMP.SelectedRows[0].Cells[4].Value); UnEditable(); btnSave.Text = "Update"; } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }