internal virtual StringBuilder GetAutoPropertyFilterString()
        {
            var res = new StringBuilder();


            if (ReceivedQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedQty == {0}", ReceivedQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(ItemNumberFilter) == false)
            {
                res.Append(" && " + string.Format("ItemNumber.Contains(\"{0}\")", ItemNumberFilter));
            }


            if (string.IsNullOrEmpty(ItemDescriptionFilter) == false)
            {
                res.Append(" && " + string.Format("ItemDescription.Contains(\"{0}\")", ItemDescriptionFilter));
            }


            if (CostFilter.HasValue)
            {
                res.Append(" && " + string.Format("Cost == {0}", CostFilter.ToString()));
            }

            if (InvoiceQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceQty == {0}", InvoiceQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(StatusFilter) == false)
            {
                res.Append(" && " + string.Format("Status.Contains(\"{0}\")", StatusFilter));
            }


            if (ReceivedValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedValue == {0}", ReceivedValueFilter.ToString()));
            }

            if (InvoiceValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceValue == {0}", InvoiceValueFilter.ToString()));
            }
            return(res.ToString().StartsWith(" &&") || res.Length == 0 ? res:  res.Insert(0, " && "));
        }
        internal virtual StringBuilder GetAutoPropertyFilterString()
        {
            var res = new StringBuilder();


            if (ReceivedQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedQty == {0}", ReceivedQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(ItemNumberFilter) == false)
            {
                res.Append(" && " + string.Format("ItemNumber.Contains(\"{0}\")", ItemNumberFilter));
            }


            if (string.IsNullOrEmpty(ItemDescriptionFilter) == false)
            {
                res.Append(" && " + string.Format("ItemDescription.Contains(\"{0}\")", ItemDescriptionFilter));
            }


            if (CostFilter.HasValue)
            {
                res.Append(" && " + string.Format("Cost == {0}", CostFilter.ToString()));
            }

            if (InvoiceQtyFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceQty == {0}", InvoiceQtyFilter.ToString()));
            }

            if (string.IsNullOrEmpty(InvoiceNoFilter) == false)
            {
                res.Append(" && " + string.Format("InvoiceNo.Contains(\"{0}\")", InvoiceNoFilter));
            }



            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" && (");
            }

            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue)
            {
                if (StartInvoiceDateFilter.HasValue)
                {
                    res.Append(
                        (Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue?"":" && ") +
                        string.Format("InvoiceDate >= \"{0}\"", Convert.ToDateTime(StartInvoiceDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }

            if (Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                if (EndInvoiceDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("InvoiceDate <= \"{0}\"", Convert.ToDateTime(EndInvoiceDateFilter).Date.AddHours(23).ToString("MM/dd/yyyy HH:mm:ss")));
                }
            }

            if (Convert.ToDateTime(StartInvoiceDateFilter).Date != DateTime.MinValue &&
                Convert.ToDateTime(EndInvoiceDateFilter).Date != DateTime.MinValue)
            {
                res.Append(" )");
            }

            if (Convert.ToDateTime(_invoiceDateFilter).Date != DateTime.MinValue)
            {
                if (InvoiceDateFilter.HasValue)
                {
                    res.Append(" && " + string.Format("InvoiceDate == \"{0}\"", Convert.ToDateTime(InvoiceDateFilter).Date.ToString("MM/dd/yyyy")));
                }
            }


            if (string.IsNullOrEmpty(CNumberFilter) == false)
            {
                res.Append(" && " + string.Format("CNumber.Contains(\"{0}\")", CNumberFilter));
            }


            if (string.IsNullOrEmpty(RegistrationDateFilter) == false)
            {
                res.Append(" && " + string.Format("RegistrationDate.Contains(\"{0}\")", RegistrationDateFilter));
            }


            if (DurationFilter.HasValue)
            {
                res.Append(" && " + string.Format("Duration == {0}", DurationFilter.ToString()));
            }

            if (InvoiceMonthFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceMonth == {0}", InvoiceMonthFilter.ToString()));
            }

            if (AsycudaMonthFilter.HasValue)
            {
                res.Append(" && " + string.Format("AsycudaMonth == {0}", AsycudaMonthFilter.ToString()));
            }

            if (AllocatedValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("AllocatedValue == {0}", AllocatedValueFilter.ToString()));
            }

            if (ReceivedValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("ReceivedValue == {0}", ReceivedValueFilter.ToString()));
            }

            if (InvoiceValueFilter.HasValue)
            {
                res.Append(" && " + string.Format("InvoiceValue == {0}", InvoiceValueFilter.ToString()));
            }

            if (LineNumberFilter.HasValue)
            {
                res.Append(" && " + string.Format("LineNumber == {0}", LineNumberFilter.ToString()));
            }

            if (PiQuantityFilter.HasValue)
            {
                res.Append(" && " + string.Format("PiQuantity == {0}", PiQuantityFilter.ToString()));
            }

            if (string.IsNullOrEmpty(OverShortDetailStatusFilter) == false)
            {
                res.Append(" && " + string.Format("OverShortDetailStatus.Contains(\"{0}\")", OverShortDetailStatusFilter));
            }


            if (QtyAllocatedFilter.HasValue)
            {
                res.Append(" && " + string.Format("QtyAllocated == {0}", QtyAllocatedFilter.ToString()));
            }

            if (string.IsNullOrEmpty(AllocationStatusFilter) == false)
            {
                res.Append(" && " + string.Format("AllocationStatus.Contains(\"{0}\")", AllocationStatusFilter));
            }
            return(res.ToString().StartsWith(" &&") || res.Length == 0 ? res:  res.Insert(0, " && "));
        }