Click here to Skip to main content
15,900,725 members

Comments by Member 10532715 (Top 26 by date)

Member 10532715 7-Oct-16 6:54am View    
It has been solved, actually my constructor pass data after form load i have putted it to after.. then its working fine.. Thanks Mr.Tadit.. for looking my problem...

wrong code..
FrmDoctorOPD doctoropd = new FrmDoctorOPD();
doctoropd.Show();
doctoropd.label5.Text = label12.Text; /// here is wrong afterload

Correct code..

FrmDoctorOPD doctoropd = new FrmDoctorOPD();
doctoropd.label5.Text = label12.Text; before load
doctoropd.Show();
Member 10532715 7-Oct-16 4:42am View    
private void metroTile3_Click(object sender, EventArgs e)
{
search();

}
Member 10532715 7-Oct-16 4:41am View    
yes it is coming from data base.. when i use search button .. its working fine but not in page load.. pls see search button code it is working like charm..

private void search()
{

try
{
cnn.Open();
string sqlcommand = " select OPD_NO as [OPD No],Patientname as [Pateint Name],Age,VisitDate as [visit Date],Department,Consultent_Doctor from OPD_table where Status_pet='Checked In' and Consultent_Doctor='" + label5.Text + "' and visitdate between '" + DateTime.ParseExact(this.dateTimePicker1.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture) + "' and '" + DateTime.ParseExact(this.dateTimePicker2.Text, "MM/dd/yyyy", CultureInfo.InvariantCulture) + "'";


SqlDataAdapter adap = new SqlDataAdapter(sqlcommand, cnn);


DataTable dt = new DataTable();

adap.Fill(dt);

if (dt.Rows.Count > 0)
{

this.dataGridView1.DataSource = dt;

cnn.Close();
}

else
{
MessageBox.Show("No Records found");
dataGridView1.DataSource = null;
cnn.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());

}



}
Member 10532715 7-Oct-16 4:37am View    
yes it is windows desktop application pls see my full code

previous page code where i have putted

private void adminMenuToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmDoctorOPD doctoropd = new FrmDoctorOPD();
doctoropd.Show();
doctoropd.label5.Text = label12.Text;



}

now in page to i have putted it as..

private void FrmDoctorOPD_Load(object sender, EventArgs e)
{

label7.Text = System.DateTime.Now.ToShortDateString();
fillgidview();


}

private void fillgidview()
{
try
{
cnn.Open();
string sqlcommand = " select OPD_NO as [OPD No],Patientname as [Pateint Name],Age,VisitDate as [visit Date],Department,Consultent_Doctor from OPD_table where Status_pet='Checked In' and Consultent_Doctor='" + label5.Text + "'";


SqlDataAdapter adap = new SqlDataAdapter(sqlcommand, cnn);


DataTable dt = new DataTable();

adap.Fill(dt);

this.dataGridView1.DataSource = dt;


cnn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());

}




}
Member 10532715 26-Nov-14 6:34am View    
Pls help my mind is just stuck