سلام وقت بخیر همه چیز درست کار میکنه بجز فیلتر تاریخ.
void Filter()
{
using (UnitOfWork db = new UnitOfWork())
{
List<DataLayer.Accounting> result = new List<DataLayer.Accounting>();
DateTime? startDate;
DateTime? endDate;
if (txtDateFrom.Text != " - -")
{
startDate = Convert.ToDateTime(txtDateFrom.Text);
startDate = DateConvertorToShamsi.ToMiladi(startDate.Value);
result = result.Where(r => r.DateTime>=startDate.Value).ToList();
}
if (txtDateTo.Text != " - -")
{
endDate = Convert.ToDateTime(txtDateTo.Text);
endDate = DateConvertorToShamsi.ToMiladi(endDate.Value);
result = result.Where(r => r.DateTime <= endDate.Value).ToList();
}
if ((int)cbCustomer.SelectedValue != 0)
{
int customerId = int.Parse(cbCustomer.SelectedValue.ToString());
result.AddRange(db.customerGenericRepository.Get(c => c.TypeID == typeId && c.CustomerID == customerId));
}
else
{
result.AddRange(db.customerGenericRepository.Get(c => c.TypeID == typeId));
}
dgvReport.Rows.Clear();
foreach (var accounting in result)
{
string customerName = db.CustomersRepository.GetCustomerNameById(accounting.CustomerID);
dgvReport.Rows.Add(accounting.ID, customerName, accounting.Amount, accounting.DateTime.ToShamsi(), accounting.Description);
}
}
}