public static DataTable SetCustomerDetails(List <Customer> listCustomer) { DataSet1.CustomerDataTable dt = new DataSet1.CustomerDataTable(); try { foreach (var cust in listCustomer) { DataRow newRow = dt.NewRow(); foreach (PropertyInfo property in cust.GetType().GetProperties()) { if (property.Name != "ShipInfo") { newRow[property.Name] = cust.GetType().GetProperty(property.Name).GetValue(cust, null); } } dt.Rows.Add(newRow); } return(dt); } catch (Exception ex) { Console.WriteLine(ex.ToString()); return(null); } }
private void btnPrint_Click(object sender, EventArgs e) { DataSet1.CustomerDataTable dt = new DataSet1.CustomerDataTable(); dt = (DataSet1.CustomerDataTable)SetCustomerDetails(customer); ReportForm rf = new ReportForm(dt); rf.Show(); }