private void Usp_BindDoctorGrid() { try { DataTable dt = new DataTable(); BLDoctor objBL = new BLDoctor(); dt = objBL.BindFullGrid(); if (dt.Rows.Count > 0) { dgvDoctor.DataSource = dt; } else { dgvDoctor.DataSource = null; } dgvDoctor.Refresh(); dgvDoctor.Show(); { dgvDoctor.DataSource = dt; dgvDoctor.Columns[0].HeaderCell.Value = "Dr. Name"; dgvDoctor.Columns[1].HeaderCell.Value = "DOB"; dgvDoctor.Columns[2].HeaderCell.Value = "Country"; dgvDoctor.Columns[3].HeaderCell.Value = "State"; dgvDoctor.Columns[4].HeaderCell.Value = "City"; dgvDoctor.Columns[5].HeaderCell.Value = "Area"; dgvDoctor.Columns[6].HeaderCell.Value = "Address"; dgvDoctor.Columns[7].HeaderCell.Value = "Specialization"; dgvDoctor.Columns[8].HeaderCell.Value = "Mobile Number"; dgvDoctor.Columns[9].HeaderCell.Value = "IsActive"; dgvDoctor.Columns[9].Visible = false; dgvDoctor.Columns[10].HeaderCell.Value = "IsDelete"; dgvDoctor.Columns[10].Visible = false; dgvDoctor.Columns[11].HeaderCell.Value = "DoctorID"; dgvDoctor.Columns[11].Visible = false; dgvDoctor.AllowUserToAddRows = false; dgvDoctor.AllowUserToDeleteRows = false; //dgvDoctor.Columns[12].HeaderCell.Value = "OpeningBalance"; dgvDoctor.Refresh(); dgvDoctor.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void dgvDoctor_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvDoctor.SelectedRows.Count > 0) { txtDrName.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells[0].Value); string DrName = txtDrName.Text; BLDoctor objDoctor = new BLDoctor(); DataTable dt = objDoctor.GetID(DrName); if (dt.Rows.Count != 0) { lblid.Text = dt.Rows[0]["DoctorID"].ToString(); } lblhidden.Text = dgvDoctor.SelectedRows[0].Cells["DoctorID"].Value.ToString(); txtDrName.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["DrName"].Value); dtpDOB.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["DOB"].Value); cbcountry.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["CountryName"].Value); cbstate.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["StateName"].Value); cbcity.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["CityName"].Value); txtArea.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["Area"].Value); txtAddress.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["Address"].Value); txtspecialization.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["Specialization"].Value); //lbProductList.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["ProductList"].Value); //txtAddress.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells[8].Value); dgvDoctor.Columns["DoctorID"].Visible = false; txtmobileno.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["MobileNo"].Value); //txtgifts.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells[9].Value); txtmobileno.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["MobileNo"].Value); txtOpeningBal.Text = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["OpeningBalance"].Value); txtOpeningBal.ReadOnly = true; string status = Convert.ToString(dgvDoctor.SelectedRows[0].Cells["IsActive"].Value); if (status == "Yes") { cbActive.Checked = true; } btnsave.Text = "Update"; //lbProductList.Enabled = true; BindProductList(); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }