예제 #1
0
        private void GetOutSummmaryStatisticData()
        {
            this.OutSummaryTextBlock.Text = null;
            ReportWeightSummaryV v = WeighingBillModel.GetReportWeightSummaryData(WeightingBillType.CK, GetStartDate(), GetEndDate(), GetSeachCondition());

            if (v != null)
            {
                this.OutSummaryTextBlock.Text = String.Format(this.OutDetailTotalStatisticLabelTemplate, v.companys, v.materials, v.cars, v.traeweight, v.grossweight, v.netweight);
            }
        }
        /// <summary>
        /// 获取报表的明细报表的 汇总 统计数据
        /// </summary>
        /// <param name="type"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="where">其它条件</param>
        /// <returns></returns>
        public static ReportWeightSummaryV GetReportWeightSummaryData(WeightingBillType type, String startDate = null, String endDate = null, String where = null)
        {
            ReportWeightSummaryV reportWeightSummaryV = null;
            String infield = @"COUNT(DISTINCT(send_company_id)) as companys,
                                        COUNT(DISTINCT(receive_material_id)) as materials,
                                        COUNT(DISTINCT(id)) as cars,
                                        SUM(send_net_weight) as sendweight,
                                        SUM(receive_gross_weight) as grossweight,
                                        SUM(receive_trae_weight) as traeweight,
                                        SUM(receive_net_weight) as netweight,
                                        SUM(decuation_weight) as decuationweight,
                                        SUM(difference_weight) as differenceweight";

            String outfield  = @"COUNT(DISTINCT(receive_company_id)) as companys,
                                        COUNT(DISTINCT(Send_material_id)) as materials,
                                        COUNT(DISTINCT(id)) as cars,
                                        SUM(Send_gross_weight) as grossweight,
                                        SUM(Send_trae_weight) as traeweight,
                                        SUM(Send_net_weight) as netweight";
            string condition = WeighingBillEnum.type.ToString() + " = " + ((int)type);

            if (type == WeightingBillType.RK)
            {
                condition += " and " + WeighingBillEnum.receive_status.ToString() + "= 1 ";
                if (string.IsNullOrEmpty(startDate) && string.IsNullOrEmpty(endDate))
                {
                    condition += " and " + WeighingBillEnum.receive_out_time.ToString() + " like '%" + MyHelper.DateTimeHelper.getCurrentDateTime(MyHelper.DateTimeHelper.DateFormat) + "%'";
                }
                else
                {
                    if (!string.IsNullOrEmpty(startDate))
                    {
                        condition += " and " + WeighingBillEnum.receive_out_time.ToString() + " >=" + Constract.valueSplit + startDate + Constract.valueSplit;
                    }
                    if (!string.IsNullOrEmpty(endDate))
                    {
                        condition += " and " + WeighingBillEnum.receive_out_time.ToString() + " <=" + Constract.valueSplit + endDate + Constract.valueSplit;
                    }
                }
            }
            else if (type == WeightingBillType.CK)
            {
                condition += " and " + WeighingBillEnum.send_status.ToString() + "= 1 ";
                if (string.IsNullOrEmpty(startDate) && string.IsNullOrEmpty(endDate))
                {
                    condition += " and " + WeighingBillEnum.send_out_time.ToString() + " like '%" + MyHelper.DateTimeHelper.getCurrentDateTime(MyHelper.DateTimeHelper.DateFormat) + "%'";
                }
                else
                {
                    if (!string.IsNullOrEmpty(startDate))
                    {
                        condition += " and " + WeighingBillEnum.send_out_time.ToString() + " >=" + Constract.valueSplit + startDate + Constract.valueSplit;
                    }
                    if (!string.IsNullOrEmpty(endDate))
                    {
                        condition += " and " + WeighingBillEnum.send_out_time.ToString() + " <=" + Constract.valueSplit + endDate + Constract.valueSplit;
                    }
                }
            }
            else
            {
                return(null);
            }
            if (!string.IsNullOrEmpty(where))
            {
                condition += " and " + where;
            }
            string sql = string.Empty;

            if (type == WeightingBillType.RK)
            {
                sql = DatabaseOPtionHelper.GetInstance().getSelectSql(DataTabeName.weighing_bill.ToString(), infield, condition);
            }
            else if (type == WeightingBillType.CK)
            {
                sql = DatabaseOPtionHelper.GetInstance().getSelectSql(DataTabeName.weighing_bill.ToString(), outfield, condition);
            }
            else
            {
                return(null);
            }
            reportWeightSummaryV = DatabaseOPtionHelper.GetInstance().select <ReportWeightSummaryV>(sql)[0];
            return(reportWeightSummaryV);
        }