Beispiel #1
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;
            }
        }
Beispiel #2
0
 private void btn_Chart_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(rankCHname))
     {
         typename = DataManager.get_TableEName(cmb_Type.SelectedItem.ToString());
         tablename = typename + "_" + rankname;
         if (!tablename.Contains("SOILNUTRIENT"))
         {
             ChartObject co = new ChartObject();
             co.cropcode = DataBaseOperate.get_CropCode(cmbCropType.SelectedItem.ToString());
             co.datemin = dT_maize_s.Value;
             co.datemax = dT_maize_e.Value;
             co.treeNodeEName = treeNodeEName;
             co.chartType = cmb_ChartType.SelectedItem.ToString();
             BindDataSource(co);
         }
         else
         {
             ChartObject co = new ChartObject();
             co.cropcode = DataBaseOperate.get_CropCode(cmbCropType.SelectedItem.ToString());
             co.datemin = dT_maize_s.Value;
             co.datemax = dT_maize_e.Value;
             co.treeNodeEName = treeNodeEName;
             co.nutrientcode = DataBaseOperate.get_NutrientCode(cmb_Nutrient.SelectedItem.ToString());
             co.chartType = cmb_ChartType.SelectedItem.ToString();
             BindSoilDataSource(co);
         }
         InitDataSet();
     }
     else
     {
         MessageBox.Show("请选择监测类型!");
     }
 }