public List <RuntimeStationData> SelectRuntimeStationData(int StationID, DateTime TargetDate)
        {
            connect();
            DateTime TimeStart = TargetDate.Date;
            DateTime TimeEnd   = TimeStart + TimeSpan.FromDays(1) - TimeSpan.FromSeconds(1);
            List <RuntimeStationData> DataList = new List <RuntimeStationData>();
            string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `StationID`={0} AND `Time` BETWEEN '{1}' AND '{2}';",
                                       StationID, TimeStart.ToString("yyyy-MM-dd HH:mm:ss"), TimeEnd.ToString("yyyy-MM-dd HH:mm:ss"));
            MySqlCommand    cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                RuntimeStationData Record = new RuntimeStationData()
                {
                    ID            = (int)rdr["ID"],
                    StationID     = (int)rdr["StationID"],
                    ActivePower   = double.Parse((string)rdr["ActivePower"]),
                    ReactivePower = double.Parse((string)rdr["ReactivePower"]),
                    Time          = (DateTime)rdr["Time"]
                };
                DataList.Add(Record);
            }
            rdr.Close();
            return(DataList);
        }
 public int AddRuntimeStationData(RuntimeStationData Record)
 {
     connect();
     string sql = String.Format("INSERT INTO `runtime_station_data` (`StationID`,`ActivePower`,`ReactivePower`,`Time`) VALUE ('{0}','{1}','{2}','{3}');",
         Record.StationID, Record.ActivePower, Record.ReactivePower, Record.Time.ToString("yyyy-MM-dd HH:mm:ss"));
     MySqlCommand cmd = new MySqlCommand(sql, conn);
     int result = cmd.ExecuteNonQuery();
     return result;
 }
        public int AddRuntimeStationData(RuntimeStationData Record)
        {
            connect();
            string sql = String.Format("INSERT INTO `runtime_station_data` (`StationID`,`ActivePower`,`ReactivePower`,`Time`) VALUE ('{0}','{1}','{2}','{3}');",
                                       Record.StationID, Record.ActivePower, Record.ReactivePower, Record.Time.ToString("yyyy-MM-dd HH:mm:ss"));
            MySqlCommand cmd    = new MySqlCommand(sql, conn);
            int          result = cmd.ExecuteNonQuery();

            return(result);
        }
        public RuntimeStationData FindRuntimeStationData(int ID)
        {
            connect();
            string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `ID`={0};",
                                       ID);
            MySqlCommand    cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            rdr.Read();
            RuntimeStationData Record = new RuntimeStationData()
            {
                ID            = (int)rdr["ID"],
                StationID     = (int)rdr["StationID"],
                ActivePower   = double.Parse((string)rdr["ActivePower"]),
                ReactivePower = double.Parse((string)rdr["ReactivePower"]),
                Time          = (DateTime)rdr["Time"]
            };

            rdr.Close();
            return(Record);
        }
        public List <RuntimeStationData> UpdateRuntimeStationData(int StartID, int StationID)
        {
            connect();
            List <RuntimeStationData> DataList = new List <RuntimeStationData>();
            string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `ID`>{0} AND `StationID`={0};",
                                       StartID, StationID);
            MySqlCommand    cmd = new MySqlCommand(sql, conn);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                RuntimeStationData Record = new RuntimeStationData()
                {
                    ID            = (int)rdr["ID"],
                    StationID     = (int)rdr["StationID"],
                    ActivePower   = double.Parse((string)rdr["ActivePower"]),
                    ReactivePower = double.Parse((string)rdr["ReactivePower"]),
                    Time          = (DateTime)rdr["Time"]
                };
                DataList.Add(Record);
            }
            rdr.Close();
            return(DataList);
        }
        public int AddRuntimeStationData(RuntimeStationData Record)
        {
            DatabaseConnector dc = new DatabaseConnector();

            return(dc.AddRuntimeStationData(Record));
        }
 public List<RuntimeStationData> UpdateRuntimeStationData(int StartID, int StationID)
 {
     connect();
     List<RuntimeStationData> DataList = new List<RuntimeStationData>();
     string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `ID`>{0} AND `StationID`={0};",
         StartID,StationID);
     MySqlCommand cmd = new MySqlCommand(sql, conn);
     MySqlDataReader rdr = cmd.ExecuteReader();
     while (rdr.Read())
     {
         RuntimeStationData Record = new RuntimeStationData()
         {
             ID = (int)rdr["ID"],
             StationID = (int)rdr["StationID"],
             ActivePower = double.Parse((string)rdr["ActivePower"]),
             ReactivePower = double.Parse((string)rdr["ReactivePower"]),
             Time = (DateTime)rdr["Time"]
         };
         DataList.Add(Record);
     }
     rdr.Close();
     return DataList;
 }
 public List<RuntimeStationData> SelectRuntimeStationData(int StationID, DateTime TargetDate)
 {
     connect();
     DateTime TimeStart = TargetDate.Date;
     DateTime TimeEnd = TimeStart + TimeSpan.FromDays(1) - TimeSpan.FromSeconds(1);
     List<RuntimeStationData> DataList = new List<RuntimeStationData>();
     string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `StationID`={0} AND `Time` BETWEEN '{1}' AND '{2}';",
         StationID, TimeStart.ToString("yyyy-MM-dd HH:mm:ss"), TimeEnd.ToString("yyyy-MM-dd HH:mm:ss"));
     MySqlCommand cmd = new MySqlCommand(sql, conn);
     MySqlDataReader rdr = cmd.ExecuteReader();
     while (rdr.Read())
     {
         RuntimeStationData Record = new RuntimeStationData()
         {
             ID = (int)rdr["ID"],
             StationID = (int)rdr["StationID"],
             ActivePower = double.Parse((string)rdr["ActivePower"]),
             ReactivePower = double.Parse((string)rdr["ReactivePower"]),
             Time = (DateTime)rdr["Time"]
         };
         DataList.Add(Record);
     }
     rdr.Close();
     return DataList;
 }
 public RuntimeStationData FindRuntimeStationData(int ID)
 {
     connect();
     string sql = String.Format("SELECT * FROM `runtime_station_data` WHERE `ID`={0};",
         ID);
     MySqlCommand cmd = new MySqlCommand(sql, conn);
     MySqlDataReader rdr = cmd.ExecuteReader();
     rdr.Read();
     RuntimeStationData Record = new RuntimeStationData()
     {
         ID = (int)rdr["ID"],
         StationID = (int)rdr["StationID"],
         ActivePower = double.Parse((string)rdr["ActivePower"]),
         ReactivePower = double.Parse((string)rdr["ReactivePower"]),
         Time = (DateTime)rdr["Time"]
     };
     rdr.Close();
     return Record;
 }
 public int AddRuntimeStationData(RuntimeStationData Record)
 {
     DatabaseConnector dc = new DatabaseConnector();
     return dc.AddRuntimeStationData(Record);
 }