diff --git a/solarApp/Model/station_model.cs b/solarApp/Model/station_model.cs index 3898318..0d808d9 100644 --- a/solarApp/Model/station_model.cs +++ b/solarApp/Model/station_model.cs @@ -56,7 +56,8 @@ namespace solarApp.Model public double TOTALKWH { get; set; } public double PR { get; set; } public double SOLARHOUR { get; set; } - public double kwhkwp { get; set; } + public double kwhkwp { get; set; } + public int count { get; set; } } public class station_list diff --git a/solarApp/Service/getStationSvc.cs b/solarApp/Service/getStationSvc.cs index 3e89bec..50a7f1e 100644 --- a/solarApp/Service/getStationSvc.cs +++ b/solarApp/Service/getStationSvc.cs @@ -116,9 +116,22 @@ namespace solarApp.Service using (MySqlConnection conn = new MySqlConnection(Connection1)) { conn.Open(); - string sql = @" select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, siteid, round(TODAYKWH, 2) TODAYKWH, round(TOTALKWH, 2) TOTALKWH, - round(PR, 3) PR, round(KWHKWP, 3) KWHKWP, money - from power_station_history_day where left(`TIMESTAMP`, 10) between @date1 and @date2 and siteid = @siteID"; + //string sql = @" + // select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, siteid, round(TODAYKWH, 2) TODAYKWH, round(TOTALKWH, 2) TOTALKWH, + // round(PR, 3) PR, round(KWHKWP, 3) KWHKWP, money + // from power_station_history_day where left(`TIMESTAMP`, 10) between @date1 and @date2 and siteid = @siteID"; + string sql = @" + select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, a.siteid, round(TODAYKWH, 2) TODAYKWH, round(TOTALKWH, 2) TOTALKWH, + round(PR, 3) PR, round(KWHKWP, 3) KWHKWP, money, count + from power_station_history_day a join ( + select DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') reportdate, SITEID, count(*) count + from power_station_history_hour + where siteid = @siteID and left(`TIMESTAMP`, 10) between @date1 and @date2 + group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), SITEID + ) b on a.SITEID = b.SITEID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = b.reportdate + where left(`TIMESTAMP`, 10) between @date1 and @date2 and a.siteid = @siteID + order by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') + "; List ds = conn.Query(sql, new { date1 = date1, date2 = date2 , siteID = siteID}).AsList(); conn.Close(); return ds; diff --git a/solarApp/fmMain.Designer.cs b/solarApp/fmMain.Designer.cs index 7906b34..24a81cb 100644 --- a/solarApp/fmMain.Designer.cs +++ b/solarApp/fmMain.Designer.cs @@ -929,6 +929,7 @@ namespace solarApp this.gv_web_station_day.RowTemplate.Height = 25; this.gv_web_station_day.Size = new System.Drawing.Size(711, 292); this.gv_web_station_day.TabIndex = 3; + this.gv_web_station_day.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gv_web_station_day_CellFormatting); // // panel7 // @@ -1061,6 +1062,7 @@ namespace solarApp this.gv_fic_station_day.RowTemplate.Height = 25; this.gv_fic_station_day.Size = new System.Drawing.Size(744, 453); this.gv_fic_station_day.TabIndex = 4; + this.gv_fic_station_day.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.gv_fic_station_day_CellFormatting); // // panel5 // diff --git a/solarApp/fmMain.cs b/solarApp/fmMain.cs index ce1f928..71c2245 100644 --- a/solarApp/fmMain.cs +++ b/solarApp/fmMain.cs @@ -245,5 +245,27 @@ namespace solarApp } } } + + private void gv_fic_station_day_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (gv_fic_station_day.Rows[e.RowIndex].Cells["count"].Value != null && !string.IsNullOrWhiteSpace(gv_fic_station_day.Rows[e.RowIndex].Cells["count"].Value.ToString())) + { + if (gv_fic_station_day.Rows[e.RowIndex].Cells["count"].Value.ToString() != "24") + { + gv_fic_station_day.Rows[e.RowIndex].Cells["count"].Style = new DataGridViewCellStyle { ForeColor = Color.Red, BackColor = Color.White }; + } + } + } + + private void gv_web_station_day_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + if (gv_web_station_day.Rows[e.RowIndex].Cells["count"].Value != null && !string.IsNullOrWhiteSpace(gv_web_station_day.Rows[e.RowIndex].Cells["count"].Value.ToString())) + { + if (gv_web_station_day.Rows[e.RowIndex].Cells["count"].Value.ToString() != "24") + { + gv_web_station_day.Rows[e.RowIndex].Cells["count"].Style = new DataGridViewCellStyle { ForeColor = Color.Red, BackColor = Color.White }; + } + } + } } }