private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox3.Items.Clear(); comboBox3.Text = string.Empty; ComboItem selectedCBItem = comboBox1.SelectedItem as ComboItem; int selectedItem = selectedCBItem.Id; if (selectedItem > -1) { lfa.pmgmt.data.DAO.Configuration.Unit units = new data.DAO.Configuration.Unit(); units.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Unit> unitList = units.List(selectedItem); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unitItem in unitList) { ComboItem item = new ComboItem(); item.Id = unitItem.Id; item.Name = unitItem.Name; comboBox3.Items.Add(item); } } }
public bool EntireLoadShed() { bool hasShedAll = false; List <lfa.pmgmt.data.DTO.BusinessRule.Load> loadList = new List <data.DTO.BusinessRule.Load>(); lfa.pmgmt.data.DAO.BusinessRule.Load loadDAO = new data.DAO.BusinessRule.Load(); loadDAO.ConnectionString = _connectionString; loadList = loadDAO.List(); if (loadList.Count > 0) { int current = loadList[0].CurrentLoad; int maxLoad = loadList[0].MaximumLoad; if (current >= maxLoad) { List <lfa.pmgmt.data.DTO.Configuration.Zone> zones = new List <data.DTO.Configuration.Zone>(); lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone(); zoneDAO.ConnectionString = _connectionString; zones = zoneDAO.List(); foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones) { List <lfa.pmgmt.data.DTO.Configuration.Unit> units = new List <data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(zone.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { List <lfa.pmgmt.data.DTO.Configuration.Device> devices = new List <data.DTO.Configuration.Device>(); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { SwitchDeviceOnOff(2, device.Id, device.Id_Unit); UpdateDeviceStatus(device.Id, 2); } } } hasShedAll = true; } } return(hasShedAll); }
public bool EntireLoadShed() { bool hasShedAll = false; List<lfa.pmgmt.data.DTO.BusinessRule.Load> loadList = new List<data.DTO.BusinessRule.Load>(); lfa.pmgmt.data.DAO.BusinessRule.Load loadDAO = new data.DAO.BusinessRule.Load(); loadDAO.ConnectionString = _connectionString; loadList = loadDAO.List(); if (loadList.Count > 0) { int current = loadList[0].CurrentLoad; int maxLoad = loadList[0].MaximumLoad; if (current >= maxLoad) { List<lfa.pmgmt.data.DTO.Configuration.Zone> zones = new List<data.DTO.Configuration.Zone>(); lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone(); zoneDAO.ConnectionString = _connectionString; zones = zoneDAO.List(); foreach (lfa.pmgmt.data.DTO.Configuration.Zone zone in zones) { List<lfa.pmgmt.data.DTO.Configuration.Unit> units = new List<data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(zone.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { List<lfa.pmgmt.data.DTO.Configuration.Device> devices = new List<data.DTO.Configuration.Device>(); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { SwitchDeviceOnOff(2, device.Id, device.Id_Unit); UpdateDeviceStatus(device.Id, 2); } } } hasShedAll = true; } } return hasShedAll; }
public bool EntireLoadShed(int zoneId, int status) { bool hasShedAll = false; List <lfa.pmgmt.data.DTO.BusinessRule.Load> loadList = new List <data.DTO.BusinessRule.Load>(); lfa.pmgmt.data.DAO.BusinessRule.Load loadDAO = new data.DAO.BusinessRule.Load(); loadDAO.ConnectionString = _connectionString; loadList = loadDAO.List(); if (loadList.Count > 0) { List <lfa.pmgmt.data.DTO.Configuration.Zone> zones = new List <data.DTO.Configuration.Zone>(); lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone(); zoneDAO.ConnectionString = _connectionString; lfa.pmgmt.data.DTO.Configuration.Zone zone = zoneDAO.Get(zoneId); List <lfa.pmgmt.data.DTO.Configuration.Unit> units = new List <data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(zone.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { List <lfa.pmgmt.data.DTO.Configuration.Device> devices = new List <data.DTO.Configuration.Device>(); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { SwitchDeviceOnOff(status, device.Id, device.Id_Unit); UpdateDeviceStatus(device.Id, status); } } hasShedAll = true; } return(hasShedAll); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ComboItem selectedItem = comboBox1.SelectedItem as ComboItem; int selectedZone = selectedItem.Id; List <lfa.pmgmt.data.DTO.Configuration.Unit> units = new List <data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(selectedZone); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { ComboItem item = new ComboItem(); item.Id = unit.Id; item.Name = unit.Name; comboBox2.Items.Add(item); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { comboBox3.Items.Clear(); comboBox3.Text = string.Empty; ComboItem selectedCBItem = comboBox1.SelectedItem as ComboItem; int selectedItem = selectedCBItem.Id; if (selectedItem > -1) { lfa.pmgmt.data.DAO.Configuration.Unit units = new data.DAO.Configuration.Unit(); units.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Unit> unitList = units.List(selectedItem); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unitItem in unitList) { ComboItem item = new ComboItem(); item.Id = unitItem.Id; item.Name = unitItem.Name; comboBox3.Items.Add(item); } } }
private void grdMain_RowEnter(object sender, DataGridViewCellEventArgs e) { DataGridViewRow selectedRow = null; if (_loadComplete) { switch (_currentModule) { case "Configuration": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Unit> unitList = unitDAO.List(_selectedItemDataId); grdChildOne.DataSource = unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; button5.Visible = true; _loadComplete = true; break; case "Schedule": if (grdMain.Rows.Count > 0) { try { selectedRow = grdMain.SelectedRows[0]; } catch { selectedRow = grdMain.Rows[0]; } _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Schedule.Unit scheduleDAO = new lfa.pmgmt.data.DAO.Schedule.Unit(); scheduleDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Schedule.Unit> s_unitList = scheduleDAO.List(_selectedItemDataId); grdChildOne.DataSource = s_unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildOne.Columns[2].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; } _loadComplete = true; break; case "LoadShed": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Configuration.Unit s_unitDAO = new data.DAO.Configuration.Unit(); s_unitDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Unit> ls_unitList = s_unitDAO.List(_selectedItemDataId); grdChildOne.DataSource = ls_unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; _loadComplete = true; break; case "Rules": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; btnDelete.Visible = true; button2.Visible = true; _loadComplete = true; break; } } }
private void grdMain_RowEnter(object sender, DataGridViewCellEventArgs e) { DataGridViewRow selectedRow = null; if (_loadComplete) { switch (_currentModule) { case "Configuration": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Unit> unitList = unitDAO.List(_selectedItemDataId); grdChildOne.DataSource = unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; button5.Visible = true; _loadComplete = true; break; case "Schedule": if (grdMain.Rows.Count > 0) { try { selectedRow = grdMain.SelectedRows[0]; } catch { selectedRow = grdMain.Rows[0]; } _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Schedule.Unit scheduleDAO = new lfa.pmgmt.data.DAO.Schedule.Unit(); scheduleDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Schedule.Unit> s_unitList = scheduleDAO.List(_selectedItemDataId); grdChildOne.DataSource = s_unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildOne.Columns[2].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; } _loadComplete = true; break; case "LoadShed": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; lfa.pmgmt.data.DAO.Configuration.Unit s_unitDAO = new data.DAO.Configuration.Unit(); s_unitDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Unit> ls_unitList = s_unitDAO.List(_selectedItemDataId); grdChildOne.DataSource = ls_unitList; grdChildOne.Columns[0].Visible = false; grdChildOne.Columns[1].Visible = false; grdChildTwo.Columns.Clear(); grdChildTwo.DataSource = null; _loadComplete = true; break; case "Rules": selectedRow = grdMain.SelectedRows[0]; _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString()); _loadComplete = false; btnDelete.Visible = true; button2.Visible = true; _loadComplete = true; break; } } }
private void btnOK_Click(object sender, EventArgs e) { try { ComboItem selectedItem = comboBox1.SelectedItem as ComboItem; int zoneId = selectedItem.Id; bool status = false; lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Unit> units = unitDAO.List(zoneId); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { lfa.pmgmt.data.DAO.Schedule.Unit sunitDAO = new data.DAO.Schedule.Unit(); sunitDAO.ConnectionString = _connectionString; sunitDAO.Insert(unit.Id, _scheduleId); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { lfa.pmgmt.data.DAO.Schedule.Device sdeviceDAO = new data.DAO.Schedule.Device(); sdeviceDAO.ConnectionString = _connectionString; sdeviceDAO.Insert(device.Id, unit.Id, status, _scheduleId); } lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule(); dao.ConnectionString = _connectionString; dao.LinkZone(_scheduleId, zoneId); } bool switch1On = checkBox1.Checked; bool switch2On = checkBox2.Checked; bool switch3On = checkBox3.Checked; bool switch4On = checkBox4.Checked; bool switch5On = checkBox5.Checked; bool switch6On = checkBox6.Checked; bool switch7On = checkBox7.Checked; bool switch8On = checkBox8.Checked; lfa.pmgmt.data.DAO.Schedule.Unit unitDAO2 = new data.DAO.Schedule.Unit(); unitDAO2.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO2.ListWithZone(_scheduleId); foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList) { if (unit.Id_Zone == zoneId) { lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device(); deviceDAO.ConnectionString = _connectionString; List <lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId); foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList) { lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device(); configDeviceDAO.ConnectionString = _connectionString; lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId); switch (configDevice.Switch) { case "Switch 1": deviceDAO.Update(device.Id, 0, 0, switch1On); break; case "Switch 2": deviceDAO.Update(device.Id, 0, 0, switch2On); break; case "Switch 3": deviceDAO.Update(device.Id, 0, 0, switch3On); break; case "Switch 4": deviceDAO.Update(device.Id, 0, 0, switch4On); break; case "Switch 5": deviceDAO.Update(device.Id, 0, 0, switch5On); break; case "Switch 6": deviceDAO.Update(device.Id, 0, 0, switch6On); break; case "Switch 7": deviceDAO.Update(device.Id, 0, 0, switch7On); break; case "Switch 8": deviceDAO.Update(device.Id, 0, 0, switch8On); break; } } } } HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } }
public bool EntireLoadShed(int zoneId, int status) { bool hasShedAll = false; List<lfa.pmgmt.data.DTO.BusinessRule.Load> loadList = new List<data.DTO.BusinessRule.Load>(); lfa.pmgmt.data.DAO.BusinessRule.Load loadDAO = new data.DAO.BusinessRule.Load(); loadDAO.ConnectionString = _connectionString; loadList = loadDAO.List(); if (loadList.Count > 0) { List<lfa.pmgmt.data.DTO.Configuration.Zone> zones = new List<data.DTO.Configuration.Zone>(); lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone(); zoneDAO.ConnectionString = _connectionString; lfa.pmgmt.data.DTO.Configuration.Zone zone = zoneDAO.Get(zoneId); List<lfa.pmgmt.data.DTO.Configuration.Unit> units = new List<data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(zone.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { List<lfa.pmgmt.data.DTO.Configuration.Device> devices = new List<data.DTO.Configuration.Device>(); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { SwitchDeviceOnOff(status, device.Id, device.Id_Unit); UpdateDeviceStatus(device.Id, status); } } hasShedAll = true; } return hasShedAll; }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ComboItem selectedItem = comboBox1.SelectedItem as ComboItem; int selectedZone = selectedItem.Id; List<lfa.pmgmt.data.DTO.Configuration.Unit> units = new List<data.DTO.Configuration.Unit>(); lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; units = unitDAO.List(selectedZone); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { ComboItem item = new ComboItem(); item.Id = unit.Id; item.Name = unit.Name; comboBox2.Items.Add(item); } }
private void btnOK_Click(object sender, EventArgs e) { try { ComboItem selectedItem = comboBox1.SelectedItem as ComboItem; int zoneId = selectedItem.Id; bool status = false; lfa.pmgmt.data.DAO.Configuration.Unit unitDAO = new data.DAO.Configuration.Unit(); unitDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Unit> units = unitDAO.List(zoneId); foreach (lfa.pmgmt.data.DTO.Configuration.Unit unit in units) { lfa.pmgmt.data.DAO.Schedule.Unit sunitDAO = new data.DAO.Schedule.Unit(); sunitDAO.ConnectionString = _connectionString; sunitDAO.Insert(unit.Id, _scheduleId); lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device(); deviceDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Configuration.Device> devices = deviceDAO.List(unit.Id); foreach (lfa.pmgmt.data.DTO.Configuration.Device device in devices) { lfa.pmgmt.data.DAO.Schedule.Device sdeviceDAO = new data.DAO.Schedule.Device(); sdeviceDAO.ConnectionString = _connectionString; sdeviceDAO.Insert(device.Id, unit.Id, status, _scheduleId); } lfa.pmgmt.data.DAO.Schedule.Schedule dao = new data.DAO.Schedule.Schedule(); dao.ConnectionString = _connectionString; dao.LinkZone(_scheduleId, zoneId); } bool switch1On = checkBox1.Checked; bool switch2On = checkBox2.Checked; bool switch3On = checkBox3.Checked; bool switch4On = checkBox4.Checked; bool switch5On = checkBox5.Checked; bool switch6On = checkBox6.Checked; bool switch7On = checkBox7.Checked; bool switch8On = checkBox8.Checked; lfa.pmgmt.data.DAO.Schedule.Unit unitDAO2 = new data.DAO.Schedule.Unit(); unitDAO2.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO2.ListWithZone(_scheduleId); foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList) { if (unit.Id_Zone == zoneId) { lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device(); deviceDAO.ConnectionString = _connectionString; List<lfa.pmgmt.data.DTO.Schedule.Device> deviceList = deviceDAO.ListWithDeviceId(unit.Id, _scheduleId); foreach (lfa.pmgmt.data.DTO.Schedule.Device device in deviceList) { lfa.pmgmt.data.DAO.Configuration.Device configDeviceDAO = new data.DAO.Configuration.Device(); configDeviceDAO.ConnectionString = _connectionString; lfa.pmgmt.data.DTO.Configuration.Device configDevice = configDeviceDAO.Get(device.DeviceId); switch (configDevice.Switch) { case "Switch 1": deviceDAO.Update(device.Id, 0, 0, switch1On); break; case "Switch 2": deviceDAO.Update(device.Id, 0, 0, switch2On); break; case "Switch 3": deviceDAO.Update(device.Id, 0, 0, switch3On); break; case "Switch 4": deviceDAO.Update(device.Id, 0, 0, switch4On); break; case "Switch 5": deviceDAO.Update(device.Id, 0, 0, switch5On); break; case "Switch 6": deviceDAO.Update(device.Id, 0, 0, switch6On); break; case "Switch 7": deviceDAO.Update(device.Id, 0, 0, switch7On); break; case "Switch 8": deviceDAO.Update(device.Id, 0, 0, switch8On); break; } } } } HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } }