Esempio n. 1
0
 private void MultPlotChart_Load(object sender, EventArgs e)
 {
     list_IndexType.DataSource = ChartOperate.get_chartIndexType();
     string[] items = { "线状图", "柱状图" };
     TreeNodeOperate.generatePlotTree(treeView2);
     cmb_StaticsType.DataSource = ChartOperate.get_chartStaticsType();
     cmb_ChartType.DataSource   = items;
     cmb_sensorType.DataSource  = ChartOperate.get_SensorSource();
 }
Esempio n. 2
0
        DataTable dt = null;//数据源
        private void btn_Chart_Click(object sender, EventArgs e)
        {
            chartControl1.Series.Clear();

            if (!string.IsNullOrEmpty(plotname))
            {
                if (cmb_IndexType.SelectedItem != null && cmb_StaticsType.SelectedItem != null && cmb_ChartType.SelectedItem != null && cmb_sensorType.SelectedItem != null)
                {
                    string IndexType   = ChartOperate.get_VITYPE(cmb_IndexType.SelectedItem.ToString());
                    string StaticsType = ChartOperate.get_STATYPE(cmb_StaticsType.SelectedItem.ToString());
                    string sensortype  = ChartOperate.get_SensorTYPE(cmb_sensorType.SelectedItem.ToString());
                    param1 = new SqlParameter[] {
                        new SqlParameter("@name", plotname),
                        new SqlParameter("@VI_TYPE", IndexType),
                        new SqlParameter("@VI_STATYPE", StaticsType),
                        new SqlParameter("@SENSORTYPE", sensortype),
                        new SqlParameter("@date1", Convert.ToDateTime(dT_maize_s.Value)),
                        new SqlParameter("@date2", Convert.ToDateTime(dT_maize_e.Value))
                    };
                    param2 = new SqlParameter[] {
                        new SqlParameter("@name", plotname),
                        new SqlParameter("@VI_TYPE", IndexType),
                        new SqlParameter("@VI_STATYPE", StaticsType),
                        new SqlParameter("@SENSORTYPE", sensortype),
                        new SqlParameter("@date1", Convert.ToDateTime(dT_maize_s.Value)),
                        new SqlParameter("@date2", Convert.ToDateTime(dT_maize_e.Value))
                    };
                    dt    = ChartOperate.get_VillPlotData(param1);
                    dicts = ChartOperate.get_VillPlotChartData(param2);
                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("没有满足条件的数据!");
                    }
                    else
                    {
                        Series ser1 = ChartOperate.CreateSeries(charttype, dicts);
                        ser1.Name = cmb_IndexType.SelectedItem.ToString();
                        chartControl1.Series.Add(ser1);
                        chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
                        chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.Top;
                        dataGridView1.DataSource = dt;
                        //chartControl1.ExportToImage(@"C:\Users\LYM\Desktop\1.png", ImageFormat.Png);
                    }
                    InitDataSet();
                }

                else
                {
                    MessageBox.Show("统计指标或图表类型不能为空!");
                }
            }
            else
            {
                MessageBox.Show("请选择地块!");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 绑定数据源
        /// </summary>
        /// <param name="co"></param>
        public void BindDataSource(ChartObject co)
        {
            chartControl1.Series.Clear();
            //DataTable dt = null;
            switch (rankname)
            {
            case "COUNTY":
                string str_county = string.Format("select * from {0} where CROP_CODE='{1}' and MONITORTIME between '{2}' and '{3}' and COUNTYCODE='{4}' order by MONITORTIME asc", tablename, co.cropcode, co.datemin, co.datemax, co.treeNodeEName);
                dt = DataManager.return_DataTable(str_county);
                break;

            case "TOWN":
                string str_town = string.Format("select * from {0} where CROP_CODE='{1}' and MONITORTIME between '{2}' and '{3}' and TOWNCODE='{4}' order by MONITORTIME asc", tablename, co.cropcode, co.datemin, co.datemax, co.treeNodeEName);
                dt = DataManager.return_DataTable(str_town);
                break;

            case "VILLAGE":
                string str_village = string.Format("select * from {0} where CROP_CODE='{1}' and MONITORTIME between '{2}' and '{3}' and VILLAGECODE='{4}' order by MONITORTIME asc", tablename, co.cropcode, co.datemin, co.datemax, co.treeNodeEName);
                dt = DataManager.return_DataTable(str_village);
                break;

            case "PLOT":
                string str_Plot = string.Format("select * from {0} where CROP_CODE='{1}' and MONITORTIME between '{2}' and '{3}' and PLOTID='{4}' order by MONITORTIME asc", tablename, co.cropcode, co.datemin, co.datemax, co.treeNodeEName);
                dt = DataManager.return_DataTable(str_Plot);
                break;
            }

            if (dt.Rows.Count != 0)
            {
                dataGridView1.DataSource = DataManager.Convert_ColumeName(DataManager.convert_TableValue(rankname, typename, dt));
                //dataGridView1.DataSource = dt;
                Dictionary <string, string> dicts = new Dictionary <string, string>();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dicts.Add(((DateTime)dt.Rows[i][1]).ToShortDateString(), dt.Rows[i][3].ToString());
                }
                Series ser = ChartOperate.CreateSeries(co.chartType, dicts);
                ser.Name = cmb_Type.SelectedItem.ToString();
                chartControl1.Series.Add(ser);
                chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
                chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.Top;
            }
            else
            {
                MessageBox.Show("没有符合条件的记录");
                dataGridView1.DataSource = null;
            }
        }
