Exemple #1
0
 private void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         dtCheckedTags = m_viewTagValue.Table.GetChanges();
         List <DataRow> lstDeleteRows = new List <DataRow>();
         if (dtCheckedTags != null)
         {
             foreach (DataRow row in dtCheckedTags.Rows)
             {
                 if (row["CheckRow"].ToString() == "1")
                 {
                     sExcelCells += row["ExcelCell"] + ",";
                 }
                 else
                 {
                     lstDeleteRows.Add(row);
                 }
             }
             sExcelCells = sExcelCells.Trim(',');
             if (lstDeleteRows.Count > 0)
             {
                 foreach (DataRow row in lstDeleteRows)
                 {
                     dtCheckedTags.Rows.Remove(row);
                 }
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("请选择测点!");
         }
     }
     catch (Exception ex) { WriteLog.WriteLogs(ex.ToString()); }
 }
Exemple #2
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                lblQueryWait.Visible = true;
                lblQueryWait.Refresh();
                string sTime = PublicFunction.DateTimeToStringWithfff(DateTime.Now);
                string sSql  = "insert into QueryAlarm(QueryDate,StartTime,EndTime,QueryFields,UnitNO,AlarmDesc) values('"
                               + sTime + "','" + dateTimePickerBegin2.Value + "','" + dateTimePickerEnd2.Value + "','" + F18 + "',"
                               + UnitNO + ",'查询数据时,未按提示等待,做其他操作造成程序退出!')";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }

                dtChart = TagLJValue.QueryDBTotalData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "[ValueTime],[HourOfYear]," + F18, UnitNO);
                if (dtChart.Rows.Count > 0)
                {
                    if (rdoTotalHours.Checked == true)
                    {
                        chart1.Series[0].XValueMember = "HourOfYear";
                        chart1.Series[0].XValueType   = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
                        dXMin       = double.Parse(dtChart.Rows[0]["HourOfYear"].ToString());
                        dHourOfYear = double.Parse(dtChart.Rows[dtChart.Rows.Count - 1]["HourOfYear"].ToString());
                        chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Auto;
                        chart1.ChartAreas[0].AxisX.MajorGrid.Interval     = (dHourOfYear - dXMin) / 10;
                        chart1.ChartAreas[0].AxisX.IntervalType           = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Auto;
                        chart1.ChartAreas[0].AxisX.Interval          = (dHourOfYear - dXMin) / 10;
                        chart1.ChartAreas[0].AxisX.Title             = "供热期累计小时数";
                        chart1.ChartAreas[0].AxisX.LabelStyle.Format = "0";
                    }
                    else
                    {
                        DateTime timeBegin = (DateTime)dtChart.Rows[0]["ValueTime"];
                        DateTime timeEnd   = (DateTime)dtChart.Rows[dtChart.Rows.Count - 1]["ValueTime"];
                        chart1.Series[0].XValueMember = "ValueTime";
                        chart1.Series[0].XValueType   = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
                        chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Hours;
                        chart1.ChartAreas[0].AxisX.MajorGrid.Interval     = (timeEnd - timeBegin).TotalHours / 6;
                        chart1.ChartAreas[0].AxisX.IntervalType           = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Hours;
                        chart1.ChartAreas[0].AxisX.Interval          = (timeEnd - timeBegin).TotalHours / 6;
                        chart1.ChartAreas[0].AxisX.Title             = "日期时间";
                        chart1.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd HH:mm";
                    }
                    chart1.ChartAreas[0].AxisX.TitleAlignment = StringAlignment.Far;
                    chart1.ChartAreas[0].AxisY.Title          = "累计节标煤量:" + Math.Round(double.Parse(dtChart.Rows[dtChart.Rows.Count - 1][F18].ToString()), 2) + "(吨)";
                    chart1.DataSource = dtChart;
                    chart1.DataBind();
                    timerChartBind.Enabled = false;
                }
                else
                {
                    MessageBox.Show("没有查询到数据!");
                }

                sSql = "delete QueryAlarm where QueryDate='" + sTime + "'";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }
            }
            catch (Exception ex)
            {
                WriteLog.WriteLogs(ex.ToString());
                MessageBox.Show("错误:" + ex.Message);
            }
            finally
            {
                lblQueryWait.Visible = false;
                lblQueryWait.Refresh();
            }
        }
