using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UAS_MES_NEW.DataOperate;
using UAS_MES_NEW.Entity;

namespace UAS_MES_NEW.CustomControl.TextBoxWithIcon
{
    public partial class SourceStepCountPre : UserControl
    {
        DataHelper dh;

        string Source1;

        public string Source
        {
            get
            {
                return Source1;
            }

            set
            {
                Source1 = value;
            }
        }

        string StepCode1;

        public string StepCode
        {
            get
            {
                return StepCode1;
            }

            set
            {
                StepCode1 = value;
            }
        }

        string LineCode1;

        public string LineCode
        {
            get
            {
                return LineCode1;
            }

            set
            {
                LineCode1 = value;
            }
        }

        internal DataHelper Dh
        {
            get
            {
                return dh;
            }

            set
            {
                dh = value;
            }
        }

        public string Tag1
        {
            get
            {
                return tag;
            }

            set
            {
                tag = value;
            }
        }

        string tag;

        public SourceStepCountPre()
        {
            InitializeComponent();
        }

        private void SourceStepCount_Load(object sender, EventArgs e)
        {
            //五分钟刷新一次
            CountRefresh.Interval = 60000;
        }

        public void Start()
        {
            string SQL = "select count(1) from commandlog where cl_caller='" + tag + "' and cl_date>trunc(sysdate) and cl_linecode='" + User.UserLineCode + "'";
            DataTable dt = (DataTable)Dh.ExecuteSql(SQL, "select");
            Count.Text = "计数:" + dt.Rows[0][0].ToString();
            CountRefresh.Start();
        }

        public void Close()
        {
            CountRefresh.Stop();
        }

        private void CountRefresh_Tick(object sender, EventArgs e)
        {
            string SQL = "select count(1) from commandlog where cl_caller='" + tag + "' and cl_date>trunc(sysdate)  and cl_linecode='" + User.UserLineCode + "'";
            DataTable dt = (DataTable)Dh.ExecuteSql(SQL, "select");
            Count.Text = "计数:" + dt.Rows[0][0].ToString();
        }
    }
}