0
我在我的項目中使用Linq to Sql,並通過名爲Get_All_Incomes
的存儲過程填充datagridview。如何導出Datagridview細節到水晶報表
我設計了一個水晶報表,以在GridView查看數據,但有一個例外
集不支持System.Nullable <>
我填充GridView控件使用此代碼
dgvIncome.DataSource = CLS_Incomes.Get_All_Incomes().ToList();
我使用這種方法過濾gridview
string nameFilter = txtCust.Text;
string mediaFilter = comboMedia.SelectedIndex > 0 ? comboMedia.Text : "";
string currencyFilter = comboCurr.SelectedIndex > 0 ? comboCurr.Text :"";
string motalabahFilter = txtMot.Text;
string sanadFilter = txtSanad.Text;
string incomeFilter = txtIncome.Text;
DateTime? fromDate = radioFrom.Checked ? dateTimePicker1.Value.Date : (DateTime?)null;
DateTime? toDate = radioFrom.Checked ? dateTimePicker2.Value.Date : (DateTime?) null;
using (dbDataContext db = new dbDataContext())
{
var result = from p in db.Get_All_Incomes()
where
(nameFilter.Length > 0 && p.CustomersName.Contains(nameFilter) || nameFilter.Length == 0)
&& (mediaFilter.Length > 0 && p.Name == mediaFilter || mediaFilter.Length == 0)
&& (currencyFilter.Length > 0 && p.CurrencyName == currencyFilter || currencyFilter.Length == 0)
&& (motalabahFilter.Length > 0 && p.Motalabah == motalabahFilter || motalabahFilter.Length == 0)
&& (sanadFilter.Length > 0 && p.Sanad == sanadFilter || sanadFilter.Length == 0)
&& (incomeFilter.Length > 0 && p.Income.ToString() == incomeFilter || incomeFilter.Length == 0)
&&
((fromDate == null || toDate == null) ||
(fromDate != null && toDate != null && p.SanadDate >= fromDate && p.SanadDate <= toDate))
select p;
dgvIncome.DataSource = result.ToList();
最後呼籲使用此按鈕
btnReport.Cursor = Cursors.WaitCursor;
Reports.Rpt rpt = new Reports.Rpt();
rpt.SetDataSource(dgvIncome.DataSource);
FRM_Report frm = new FRM_Report();
btnReport.Cursor = Cursors.Default;
frm.ShowDialog();