public QueryResult ExportProductShiftDetail(ProductShiftDetailReportQueryFilter filter)
        {
            int totalCount = 0;
            ProductShiftDetail        needManualItem = null;
            ProductShiftDetailAmtInfo outAmt = null, inAmt = null;
            var list = ObjectFactory <IProductShiftDetailQueryDA> .Instance.Query(filter, out totalCount, ref outAmt, ref inAmt, ref needManualItem);

            DataTable dt = new DataTable();

            var propertys = typeof(ProductShiftDetail).GetProperties();

            foreach (var property in propertys)
            {
                dt.Columns.Add(property.Name);
            }

            foreach (var data in list)
            {
                var newRow = dt.NewRow();
                foreach (var property in propertys)
                {
                    newRow[property.Name] = property.GetValue(data, null);
                }
                dt.Rows.Add(newRow);
            }

            return(new QueryResult()
            {
                TotalCount = totalCount,
                Data = dt
            });
        }
        private List <ShiftSysnoProduct> GetStockAToStockB(ProductShiftDetailReportQueryFilter query, string prodtuctSysnos)
        {
            List <ShiftSysnoProduct> result      = null;
            CustomDataCommand        dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryProductShiftDetailCompanyProductInfoStackAToStackB");

            using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                       dataCommand.CommandText, dataCommand, ToPagingInfo(query.PagingInfo), "ProductSysNo asc"))
            {
                sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, "1=1");

                dataCommand.AddInputParameter("@SapCoCodeFrom", DbType.String, query.OutCompany);
                dataCommand.AddInputParameter("@SapCoCodeTo", DbType.String, query.EnterCompany);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeStart", QueryConditionOperatorType.MoreThanOrEqual, query.OutTimeStart);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeEnd", QueryConditionOperatorType.LessThanOrEqual, query.OutTimeEnd);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.CompanyCode",
                                                             DbType.String, "@CompanyCode", QueryConditionOperatorType.LessThanOrEqual, query.CompanyCode);

                sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, " stItem.GoldenTaxNo is null ");

                if (prodtuctSysnos.Length < 1000)
                {
                    sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, " stItem.ProductSysNo in  (" + prodtuctSysnos + ") ");
                }
                dataCommand.CommandText = sqlBuilder.BuildQuerySql();
                result = dataCommand.ExecuteEntityList <ShiftSysnoProduct>();
            }

            return(result);
        }
        public List <ProductShiftDetail> Query(ProductShiftDetailReportQueryFilter filter, out int totalCount
                                               , ref ProductShiftDetailAmtInfo outAmt, ref ProductShiftDetailAmtInfo inAmt
                                               , ref ProductShiftDetail needManualItem)
        {
            totalCount = 0;
            List <ProductShiftDetail> result = null;

            if (filter.IsCheckCompany || filter.IsCheckDetail)
            {
                if (filter.IsCheckDetail)
                {
                    result = QueryProductShiftDetailCompanyInfos(filter, out totalCount);

                    if (totalCount > 0)
                    {
                        outAmt = QueryCompanyAmtCountInfo(filter)[0];
                    }
                }
                else
                {
                    List <ProductShiftDetailAmtInfo> listAmtInfo = null;
                    ProductShiftDetail productAdjest             = null;
                    result = QueryCompany(filter, ref listAmtInfo, ref productAdjest, out totalCount);
                    if (result.Count > 0 || (listAmtInfo != null && listAmtInfo.Count > 0))
                    {
                        outAmt = listAmtInfo.Find(item => item.CountType.Value == 1);
                        inAmt  = listAmtInfo.Find(item => item.CountType.Value == -1);

                        if (result.Count > 0)
                        {
                            var alertItem = result.Find(x => { return(x.NeedManual == true); });
                            if (alertItem != null || productAdjest != null)
                            {
                                if (alertItem != null)
                                {
                                    needManualItem = alertItem;
                                }
                                else
                                {
                                    needManualItem = productAdjest;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                result = QueryProductShiftDetail(filter, out totalCount);
            }

            return(result);
        }
        public ProductShiftDetailResp QueryProductShiftDetail(ProductShiftDetailReportQueryFilter filter)
        {
            int totalCount = 0;
            ProductShiftDetail        needManualItem = null;
            ProductShiftDetailAmtInfo outAmt = null, inAmt = null;
            var list = ObjectFactory <IProductShiftDetailQueryDA> .Instance.Query(filter, out totalCount, ref outAmt, ref inAmt, ref needManualItem);

            return(new ProductShiftDetailResp()
            {
                Data = list, TotalCount = totalCount, OutAmt = outAmt, InAmt = inAmt, NeedManualItem = needManualItem
            });
        }
        List <ProductShiftDetail> QueryProductShiftDetail(ProductShiftDetailReportQueryFilter query, out int totalCount)
        {
            CustomDataCommand dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryProductShiftDetail");

            using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                       dataCommand.CommandText, dataCommand, ToPagingInfo(query.PagingInfo), "stItem.ShiftSysNo asc"))
            {
                sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, "1=1");

                if (!string.IsNullOrEmpty(query.GoldenTaxNo))
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND,
                                                                 "stItem.GoldenTaxNo",
                                                                 DbType.String,
                                                                 "@GoldenTaxNo",
                                                                 QueryConditionOperatorType.Equal,
                                                                 query.GoldenTaxNo);
                }
                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.StockSysNoA",
                                                             DbType.Int32, "@StockSysNoA", QueryConditionOperatorType.Equal, query.StockSysNoA);

                if (!string.IsNullOrEmpty(query.StockSysNoB.ToString())) //dropdrow取下来的是? all/全部
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.StockSysNoB",
                                                                 DbType.Int32, "@StockSysNoB", QueryConditionOperatorType.Equal, query.StockSysNoB);
                }

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeStart", QueryConditionOperatorType.MoreThanOrEqual, query.OutTimeStart);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeEnd", QueryConditionOperatorType.LessThanOrEqual, query.OutTimeEnd);

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

                dataCommand.CommandText = sqlBuilder.BuildQuerySql();
                var dt = dataCommand.ExecuteEntityList <ProductShiftDetail>();
                totalCount = Convert.ToInt32(dataCommand.GetParameterValue("@TotalCount"));
                return(dt);
            }
        }
        private List <ProductShiftDetail> QueryCompany(ProductShiftDetailReportQueryFilter filter, ref List <ProductShiftDetailAmtInfo> listAmtInfo, ref ProductShiftDetail productAdjest, out int totalCount)
        {
            CustomDataCommand         dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryProductShiftDetailCompany");
            List <ProductShiftDetail> result      = new List <ProductShiftDetail>();

            using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                       dataCommand.CommandText, dataCommand, ToPagingInfo(filter.PagingInfo), "ShiftQty desc"))
            {
                sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, "1=1");

                if (!string.IsNullOrEmpty(filter.GoldenTaxNo))
                {
                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND,
                                                                 "stItem.GoldenTaxNo",
                                                                 DbType.String,
                                                                 "@GoldenTaxNo",
                                                                 QueryConditionOperatorType.Equal,
                                                                 filter.GoldenTaxNo);
                }

                dataCommand.AddInputParameter("@SapCoCodeFrom", DbType.String, filter.OutCompany);

                dataCommand.AddInputParameter("@SapCoCodeTo", DbType.String, filter.EnterCompany);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeStart", QueryConditionOperatorType.MoreThanOrEqual, filter.OutTimeStart);

                sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                             DbType.DateTime, "@OutTimeEnd", QueryConditionOperatorType.LessThanOrEqual, filter.OutTimeEnd);

                sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, " stItem.GoldenTaxNo is null ");

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

                dataCommand.CommandText = sqlBuilder.BuildQuerySql();
                var transferBefore = dataCommand.ExecuteEntityList <ProductShiftDetail>();

                listAmtInfo = QueryCompanyAmtCountInfo(filter);
                var transferResult = CollideOutAmt(listAmtInfo, transferBefore);
                totalCount = transferResult == null ? 0 : transferResult.Count;

                var rowIndex = filter.PagingInfo.PageIndex.Value * filter.PagingInfo.PageSize.Value;
                var pageSize = filter.PagingInfo.PageSize.Value;
                result = transferResult == null ? null : transferResult.Skip(rowIndex).Take(pageSize).ToList();

                //加调整项/////////////////////////////////
                productAdjest = transferResult.Find(x => { return(x.NeedManual == true); });
                /////////////////////////////////////////////////////

                List <ShiftSysnoProduct> listAtoB = GetStockAToStockB(filter, GetListString(transferResult));
                for (int i = 0; i < transferResult.Count; i++)
                {
                    List <ShiftSysnoProduct> listShiftAtoB = listAtoB.Where(item => item.ProductSysNo == transferResult[i].ProductSysNo).ToList();
                    if (transferResult[i].ShiftQty.HasValue && transferResult[i].ShiftQty > 0)
                    {
                        if (listShiftAtoB.Count > 0)
                        {
                            transferResult[i].ShiftSysNo = listShiftAtoB[0].ShiftSysNo;
                            transferResult[i].OutTime    = listShiftAtoB[0].OutTime;
                            transferResult[i].StockNameB = listShiftAtoB[0].StockNameB;
                        }
                    }
                }

                return(result);
            }
        }
        List <ProductShiftDetailAmtInfo> QueryCompanyAmtCountInfo(ProductShiftDetailReportQueryFilter query)
        {
            if (query.IsCheckDetail)
            {
                CustomDataCommand dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryProductShiftDetailCompanyInfosCountInfo");
                using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                           dataCommand.CommandText, dataCommand, ToPagingInfo(query.PagingInfo), "shiftDetail.SysNo asc"))
                {
                    sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, "1=1");

                    if (!string.IsNullOrEmpty(query.GoldenTaxNo))
                    {
                        sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND,
                                                                     "shiftDetail.TaxNO",
                                                                     DbType.String,
                                                                     "@GoldenTaxNo",
                                                                     QueryConditionOperatorType.Equal,
                                                                     query.GoldenTaxNo);
                    }

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "shiftDetail.OutCompany",
                                                                 DbType.String, "@OutCompany", QueryConditionOperatorType.Equal, query.OutCompany);

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "shiftDetail.InCompany",
                                                                 DbType.String, "@InCompany", QueryConditionOperatorType.Equal, query.EnterCompany);

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "shift.OutTime",
                                                                 DbType.DateTime, "@OutTimeStart", QueryConditionOperatorType.MoreThanOrEqual, query.OutTimeStart);

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "shift.OutTime",
                                                                 DbType.DateTime, "@OutTimeEnd", QueryConditionOperatorType.LessThanOrEqual, query.OutTimeEnd);

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

                    dataCommand.CommandText = sqlBuilder.BuildQuerySql();
                    return(dataCommand.ExecuteEntityList <ProductShiftDetailAmtInfo>());
                }
            }
            else
            {
                CustomDataCommand dataCommand = DataCommandManager.CreateCustomDataCommandFromConfig("QueryProductShiftDetailCompanyAmt");
                using (DynamicQuerySqlBuilder sqlBuilder = new DynamicQuerySqlBuilder(
                           dataCommand.CommandText, dataCommand, ToPagingInfo(query.PagingInfo), "ShiftQty desc"))
                {
                    sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, "1=1");

                    dataCommand.AddInputParameter("@SapCoCodeFrom", DbType.String, query.OutCompany);
                    dataCommand.AddInputParameter("@SapCoCodeTo", DbType.String, query.EnterCompany);

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                                 DbType.DateTime, "@OutTimeStart", QueryConditionOperatorType.MoreThanOrEqual, query.OutTimeStart);

                    sqlBuilder.ConditionConstructor.AddCondition(QueryConditionRelationType.AND, "st.OutTime",
                                                                 DbType.DateTime, "@OutTimeEnd", QueryConditionOperatorType.LessThanOrEqual, query.OutTimeEnd);

                    sqlBuilder.ConditionConstructor.AddCustomCondition(QueryConditionRelationType.AND, " stItem.GoldenTaxNo is null ");

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

                    dataCommand.CommandText = sqlBuilder.BuildQuerySql();
                    return(dataCommand.ExecuteEntityList <ProductShiftDetailAmtInfo>());
                }
            }
        }
 public ProductShiftDetailReport()
 {
     InitializeComponent();
     this.SeachBuilder.DataContext = m_query = new ProductShiftDetailReportQueryFilter();
 }
Exemple #9
0
 public void ExportQuery(ProductShiftDetailReportQueryFilter query, ColumnSet[] columnSet)
 {
     restClient.ExportFile("/InvoiceService/Invoice/ExportProductShiftDetail", query, columnSet);
 }
Exemple #10
0
 public void Query(ProductShiftDetailReportQueryFilter query, EventHandler <RestClientEventArgs <ProductShiftDetailResp> > callback)
 {
     restClient.Query <ProductShiftDetailResp>("/InvoiceService/Invoice/QueryProductShiftDetail", query, callback);
 }
 /// <summary>
 /// 移仓单明细表查询
 /// </summary>
 public DataTable ProductShiftDetailReportQuery(ProductShiftDetailReportQueryFilter filter, out int totalCount)
 {
     throw new NotImplementedException();
 }