Exemple #3
0
        /// <summary>
        /// 加载程序运行中配置的控件
        /// </summary>
        void AddConfigedControl()
        {
            try
            {
                int       i;
                Control   parent  = null;
                Control   control = null;
                Rectangle rect;
                LabelTag  labelTag = null;
                foreach (DataRow row in dtControls.Rows)
                {
                    parent = panel1;
                    try
                    {
                        if (row["type"].ToString() == "PictureBox")
                        {
                            int controlX = int.Parse(row["ControlX"].ToString());
                            int controlY = int.Parse(row["ControlY"].ToString());
                            control = new PictureBox();
                            ((PictureBox)control).BackgroundImage       = global::KSPrj.Properties.Resources.verticalGreen;
                            ((PictureBox)control).BackgroundImageLayout = ImageLayout.Stretch;
                            control.Name          = row["ControlName"].ToString();
                            rect                  = new Rectangle();
                            rect.X                = controlX;
                            rect.Y                = controlY;
                            labelTag              = new LabelTag();
                            labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                            labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                            labelTag.ControlX     = controlX;
                            labelTag.ControlY     = controlY;
                            labelTag.UnitNo       = byte.Parse(row["UnitNo"].ToString());
                            control.Tag           = labelTag;

                            control.Bounds = rect;
                            control.Size   = new System.Drawing.Size(12, 18);
                            parent.Controls.Add(control);
                            control.Refresh();
                            continue;
                        }

                        //这里先以Label写死;如果以后还有其他类型的控件,则在这里枚举
                        control = new Label();
                        ((Label)control).AutoSize = true;
                        control.Name = row["ControlName"].ToString();
                        control.Text = control.Name;
                        if (row["ControlText"].ToString().Length > 1)
                        {
                            control.Text = row["ControlText"].ToString();
                        }
                        if (row["FontSize"].ToString().Length > 1)
                        {
                            control.Font = new System.Drawing.Font("宋体", float.Parse(row["FontSize"].ToString()), System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
                        }
                        rect           = new Rectangle();
                        rect.X         = int.Parse(row["ControlX"].ToString());
                        rect.Y         = int.Parse(row["ControlY"].ToString());
                        control.Bounds = rect;
                        try { control.ForeColor = Color.FromArgb(int.Parse(row["ForeColor"].ToString())); }
                        catch { }
                        try { control.BackColor = Color.Transparent; }//Color.FromArgb(int.Parse(row["BackColor"].ToString()));
                        catch { }
                        labelTag              = new LabelTag();
                        labelTag.ControlX     = rect.X;
                        labelTag.ControlY     = rect.Y;
                        labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                        labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                        labelTag.UnitNo       = byte.Parse(row["UnitNo"].ToString());
                        control.Tag           = labelTag;
                        control.DoubleClick  += new EventHandler(Label_DoubleClick);//双击事件
                        parent.Controls.Add(control);
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            { WriteLog.WriteLogs(ex.ToString()); }
        }
Exemple #4
0
 private void timerChartBind_Tick(object sender, EventArgs e)
 {
     try
     {
         DataRow row;
         if (lTotalCount < TagLJValue.GetTotalCount(UnitNO))
         {
             lTotalCount = TagLJValue.GetTotalCount(UnitNO);
             dtChart.Dispose();
             dtChart = null;
             dtChart = TagLJValue.GetTotalDataWithNewTable(UnitNO);
             if (dtChart.Rows.Count > 0)
             {
                 dHourOfYear = double.Parse(dtChart.Rows[dtChart.Rows.Count - 1]["HourOfYear"].ToString());
                 if (rdoTotalHours.Checked == true)
                 {
                     chart1.Series[0].XValueMember = "HourOfYear";
                     chart1.Series[0].XValueType   = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
                     dXMin = double.Parse(dtChart.Rows[0]["HourOfYear"].ToString());
                     chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Auto;
                     chart1.ChartAreas[0].AxisX.MajorGrid.Interval     = (int)(dHourOfYear - dXMin) / 10;
                     chart1.ChartAreas[0].AxisX.IntervalType           = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Auto;
                     chart1.ChartAreas[0].AxisX.Interval          = (int)(dHourOfYear - dXMin) / 10;
                     chart1.ChartAreas[0].AxisX.Title             = "供热期累计小时数";
                     chart1.ChartAreas[0].AxisX.LabelStyle.Format = "0";
                 }
                 else
                 {
                     DateTime timeBegin = (DateTime)dtChart.Rows[0]["ValueTime"];
                     DateTime timeEnd   = (DateTime)dtChart.Rows[dtChart.Rows.Count - 1]["ValueTime"];
                     chart1.Series[0].XValueMember = "ValueTime";
                     chart1.Series[0].XValueType   = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
                     chart1.ChartAreas[0].AxisX.MajorGrid.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Hours;
                     chart1.ChartAreas[0].AxisX.MajorGrid.Interval     = (int)(timeEnd - timeBegin).TotalHours / 6;
                     chart1.ChartAreas[0].AxisX.IntervalType           = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Hours;
                     chart1.ChartAreas[0].AxisX.Interval          = (int)(timeEnd - timeBegin).TotalHours / 6;
                     chart1.ChartAreas[0].AxisX.Title             = "时间";
                     chart1.ChartAreas[0].AxisX.LabelStyle.Format = "yyyy-MM-dd HH:mm";
                 }
                 chart1.ChartAreas[0].AxisY.Title = "供电累计收入:" + Math.Round(double.Parse(dtChart.Rows[dtChart.Rows.Count - 1][F6].ToString()), 2) + "(万元)";
                 row = dtChart.NewRow();
                 row["ValueTime"]  = DateTime.Parse(dtChart.Rows[dtChart.Rows.Count - 1]["ValueTime"].ToString()).AddSeconds(1);
                 row["HourOfYear"] = dHourOfYear + 0.0001;
                 dtChart.Rows.Add(row);
             }
         }
         row = dtChart.NewRow();
         row["ValueTime"]  = DateTime.Now;
         dHourOfYear      += timerChartBind.Interval / 1000 / 3600d;
         row["HourOfYear"] = dHourOfYear;
         MinMaxValue mmv = TagLJValue.GetMinMaxValue(F3226, UnitNO);
         chart1.ChartAreas[0].AxisX.Title = "供热期累计小时数:" + Math.Round(dHourOfYear, 4).ToString("0.0000")
                                            + "                累计开始时间:" + mmv.BeginDateString + "\n供电收入最小值:"
                                            + Math.Round(mmv.MinValue / 10000, 4).ToString("0.0000") + "        供电收入最小值时间:" + mmv.MinDateString
                                            + "\n供电收入最大值:" + Math.Round(mmv.MaxValue / 10000, 4).ToString("0.0000") + "        供电收入最大值时间:"
                                            + mmv.MaxDateString + "\n供电收入平均值:" + TagLJValue.GetTotalDataAvg(F6, UnitNO) + "万元/小时";
         chart1.ChartAreas[0].AxisX.TitleAlignment = StringAlignment.Near;
         dtChart.Rows.Add(row);
         chart1.DataSource = dtChart;
         chart1.DataBind();
         WriteLog.WriteLogs("timerChartBind:" + timerChartBind.Enabled);
     }
     catch (Exception ex)
     { WriteLog.WriteLogs(ex.ToString()); }
 }
Exemple #5
0
        /// <summary>
        /// 加载程序运行中配置的控件
        /// </summary>
        void AddConfigedControl()
        {
            try
            {
                //控制添加测点的按钮是否可见
                if (ConstYXYH.IsCanAddLabel)
                {
                    btnAddTag.Visible = true;
                }
                else
                {
                    btnAddTag.Visible = false;
                }

                int       i;
                Control   parent  = null;
                Control   control = null;
                Rectangle rect;
                LabelTag  labelTag = null;
                foreach (DataRow row in dtControls.Rows)
                {
                    parent = panel6;
                    try
                    {
                        //这里先以Label写死;如果以后还有其他类型的控件,则在这里枚举
                        control = new Label();
                        ((Label)control).AutoSize = true;
                        control.Name = row["ControlName"].ToString();
                        control.Text = control.Name;
                        if (row["ControlText"].ToString().Length > 1)
                        {
                            control.Text = row["ControlText"].ToString();
                        }
                        rect           = new Rectangle();
                        rect.X         = int.Parse(row["ControlX"].ToString());
                        rect.Y         = int.Parse(row["ControlY"].ToString());
                        control.Bounds = rect;
                        try { control.ForeColor = Color.FromArgb(int.Parse(row["ForeColor"].ToString())); }
                        catch { }
                        try { control.BackColor = Color.FromArgb(int.Parse(row["BackColor"].ToString())); }
                        catch { }
                        labelTag              = new LabelTag();
                        labelTag.ControlX     = rect.X;
                        labelTag.ControlY     = rect.Y;
                        labelTag.ParentHeight = int.Parse(row["ParentHeight"].ToString());
                        labelTag.ParentWidth  = int.Parse(row["ParentWidth"].ToString());
                        control.Tag           = labelTag;
                        control.DoubleClick  += new EventHandler(Label_DoubleClick);      //双击事件
                        control.MouseDown    += new MouseEventHandler(control_MouseDown); //鼠标按下事件
                        if (ConstYXYH.IsCanMoveLabel)
                        {
                            control.MouseMove       += new MouseEventHandler(control_MouseMove); //移动时的鼠标移动事件
                            control.MouseUp         += new MouseEventHandler(control_MouseUp);   //移动时的鼠标抬起事件
                            control.ContextMenuStrip = contextMenuStrip_Label;                   //添加快捷菜单
                        }
                        parent.Controls.Add(control);
                    }
                    catch { }
                }
            }
            catch (Exception ex)
            { WriteLog.WriteLogs(ex.ToString()); }
        }