FIC_Solar/solarApp/fmArchive.cs
2021-09-13 18:32:17 +08:00

192 lines
7.5 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using solarApp.Service;
namespace solarApp
{
public partial class fmArchive : Form
{
getStationSvc stationSvc = new getStationSvc();
public fmArchive()
{
InitializeComponent();
}
private void bt_inv_proc_Click(object sender, EventArgs e)
{
}
private void bt_Sensor_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procSensorSvc sensorSvc = new procSensorSvc();
//sensorSvc._siteDB = lbSiteDB_sensor.Text;
//sensorSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//sensorSvc._siteID01 = lbSiteID_sensor.Text;
//sensorSvc._date1 = date1;
//sensorSvc._date2 = date1;
sensorSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void fmArchive_Load(object sender, EventArgs e)
{
#region
int i = 0;
var site_list = stationSvc.get_station_list();
foreach (var item in site_list)
{
RadioButton rb = new RadioButton();
rb.Name = item.SiteID;
rb.Text = item.SiteName;
rb.Tag = item.SiteDB;
rb.Font = new Font(Font.FontFamily, 12);
rb.AutoSize = true;
rb.CheckedChanged += new EventHandler(rb_site_CheckedChanged);
fp_site.Controls.Add(rb);
if (i == 0) rb.Checked = true;
i++;
}
#endregion
}
private void rb_site_CheckedChanged(object sender, EventArgs e)
{
RadioButton rb = sender as RadioButton;
if (rb.Checked)
{
lbSiteName_sensor.Text = rb.Text;
lbSiteDB_sensor.Text = rb.Tag.ToString();
lbSiteID_sensor.Text = rb.Name;
//顯示 table name on label
//lbSiteRaw.Text = lbSiteName_inv.Text + " " + lbSiteDB_inv.Text + ".s" + lbSiteID_inv.Text + "_Station";
//lbInvRaw.Text = lbSiteName_inv.Text + " " + lbSiteDB_inv.Text + ".s" + lbSiteID_inv.Text + "_Inv";
//lbSensorRaw.Text = lbSiteName_inv.Text + " " + lbSiteDB_inv.Text + ".s" + lbSiteID_inv.Text + "_SensorAVG";
//add_inv_list(lbSiteDB_inv.Text, lbSiteID_inv.Text.Substring(0, 9));
}
}
private void btVerifyData_Click(object sender, EventArgs e)
{
fmMain fm = new fmMain();
fm.Show();
}
private void bt_Inv_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procInvSvc invSvc = new procInvSvc();
//invSvc._siteDB = lbSiteDB_sensor.Text;
//invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//invSvc._siteID01 = lbSiteID_sensor.Text;
//invSvc._date1 = date1;
//invSvc._date2 = date1;
invSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void dtSelect_ValueChanged(object sender, EventArgs e)
{
bt_clear_inv.Enabled = true;
bt_clear_station.Enabled = true;
bt_clear_sensor.Enabled = true;
bt_clear_inv.Text = "clear " + dtSelect1.Value.ToString("MM-dd");
bt_clear_station.Text = "clear " + dtSelect1.Value.ToString("MM-dd");
bt_clear_sensor.Text = "clear " + dtSelect1.Value.ToString("MM-dd");
}
private void bt_clear_inv_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procInvSvc invSvc = new procInvSvc();
invSvc._siteDB = lbSiteDB_sensor.Text;
invSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
invSvc._siteID01 = lbSiteID_sensor.Text;
invSvc._date1 = date1;
//invSvc._date2 = date1;
invSvc.clearData();
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void bt_clear_station_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procStationSvc siteSvc = new procStationSvc();
siteSvc._siteDB = lbSiteDB_sensor.Text;
siteSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
siteSvc._siteID01 = lbSiteID_sensor.Text;
siteSvc._date1 = date1;
//siteSvc._date2 = date1;
siteSvc.clearData();
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void bt_site_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procStationSvc siteSvc = new procStationSvc();
//siteSvc._siteDB = lbSiteDB_sensor.Text;
//siteSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
//siteSvc._siteID01 = lbSiteID_sensor.Text;
//siteSvc._date1 = date1;
//siteSvc._date2 = date1;
siteSvc.archiveData(lbSiteID_sensor.Text.Substring(0, 9), date1);
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void bt_archive_Click(object sender, EventArgs e)
{
bt_Sensor.PerformClick();
bt_Inv.PerformClick();
bt_site.PerformClick();
}
private void bt_clear_sensor_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
//procSensorSvc sensorSvc = new procSensorSvc(lbSiteDB_sensor.Text, lbSiteID_sensor.Text, date1, date1);
procSensorSvc sensorSvc = new procSensorSvc();
sensorSvc._siteDB = lbSiteDB_sensor.Text;
sensorSvc._siteID = lbSiteID_sensor.Text.Substring(0, 9);
sensorSvc._siteID01 = lbSiteID_sensor.Text;
sensorSvc._date1 = date1;
//sensorSvc._date2 = date1;
sensorSvc.clearData();
//sensorSvc.archiveData();
MessageBox.Show("OK");
}
private void lbSiteDB_sensor_Click(object sender, EventArgs e)
{
fmExcel fm = new fmExcel();
fm.Show();
}
private void bt_meter_Click(object sender, EventArgs e)
{
string date1 = dtSelect1.Value.ToString("yyyy-MM-dd");
procSensorSvc sensorSvc = new procSensorSvc();
sensorSvc.archiveMeterData(lbSiteID_sensor.Text.Substring(0, 9), date1);
}
}
}