예제 #1
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();

            if (sf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string      path        = sf.FileName.ToString();
                OutPutFile  outPutFile  = new OutPutFile();
                MrDataShow  mrDataShow  = new MrDataShow();
                MRTableList mRTableList = new MRTableList();
                DataTable   dt2         = new DataTable();
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                foreach (TreeNode item in treeView1.Nodes)
                {
                    foreach (TreeNode item2 in item.Nodes)
                    {
                        string name = item2.Text;
                        mRTableList.tabletype = item.Text;
                        mRTableList.tableName = item2.Text;

                        dt2           = mrDataShow.GetTableData(mRTableList);
                        dt2.TableName = item.Name + "-" + item2.Text;
                        string str = outPutFile.SaveCSV(dt2, string.Format("{0}//{1}.csv", path, dt2.TableName));
                    }
                }
                MessageBox.Show("导出成功!", "提示");
            }
        }
예제 #2
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            List <MRTableList> mrTable1 = SingletonMrData.mrTableL;

            string        tabelName  = treeView1.SelectedNode.Text;
            List <string> tableTypeL = new List <string>()
            {
                "MRE", "MRO", "MRS"
            };

            if (tableTypeL.Contains(tabelName))
            {
                return;
            }
            string tabelType = treeView1.SelectedNode.Parent.Text;
            //List<string> clolumnL = new List<string>();//需要呈现的所有列
            MRTableList mRTableList = new MRTableList();//

            mRTableList.tabletype = tabelType;
            mRTableList.tableName = tabelName;

            MrDataShow mrDataShow = new MrDataShow();

            dt                       = mrDataShow.GetTableData(mRTableList);
            dt.TableName             = tabelName;
            dataGridView1.DataSource = dt;

            this.Text = string.Format("MR数据呈现  {0}", tabelName);
        }
예제 #3
0
        //开始按钮的事件
        private void StartButton_Click(object sender, EventArgs e)
        {
            /*
             * string startTimeStr = cmbDateTimePicker1.Value.ToString("yyyyMMddHHmm");
             * string endTimeStr = cmbDateTimePicker2.Value.ToString("yyyyMMddHHmm");
             * double startTime = Convert.ToDouble(startTimeStr);
             * double endTime = Convert.ToDouble(endTimeStr);
             */
            if (cmbTextBox1.Text == "" || cmbTextBox2.Text == "" || cmbCounter.Text == "")
            {
                MessageBox.Show("请选择指标或输入门限值!!!");
                return;
            }
            DateTime startTime = cmbDateTimePicker1.Value;
            DateTime endTime   = cmbDateTimePicker2.Value;

            string minStr = cmbTextBox1.Text;
            string maxStr = cmbTextBox2.Text;
            double mindb  = Convert.ToDouble(minStr);
            double maxdb  = Convert.ToDouble(maxStr);

            //临时变量取到类型和表名
            string tabelType = cmbType.Text;
            string tabelName = cmbTable.Text;


            MRTableList mRTableList = new MRTableList();//

            mRTableList.tabletype = tabelType;
            mRTableList.tableName = tabelName;

            MrDataShow mrDataShow = new MrDataShow();

            //这dt装着所有的数据
            dt = mrDataShow.GetTableData(mRTableList);
            //指标
            string convert = cmbCounter.Text;
            //新建表dt1
            DataTable dtNew = dt.Clone();

            List <DataRow> aList = new List <DataRow>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //start大于;end小于
                string startTime1 = dt.Rows[i]["startTime"].ToString();
                string endTime1   = dt.Rows[i]["endTime"].ToString();
                startTime1.Remove(16);
                endTime1.Remove(16);
                DateTime           startTmDate;
                DateTime           endTmDate;
                DateTimeFormatInfo dtFormat = new System.Globalization.DateTimeFormatInfo();

                dtFormat.ShortDatePattern = "yyyy-MM-ddThh:mm";

                startTmDate = Convert.ToDateTime(startTime1, dtFormat);
                endTmDate   = Convert.ToDateTime(endTime1, dtFormat);

                string convertStr = dt.Rows[i][convert].ToString();
                //将得到的值转化为double
                double converDouble;
                if (double.TryParse(convertStr, out converDouble) == true)
                {
                    if ((startTmDate >= startTime) && (endTmDate <= endTime) && (converDouble >= mindb) && (converDouble <= maxdb))
                    {
                        aList.Add(dt.Rows[i]);
                    }
                }
            }
            //新表赋值
            for (int i = 0; i < aList.Count; i++)
            {
                dtNew.ImportRow(aList[i]);
            }
            //新表提取数据
            DataTable dtNew1 = dtNew.DefaultView.ToTable(false, new string[] { "id", convert });

            ShowDataGridView.DataSource = dtNew1;

            List <string> idList  = new List <string>();
            List <double> conlist = new List <double>();

            foreach (DataRow rowTemp in dtNew1.Rows)
            {
                idList.Add((string)rowTemp[0]);
                double data;
                if (double.TryParse((string)rowTemp[1], out data) == true)
                {
                    conlist.Add(data);
                }
            }

            chart1.Series[0].Points.DataBindXY(idList, conlist);
        }