Ejemplo n.º 1
0
        public DataTable QueryTotalAmountByVendor(POVendorInvoiceQueryFilter query, out int totalCount)
        {
            PagingInfoEntity pagingEntity = new PagingInfoEntity();

            pagingEntity.SortField     = query.PagingInfo.SortBy;
            pagingEntity.MaximumRows   = query.PagingInfo.PageSize;
            pagingEntity.StartRowIndex = query.PagingInfo.PageIndex * query.PagingInfo.PageSize;

            CustomDataCommand dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("GetTotalAmountByVendor");

            using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                       dataCommand.CommandText, dataCommand, pagingEntity, "VendorSysNo"))
            {
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.VendorSysNo",
                                                             DbType.Int32, "@VendorSysNo", QueryConditionOperatorType.Equal, query.VendorSysNo);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.CompanyCode",
                                                             DbType.AnsiStringFixedLength, "@CompanyCode", QueryConditionOperatorType.Equal, query.CompanyCode);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.InvoiceNumber",
                                                             DbType.AnsiString, "@InvoiceNumber", QueryConditionOperatorType.Like, query.InvoiceNo);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.InvoiceTime",
                                                             DbType.DateTime, "@InvoiceDateFrom", QueryConditionOperatorType.MoreThanOrEqual, query.InvoiceDateFrom);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.InvoiceTime",
                                                             DbType.DateTime, "@InvoiceDateTo", QueryConditionOperatorType.LessThan, query.InvoiceDateTo);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.InputTime",
                                                             DbType.DateTime, "@InvoiceCreateDateFrom", QueryConditionOperatorType.MoreThanOrEqual, query.InvoiceCreateDateFrom);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.InputTime",
                                                             DbType.DateTime, "@InvoiceCreateDateTo", QueryConditionOperatorType.LessThan, query.InvoiceCreateDateTo);

                if (query.Status.HasValue)
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.Status",
                                                                 DbType.Int32, "@Status", QueryConditionOperatorType.Equal, query.Status);
                }
                else
                {
                    if (query.IsFilterAbandon.Value)
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.Status",
                                                                     DbType.Int32, "@Status", QueryConditionOperatorType.MoreThan, -1);
                    }
                }

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "vi.StockSysNo",
                                                             DbType.Int32, "@StockSysNo", QueryConditionOperatorType.Equal, query.StockSysNo);

                dataCommand.CommandText = sqlBuilder.BuildQuerySql();

                DataTable dt = dataCommand.ExecuteDataTable();
                totalCount = Convert.ToInt32(dataCommand.GetParameterValue("@TotalCount"));
                return(dt);
            }
        }
        public QueryResult QueryTotalAmountByVendor(POVendorInvoiceQueryFilter request)
        {
            int totalCount;
            var dataTable = ObjectFactory <IPOVendorInvoiceQueryDA> .Instance.QueryTotalAmountByVendor(request, out totalCount);

            return(new QueryResult()
            {
                Data = dataTable,
                TotalCount = totalCount
            });
        }