コード例 #1
0
        void Filter()
        {
            using (UnitOfWork db = new UnitOfWork())
            {
                List <DateLayer.Acconting> resualt = new List <DateLayer.Acconting>();
                DateTime?startTime;
                DateTime?EndTime;

                if (txtfromDate.Text != "    /  /")
                {
                    startTime = Convert.ToDateTime(txtfromDate.Text);
                    startTime = DateConvertor.Tomiladi(startTime.Value);
                    resualt   = resualt.Where(r => r.DateTime >= startTime.Value).ToList();
                }
                if (txttoDate.Text != "    /  /")
                {
                    EndTime = Convert.ToDateTime(txttoDate.Text);
                    EndTime = DateConvertor.Tomiladi(EndTime.Value);
                    resualt = resualt.Where(r => r.DateTime <= EndTime.Value).ToList();
                }



                if ((int)cbCustomer.SelectedValue != 0)
                {
                    int CustomerId = int.Parse(cbCustomer.SelectedValue.ToString());
                    resualt.AddRange(db.AccontingRepository.Get(a => a.TypeID == TypeID && a.CustomerID == CustomerId));
                }
                else
                {
                    resualt.AddRange(db.AccontingRepository.Get());
                }



                //var resualt = db.AccontingRepository.Get(a => a.TypeID == TypeID);
                // dgvReport.AutoGenerateColumns = false;
                //dgvReport.DataSource = resualt;
                dgvReport.Rows.Clear();
                foreach (var acconting in resualt)
                {
                    string CustomerName = db.customerRepository.GetCustomerNameByID(acconting.CustomerID);
                    dgvReport.Rows.Add(acconting.ID, CustomerName, acconting.Amount, acconting.DateTime.Toshamsi(), acconting.Description);
                }
            }
        }