private void btnprint_Click(object sender, EventArgs e) { GetHostPrintData pd = getDataSourceBindingSource.Current as GetHostPrintData; //GetHostPrintData pd = getDataSourceBindingSource.Current as GetHostPrintData; if (pd != null) { try { using (SqlConnection conn = new SqlConnection(strcon)) { conn.Open(); var qry = "select student_details.first_name, student_details.last_name, student_details.other_name, student_details.time_in, student_details.time_out, room_details.category, room_details.room_id, room_details.room_no, room_details.price from student_details INNER JOIN room_details ON student_details.room_id = room_details.room_id"; //getPrintDataBindingSource.DataSource = con.Query<GetPrintData>(qry, commandType: CommandType.Text); List <GetHostDetails> list_host = conn.Query <GetHostDetails>(qry, commandType: CommandType.Text).ToList(); PrintForm pf = new PrintForm(pd, list_host); pf.ShowDialog(); conn.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public PrintForm(GetHostPrintData gpd, List <GetHostDetails> ghd) { InitializeComponent(); pd = gpd; hd = ghd; }