Esempio n. 1
0
        string MakeStatisticsQuerySql(object obj)
        {
            DateTime realstartTime = DateTime.Parse(startTime);
            DateTime realendTime   = DateTime.Parse(endTime);

            string str          = "select ";
            string strCondition = "";
            int    index        = 0;

            do
            {
                strCondition += " ( ";
                strCondition += "select count(*) as totalCnt from Zhiqianshuju where Xuhao>=-1";
                strCondition += MakeDeviceConditionSql("Zhiqianshuju");
                strCondition += " and Zhiqianshuju.[Riqi]>=" + Common.ConvertDateTimeInt(realstartTime);

                if (dataTypeText.Contains("天"))
                {
                    realstartTime = realstartTime.AddDays(1);
                }
                else if (dataTypeText.Contains("周"))
                {
                    realstartTime = realstartTime.AddDays(7);
                }
                else if (dataTypeText.Contains("月"))
                {
                    realstartTime = realstartTime.AddMonths(1);
                }
                else if (dataTypeText.Contains("年"))
                {
                    realstartTime = realstartTime.AddYears(1);
                }

                if (realstartTime < realendTime)
                {
                    strCondition += " and Zhiqianshuju.[Riqi]<" + Common.ConvertDateTimeInt(realstartTime);
                }
                else
                {
                    strCondition += " and Zhiqianshuju.[Riqi]<" + Common.ConvertDateTimeInt(realendTime);
                }
                strCondition += " ) as " + "'" + index + "'";

                index++;
                if (realstartTime < realendTime && index < 12)
                {
                    strCondition += ",";
                }
            } while (realstartTime < realendTime && index < 12);


            Application.Current.Dispatcher.Invoke(
                new Action(() =>
            {
                IntPtr hwnd      = new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle;
                tagRECT rcClient = new tagRECT();

                PieChartServer.RemovePieChart(_pieCharIndex);
                LineChartServer.RemoveCurveChart(_lineCharIndex);
                HistogramServer.RemoveHistogramChart(_histogramCharIndex);

                _pieCharIndex       = PieChartServer.AddPieChart(hwnd, rcClient);
                _lineCharIndex      = LineChartServer.AddCurveChart(hwnd, rcClient);
                _histogramCharIndex = HistogramServer.AddHistogramChart(hwnd, rcClient, 0, 3000, 300, Color.Red.ToArgb(), Color.Black.ToArgb(), Color.Green.ToArgb());
                ResizeShowCharts();

                PieChartServer.AddData(_pieCharIndex, index);
                LineChartServer.AddData(_lineCharIndex, 13, index, 3600);
                HistogramServer.AddData(_histogramCharIndex, index);
            }));

            return(str + strCondition);
        }
Esempio n. 2
0
        string MakeStatisticsQuerySql(object obj)
        {
            DateTime realstartTime = DateTime.Parse(startTime);
            DateTime realendTime   = DateTime.Parse(endTime);

            string str          = "select ";
            string strCondition = "";
            int    index        = 0;

            do
            {
                DateTime begintime = realstartTime;
                DateTime endtime   = realstartTime;

                strCondition += " ( ";

                if (dataTypeText.Contains("天"))
                {
                    realstartTime = realstartTime.AddDays(1);
                }
                else if (dataTypeText.Contains("周"))
                {
                    realstartTime = realstartTime.AddDays(7);
                }
                else if (dataTypeText.Contains("月"))
                {
                    realstartTime = realstartTime.AddMonths(1);
                }
                else if (dataTypeText.Contains("年"))
                {
                    realstartTime = realstartTime.AddYears(1);
                }

                if (realstartTime < realendTime)
                {
                    endtime = realstartTime;
                }
                else
                {
                    endtime = realendTime;
                }

                strCondition += MakeBenyuebanliyewuCurMonthQuerySql(obj, begintime, endtime);
                strCondition += " ) as " + "'" + index + "'";

                index++;
                if (realstartTime < realendTime && index < 31)
                {
                    strCondition += ",";
                }
            } while (realstartTime < realendTime && index < 31);

            Application.Current.Dispatcher.Invoke(
                new Action(() =>
            {
                IntPtr hwnd      = new System.Windows.Interop.WindowInteropHelper(Application.Current.MainWindow).Handle;
                tagRECT rcClient = new tagRECT();

                PieChartServer.RemovePieChart(_pieCharIndex);
                LineChartServer.RemoveCurveChart(_lineCharIndex);
                HistogramServer.RemoveHistogramChart(_histogramCharIndex);

                _pieCharIndex       = PieChartServer.AddPieChart(hwnd, rcClient);
                _lineCharIndex      = LineChartServer.AddCurveChart(hwnd, rcClient);
                _histogramCharIndex = HistogramServer.AddHistogramChart(hwnd, rcClient, 0, 3000, 300, Color.Red.ToArgb(), Color.Black.ToArgb(), Color.Green.ToArgb());
                ResizeShowCharts();

                PieChartServer.AddData(_pieCharIndex, index);
                LineChartServer.AddData(_lineCharIndex, 13, index, 3600);
                HistogramServer.AddData(_histogramCharIndex, index);
            }));

            return(str + strCondition);
        }