Esempio n. 4
0
        DataTable dt     = null;//数据源
        private void btn_Chart_Click(object sender, EventArgs e)
        {
            chartControl1.Series.Clear();
            if (!string.IsNullOrEmpty(plotname))
            {
                if (list_IndexType.SelectedItem != null && cmb_StaticsType.SelectedItem != null && cmb_ChartType.SelectedItem != null && cmb_sensorType.SelectedItem != null)
                {
                    string        StaticsType = ChartOperate.get_STATYPE(cmb_StaticsType.SelectedItem.ToString()).Trim();
                    string        sensortype  = ChartOperate.get_SensorTYPE(cmb_sensorType.SelectedItem.ToString());
                    StringBuilder sb          = new StringBuilder();
                    sb.Append("select  * from VI_PLOT where PLOTID='")
                    .Append(plotname + "' and  VI_STATYPE='")
                    .Append(StaticsType + "' and MONITORTIME between '")
                    .Append(dT_maize_s.Value + "' and '" + dT_maize_e.Value + "' and SENSORTYPE='")
                    .Append(sensortype + "' and VI_TYPE in ('");
                    for (int i = 0; i < list_IndexType.SelectedItems.Count; i++)
                    {
                        string value = ChartOperate.get_VITYPE(list_IndexType.SelectedItems[i].ToString()).Trim();
                        sb.Append(value + "','");
                    }
                    string strsql = sb.ToString();
                    strsql = strsql.Substring(0, strsql.LastIndexOf(",")) + ")";//以上全部拼接SQL语句
                    dt     = ChartOperate.get_VillPlotMulitData(strsql);
                    if (dt.Rows.Count == 0)
                    {
                        MessageBox.Show("没有满足条件的数据!");
                    }
                    else
                    {
                        for (int i = 0; i < list_IndexType.SelectedItems.Count; i++)
                        {
                            string         IndexType = ChartOperate.get_VITYPE(list_IndexType.SelectedItems[i].ToString());
                            SqlParameter[] param2    = new SqlParameter[] {
                                new SqlParameter("@name", plotname),
                                new SqlParameter("@VI_TYPE", IndexType),
                                new SqlParameter("@VI_STATYPE", StaticsType),
                                new SqlParameter("@SENSORTYPE", sensortype),
                                new SqlParameter("@date1", Convert.ToDateTime(dT_maize_s.Value)),
                                new SqlParameter("@date2", Convert.ToDateTime(dT_maize_e.Value))
                            };

                            Dictionary <string, string> dicts = dicts = ChartOperate.get_VillPlotChartData(param2);

                            Series ser = ChartOperate.CreateSeries(charttype, dicts);
                            ser.Name = list_IndexType.SelectedItems[i].ToString();
                            chartControl1.Series.Add(ser);
                            chartControl1.Legend.AlignmentHorizontal = LegendAlignmentHorizontal.Right;
                            chartControl1.Legend.AlignmentVertical   = LegendAlignmentVertical.Top;

                            //chartControl1.ExportToImage(@"C:\Users\LYM\Desktop\1.png", ImageFormat.Png);
                        }

                        dataGridView1.DataSource = dt;
                        InitDataSet();
                    }
                }
                else
                {
                    MessageBox.Show("统计指标或图表类型不能为空!");
                }
            }

            else
            {
                MessageBox.Show("请选择地块!");
            }
        }