Пример #1
0
 public void SetStatisticsData(Statistics statistics)
 {
     //"insert into statistics value('', '11', '2015-11-21 21:28:44', 11, 11)";
     string sqlcommand = "INSERT INTO statistics(ClassroomId, date, temperature, humidity) VALUE(@classroomId, @date, @temperature, @humidity)";
     //            string sqlcommand = "insert into processedpapers(dc_ID,dc_title,dc_titleTokens,dc_descriptionTokens,dc_len,dc_description)values(@mydcid,@dmydctitle,@mydctitletokens,@mydcdescriptiontokens,@mydclen,@mydcdescription)";
     MySqlParameter ClassRoomdId = new MySqlParameter("@classroomId", MySqlDbType.VarChar);
     ClassRoomdId.Value = statistics.ClassroomId;
     MySqlParameter Date = new MySqlParameter("@date", MySqlDbType.DateTime);
     Date.Value = statistics.Date.ToString("yyyy-MM-dd HH:mm:ss");
     MySqlParameter Temperature = new MySqlParameter("@temperature", MySqlDbType.Double);
     Temperature.Value = statistics.Temperature;
     MySqlParameter Humidity = new MySqlParameter("@humidity", MySqlDbType.Double);
     Humidity.Value = statistics.Humidity;
     MySqlCommand cmd = new MySqlCommand(sqlcommand);
     cmd.Parameters.Add(ClassRoomdId);
     cmd.Parameters.Add(Date);
     cmd.Parameters.Add(Temperature);
     cmd.Parameters.Add(Humidity);
     sqLcon.Oper(cmd);
 }
Пример #2
0
 public List<Statistics> GetStatisticsByTimeAndName(string[] time,string name)
 {
     List<Statistics> list = new List<Statistics>();
     DataRowCollection dr = sqLcon.Query(@"SELECT * FROM `statistics`,`classroom` WHERE classroom.ClassroomName= '"+ name +"' AND statistics.ClassroomId = classroom.ClassroomId AND `date` BETWEEN '" + time[0] + "' AND '" + time[1] + "' ", "statistics");
     foreach (DataRow dataRow in dr)
     {
         Statistics statistics = new Statistics();
         statistics.Id = Convert.ToInt32(dataRow["Id"].ToString());
         statistics.ClassroomId = dataRow["ClassroomId"].ToString();
         statistics.ClassroomName = dataRow["ClassroomName"].ToString();
         statistics.Date = DateTime.Parse(dataRow["date"].ToString());
         statistics.Temperature = Convert.ToDouble(dataRow["temperature"].ToString());
         statistics.Humidity = Convert.ToDouble(dataRow["humidity"].ToString());
         list.Add(statistics);
     }
     return list;
 }
Пример #3
0
 public void StatisticsData(Statistics statistics)
 {
     service.SetStatisticsData(statistics);
 }