Ejemplo n.º 1
0
        private void GetScheduleUnitDetailsForId(List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits, int scheduleId,
                                                 List <int> ruleEnabledUnits, int defaultPort, int status)
        {
            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleUnit in scheduleUnits)
            {
                string address = scheduleUnit.Address;

                lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                deviceDAO.ConnectionString = _connectionString;

                if (!ruleEnabledUnits.Contains(scheduleUnit.Id))
                {
                    List <lfa.pmgmt.data.DTO.Schedule.Device> unitDevices = deviceDAO.List(scheduleUnit.Id, scheduleId);

                    ArrayList parameters = new ArrayList();
                    parameters.Add(unitDevices);
                    parameters.Add(defaultPort);
                    parameters.Add(scheduleUnit);
                    parameters.Add(status);

                    //AsyncLoadShedUnit(parameters);

                    Thread worker = new Thread(new ParameterizedThreadStart(AsyncLoadShedUnit));
                    worker.Priority = ThreadPriority.Highest;
                    worker.Start(parameters);
                }
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                bool      on           = false;
                ComboItem item         = comboBox1.SelectedItem as ComboItem;
                int       selectedItem = item.Id;
                lfa.pmgmt.data.DAO.Schedule.Device DAO = new data.DAO.Schedule.Device();
                DAO.ConnectionString = _connectionString;

                if (comboBox2.SelectedItem.ToString() == "On")
                {
                    on = true;
                }

                DAO.Insert(selectedItem, unitId, on, scheduleId);

                HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Ejemplo n.º 3
0
 private void BuldUpdateScheduleDevice()
 {
     foreach (DataGridViewRow deviceRow in grdChildTwo.Rows)
     {
         lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
         deviceDAO.ConnectionString = _connectionString;
         deviceDAO.Update(int.Parse(deviceRow.Cells[0].Value.ToString()), 0, 0,
                          Convert.ToBoolean(deviceRow.Cells[3].Value.ToString()));
     }
 }
Ejemplo n.º 4
0
        private void GetScheduleUnitDetails(List <lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits, int scheduleId, int defaultPort)
        {
            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleUnit in scheduleUnits)
            {
                string address = scheduleUnit.Address;

                lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                deviceDAO.ConnectionString = _connectionString;

                List <lfa.pmgmt.data.DTO.Schedule.Device> unitDevices = deviceDAO.ListById(scheduleUnit.Id, scheduleId);

                LoadShedUnit(unitDevices, defaultPort, scheduleUnit);
            }
        }
Ejemplo n.º 5
0
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox3.SelectedItem as ComboItem;
            int       unitId       = selectedItem.Id;

            dataGridView1.DataSource = null;

            if (unitId > -1)
            {
                lfa.pmgmt.data.DAO.Schedule.Device scheduleDeviceDAO = new data.DAO.Schedule.Device();
                scheduleDeviceDAO.ConnectionString = _connectionString;

                List <lfa.pmgmt.data.DTO.Schedule.Device> scheduleDevices = scheduleDeviceDAO.ListById(unitId, _scheduleId);

                if (scheduleDevices.Count > 0)
                {
                    dataGridView1.DataSource = scheduleDevices;

                    ComboBox cmbStatus = new ComboBox();
                    cmbStatus.Items.Add("On");
                    cmbStatus.Items.Add("Off");

                    DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn();
                    comboBoxColumn.Items.Add("On");
                    comboBoxColumn.Items.Add("Off");
                    dataGridView1.Columns.Add(comboBoxColumn);

                    foreach (DataGridViewRow scheduleRow in dataGridView1.Rows)
                    {
                        if (Convert.ToBoolean(scheduleRow.Cells[3].Value.ToString()))
                        {
                            scheduleRow.Cells[4].Value = "On";
                        }
                        else
                        {
                            scheduleRow.Cells[4].Value = "Off";
                        }
                    }

                    dataGridView1.Columns[0].Visible = false;
                    dataGridView1.Columns[2].Visible = false;
                    dataGridView1.Columns[3].Visible = false;

                    dataGridView1.Columns[1].Width = 273;
                    dataGridView1.Columns[4].Width = 100;
                }
            }
        }
Ejemplo n.º 6
0
        private void button4_Click(object sender, EventArgs e)
        {
            switch (_currentModule)
            {
            case "LoadShed":
                HandleInformationMesssage("Load shedding data can not deleted! Data is only for control purposes!");
                break;

            case "Configuration":
                try
                {
                    int selectedDeviceId = int.Parse(grdChildTwo.SelectedRows[0].Cells[0].Value.ToString());

                    lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                    deviceDAO.ConnectionString = _connectionString;
                    deviceDAO.Delete(selectedDeviceId);

                    HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                break;

            case "Schedule":
                try
                {
                    int s_selectedDeviceId = int.Parse(grdChildTwo.SelectedRows[0].Cells[0].Value.ToString());

                    lfa.pmgmt.data.DAO.Schedule.Device scheduleDAO = new data.DAO.Schedule.Device();
                    scheduleDAO.ConnectionString = _connectionString;
                    scheduleDAO.Delete(s_selectedDeviceId);

                    HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                break;
            }
        }
        private void Frm_AddNew_Unit_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Schedule.Device scheduleDAO = new data.DAO.Schedule.Device();
            scheduleDAO.ConnectionString = _connectionString;
            int s_unitId = scheduleDAO.GetUnitId(unitId);

            lfa.pmgmt.data.DAO.Configuration.Device DAO = new data.DAO.Configuration.Device();
            DAO.ConnectionString = _connectionString;
            List<lfa.pmgmt.data.DTO.Configuration.Device> scheduleList = DAO.List(unitId);

            foreach (lfa.pmgmt.data.DTO.Configuration.Device scheduleItem in scheduleList)
            {
                ComboItem item = new ComboItem();
                item.Id = scheduleItem.Id;
                item.Name = scheduleItem.Name;

                comboBox1.Items.Add(item);
            }

            comboBox2.Items.Add("On");
            comboBox2.Items.Add("Off");
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                bool on = false;
                ComboItem item = comboBox1.SelectedItem as ComboItem;
                int selectedItem = item.Id;
                lfa.pmgmt.data.DAO.Schedule.Device DAO = new data.DAO.Schedule.Device();
                DAO.ConnectionString = _connectionString;

                if (comboBox2.SelectedItem.ToString() == "On")
                    on = true;

                DAO.Insert(selectedItem,unitId, on, scheduleId);

                HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

                this.Close();
             }
             catch (Exception ex)
             {
                HandleException(ex);
             }
        }
        private void Frm_AddNew_Unit_Load_1(object sender, EventArgs e)
        {
            _connectionString = GetConnectionString();

            lfa.pmgmt.data.DAO.Schedule.Device scheduleDAO = new data.DAO.Schedule.Device();
            scheduleDAO.ConnectionString = _connectionString;
            int s_unitId = scheduleDAO.GetUnitId(unitId);

            lfa.pmgmt.data.DAO.Configuration.Device DAO = new data.DAO.Configuration.Device();
            DAO.ConnectionString = _connectionString;
            List <lfa.pmgmt.data.DTO.Configuration.Device> scheduleList = DAO.List(unitId);

            foreach (lfa.pmgmt.data.DTO.Configuration.Device scheduleItem in scheduleList)
            {
                ComboItem item = new ComboItem();
                item.Id   = scheduleItem.Id;
                item.Name = scheduleItem.Name;

                comboBox1.Items.Add(item);
            }

            comboBox2.Items.Add("On");
            comboBox2.Items.Add("Off");
        }
Ejemplo n.º 10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region OLD CODE
                //ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;

                //int zoneId = selectedItem.Id;
                //bool status = false;

                //if (comboBox2.SelectedItem.ToString() == "On")
                //{
                //    status = true;
                //}

                //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);
                //}
                #endregion

                foreach (DataGridViewRow dataRow in dataGridView1.Rows)
                {
                    lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                    deviceDAO.ConnectionString = _connectionString;

                    if (dataRow.Cells[4].Value.ToString() == "Off")
                    {
                        deviceDAO.Update(int.Parse(dataRow.Cells[0].Value.ToString()), 0, 0,
                                         false);
                    }
                    else
                    {
                        deviceDAO.Update(int.Parse(dataRow.Cells[0].Value.ToString()), 0, 0,
                                         true);
                    }
                }

                HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

                this.Close();
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }
        }
Ejemplo n.º 11
0
        private void grdChildOne_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                case "Configuration":
                    _loadComplete = false;

                    DataGridViewRow selectedRow = grdChildOne.SelectedRows[0];
                    _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString());

                    lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                    deviceDAO.ConnectionString = _connectionString;
                    List <lfa.pmgmt.data.DTO.Configuration.Device> list = deviceDAO.List(_selectedItemDataId);

                    grdChildTwo.DataSource = list;

                    grdChildTwo.Columns[0].Visible = false;
                    grdChildTwo.Columns[1].Visible = false;

                    grdChildTwo.Columns[5].ReadOnly = true;

                    _loadComplete = true;
                    break;

                case "Schedule":
                    _loadComplete = false;

                    DataGridViewRow s_selectedRow = grdChildOne.SelectedRows[0];
                    _selectedItemDataId = int.Parse(s_selectedRow.Cells[0].Value.ToString());

                    int selectedSchedule = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                    lfa.pmgmt.data.DAO.Schedule.Device s_deviceDAO = new data.DAO.Schedule.Device();
                    s_deviceDAO.ConnectionString = _connectionString;
                    List <lfa.pmgmt.data.DTO.Schedule.Device> s_list = s_deviceDAO.ListWithSwitch(_selectedItemDataId, selectedSchedule);

                    grdChildTwo.Columns.Clear();

                    grdChildTwo.DataSource = s_list;

                    grdChildTwo.Columns[0].Visible = false;

                    _loadComplete = true;
                    break;

                case "LoadShed":
                    _loadComplete = false;

                    DataGridViewRow ls_selectedRow = grdChildOne.SelectedRows[0];
                    _selectedItemDataId = int.Parse(ls_selectedRow.Cells[0].Value.ToString());

                    lfa.pmgmt.data.DAO.Configuration.Device ls_deviceDAO = new data.DAO.Configuration.Device();
                    ls_deviceDAO.ConnectionString = _connectionString;
                    List <lfa.pmgmt.data.DTO.Configuration.LoadShedDevice> ls_list = ls_deviceDAO.ListLoadShed(_selectedItemDataId);

                    grdChildTwo.Columns.Clear();

                    grdChildTwo.DataSource = ls_list;

                    grdChildTwo.Columns[0].Visible = false;
                    grdChildTwo.Columns[2].Visible = false;
                    grdChildTwo.Columns[3].Visible = false;
                    grdChildTwo.Columns[4].Visible = false;

                    ComboBox cmbStatus = new ComboBox();
                    cmbStatus.Items.Add("On");
                    cmbStatus.Items.Add("Off");

                    DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn();
                    comboBoxColumn.Items.Add("On");
                    comboBoxColumn.Items.Add("Off");
                    grdChildTwo.Columns.Add(comboBoxColumn);

                    foreach (DataGridViewRow dgvRow in grdChildTwo.Rows)
                    {
                        dgvRow.Cells[5].Value = dgvRow.Cells[4].Value;
                    }

                    btnLoadShed.Visible = true;

                    _loadComplete = true;
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        private void GetScheduleUnitDetails(List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits, int scheduleId,
                                            int defaultPort, int status)
        {
            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleUnit in scheduleUnits)
            {
                string address = scheduleUnit.Address;

                lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                deviceDAO.ConnectionString = _connectionString;

                List<lfa.pmgmt.data.DTO.Schedule.Device> unitDevices = deviceDAO.ListById(scheduleUnit.Id, scheduleId);

                ArrayList parameters = new ArrayList();
                parameters.Add(unitDevices);
                parameters.Add(defaultPort);
                parameters.Add(scheduleUnit);
                parameters.Add(status);

                //AsyncLoadShedUnit(parameters);

                 Thread worker = new Thread(new ParameterizedThreadStart(AsyncLoadShedUnit));
                 worker.Start(parameters);

            }
        }
Ejemplo n.º 13
0
        private void grdChildOne_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                    case "Configuration":
                        _loadComplete = false;

                         DataGridViewRow selectedRow = grdChildOne.SelectedRows[0];
                        _selectedItemDataId = int.Parse(selectedRow.Cells[0].Value.ToString());

                         lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                        deviceDAO.ConnectionString = _connectionString;
                        List<lfa.pmgmt.data.DTO.Configuration.Device> list = deviceDAO.List(_selectedItemDataId);

                        grdChildTwo.DataSource = list;

                        grdChildTwo.Columns[0].Visible = false;
                        grdChildTwo.Columns[1].Visible = false;

                        grdChildTwo.Columns[5].ReadOnly = true;

                        _loadComplete = true;
                        break;
                    case "Schedule":
                         _loadComplete = false;

                         DataGridViewRow s_selectedRow = grdChildOne.SelectedRows[0];
                        _selectedItemDataId = int.Parse(s_selectedRow.Cells[0].Value.ToString());

                        int selectedSchedule = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                         lfa.pmgmt.data.DAO.Schedule.Device s_deviceDAO = new data.DAO.Schedule.Device();
                        s_deviceDAO.ConnectionString = _connectionString;
                        List<lfa.pmgmt.data.DTO.Schedule.Device> s_list = s_deviceDAO.ListWithSwitch(_selectedItemDataId,selectedSchedule);

                        grdChildTwo.Columns.Clear();

                        grdChildTwo.DataSource = s_list;

                        grdChildTwo.Columns[0].Visible = false;

                        _loadComplete = true;
                        break;
                    case "LoadShed":
                        _loadComplete = false;

                        DataGridViewRow ls_selectedRow = grdChildOne.SelectedRows[0];
                        _selectedItemDataId = int.Parse(ls_selectedRow.Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Configuration.Device ls_deviceDAO = new data.DAO.Configuration.Device();
                        ls_deviceDAO.ConnectionString = _connectionString;
                        List<lfa.pmgmt.data.DTO.Configuration.LoadShedDevice> ls_list = ls_deviceDAO.ListLoadShed(_selectedItemDataId);

                        grdChildTwo.Columns.Clear();

                        grdChildTwo.DataSource = ls_list;

                        grdChildTwo.Columns[0].Visible = false;
                        grdChildTwo.Columns[2].Visible = false;
                        grdChildTwo.Columns[3].Visible = false;
                        grdChildTwo.Columns[4].Visible = false;

                        ComboBox cmbStatus = new ComboBox();
                        cmbStatus.Items.Add("On");
                        cmbStatus.Items.Add("Off");

                        DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn();
                        comboBoxColumn.Items.Add("On");
                        comboBoxColumn.Items.Add("Off");
                        grdChildTwo.Columns.Add(comboBoxColumn);

                        foreach(DataGridViewRow dgvRow in grdChildTwo.Rows)
                        {
                            dgvRow.Cells[5].Value = dgvRow.Cells[4].Value;
                        }

                        btnLoadShed.Visible = true;

                        _loadComplete = true;
                        break;
                }
            }
        }
Ejemplo n.º 14
0
        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);
            }
        }
Ejemplo n.º 15
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
            int       zoneId       = selectedItem.Id;

            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
            unitDAO.ConnectionString = _connectionString;
            List <lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO.ListWithZone(_scheduleId);

            lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
            deviceDAO.ConnectionString = _connectionString;

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
            {
                if (unit.Id_Zone == zoneId)
                {
                    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":
                            checkBox1.Checked = device.DeviceOn;
                            break;

                        case "Switch 2":
                            checkBox2.Checked = device.DeviceOn;
                            break;

                        case "Switch 3":
                            checkBox3.Checked = device.DeviceOn;
                            break;

                        case "Switch 4":
                            checkBox4.Checked = device.DeviceOn;
                            break;

                        case "Switch 5":
                            checkBox5.Checked = device.DeviceOn;
                            break;

                        case "Switch 6":
                            checkBox6.Checked = device.DeviceOn;
                            break;

                        case "Switch 7":
                            checkBox7.Checked = device.DeviceOn;
                            break;

                        case "Switch 8":
                            checkBox8.Checked = device.DeviceOn;
                            break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void GetScheduleUnitDetailsForId(List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits, int scheduleId,
                                                List<int> ruleEnabledUnits, int defaultPort, int status)
        {
            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleUnit in scheduleUnits)
            {
                string address = scheduleUnit.Address;

                lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                deviceDAO.ConnectionString = _connectionString;

                if (!ruleEnabledUnits.Contains(scheduleUnit.Id))
                {
                    List<lfa.pmgmt.data.DTO.Schedule.Device> unitDevices = deviceDAO.List(scheduleUnit.Id, scheduleId);

                    ArrayList parameters = new ArrayList();
                    parameters.Add(unitDevices);
                    parameters.Add(defaultPort);
                    parameters.Add(scheduleUnit);
                    parameters.Add(status);

                    Thread worker = new Thread(new ParameterizedThreadStart(AsyncLoadShedUnit));
                    worker.IsBackground = true;
                    worker.Start(parameters);
                }
            }
        }
Ejemplo n.º 17
0
 private void BuldUpdateScheduleDevice()
 {
     foreach (DataGridViewRow deviceRow in grdChildTwo.Rows)
     {
         lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
         deviceDAO.ConnectionString = _connectionString;
         deviceDAO.Update(int.Parse(deviceRow.Cells[0].Value.ToString()), 0, 0,
                          Convert.ToBoolean(deviceRow.Cells[3].Value.ToString()));
     }
 }
Ejemplo n.º 18
0
        private void button4_Click(object sender, EventArgs e)
        {
            switch (_currentModule)
            {
                case "LoadShed":
                    HandleInformationMesssage("Load shedding data can not deleted! Data is only for control purposes!");
                    break;
                case "Configuration":
                    try
                    {
                        int selectedDeviceId = int.Parse(grdChildTwo.SelectedRows[0].Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Configuration.Device deviceDAO = new data.DAO.Configuration.Device();
                        deviceDAO.ConnectionString = _connectionString;
                        deviceDAO.Delete(selectedDeviceId);

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;
                case "Schedule":
                    try
                    {
                        int s_selectedDeviceId = int.Parse(grdChildTwo.SelectedRows[0].Cells[0].Value.ToString());

                        lfa.pmgmt.data.DAO.Schedule.Device scheduleDAO = new data.DAO.Schedule.Device();
                        scheduleDAO.ConnectionString = _connectionString;
                        scheduleDAO.Delete(s_selectedDeviceId);

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;
            }
        }
Ejemplo n.º 19
0
        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox3.SelectedItem as ComboItem;
            int unitId = selectedItem.Id;

            dataGridView1.DataSource = null;

            if (unitId > -1)
            {
                lfa.pmgmt.data.DAO.Schedule.Device scheduleDeviceDAO = new data.DAO.Schedule.Device();
                scheduleDeviceDAO.ConnectionString = _connectionString;

                List<lfa.pmgmt.data.DTO.Schedule.Device> scheduleDevices = scheduleDeviceDAO.ListById(unitId, _scheduleId);

                if (scheduleDevices.Count > 0)
                {
                    dataGridView1.DataSource = scheduleDevices;

                    ComboBox cmbStatus = new ComboBox();
                    cmbStatus.Items.Add("On");
                    cmbStatus.Items.Add("Off");

                    DataGridViewComboBoxColumn comboBoxColumn = new DataGridViewComboBoxColumn();
                    comboBoxColumn.Items.Add("On");
                    comboBoxColumn.Items.Add("Off");
                    dataGridView1.Columns.Add(comboBoxColumn);

                    foreach (DataGridViewRow scheduleRow in dataGridView1.Rows)
                    {
                       if (Convert.ToBoolean(scheduleRow.Cells[3].Value.ToString()))
                       {
                          scheduleRow.Cells[4].Value = "On";
                       }
                       else
                       {
                          scheduleRow.Cells[4].Value = "Off";
                       }
                    }

                    dataGridView1.Columns[0].Visible = false;
                    dataGridView1.Columns[2].Visible = false;
                    dataGridView1.Columns[3].Visible = false;

                    dataGridView1.Columns[1].Width = 273;
                    dataGridView1.Columns[4].Width = 100;
                }
            }
        }
Ejemplo n.º 20
0
        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);
            }
        }
Ejemplo n.º 21
0
        private void GetScheduleUnitDetailsForId(List<lfa.pmgmt.data.DTO.Schedule.Unit> scheduleUnits, int scheduleId,
                                                List<int> ruleEnabledUnits, int defaultPort)
        {
            foreach (lfa.pmgmt.data.DTO.Schedule.Unit scheduleUnit in scheduleUnits)
            {
                string address = scheduleUnit.Address;

                lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                deviceDAO.ConnectionString = _connectionString;

                if (!ruleEnabledUnits.Contains(scheduleUnit.Id))
                {
                    List<lfa.pmgmt.data.DTO.Schedule.Device> unitDevices = deviceDAO.List(scheduleUnit.Id, scheduleId);

                    LoadShedUnit(unitDevices, defaultPort,scheduleUnit);
                }
            }
        }
Ejemplo n.º 22
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                #region OLD CODE
                //ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;

                //int zoneId = selectedItem.Id;
                //bool status = false;

                //if (comboBox2.SelectedItem.ToString() == "On")
                //{
                //    status = true;
                //}

                //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);
                //}
                #endregion

                foreach (DataGridViewRow dataRow in dataGridView1.Rows)
                {
                    lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
                    deviceDAO.ConnectionString = _connectionString;

                    if (dataRow.Cells[4].Value.ToString() == "Off")
                    {
                        deviceDAO.Update(int.Parse(dataRow.Cells[0].Value.ToString()), 0, 0,
                                         false);
                    }
                    else
                    {
                        deviceDAO.Update(int.Parse(dataRow.Cells[0].Value.ToString()), 0, 0,
                                         true);
                    }
                }

                HandleInformationMesssage("Data successfully saved! Please refresh the form data!");

               this.Close();
            }
            catch (Exception ex)
            {
               HandleException(ex);
            }
        }
Ejemplo n.º 23
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboItem selectedItem = comboBox1.SelectedItem as ComboItem;
            int zoneId = selectedItem.Id;

            lfa.pmgmt.data.DAO.Schedule.Unit unitDAO = new data.DAO.Schedule.Unit();
            unitDAO.ConnectionString = _connectionString;
            List<lfa.pmgmt.data.DTO.Schedule.Unit> unitList = unitDAO.ListWithZone(_scheduleId);

            lfa.pmgmt.data.DAO.Schedule.Device deviceDAO = new data.DAO.Schedule.Device();
            deviceDAO.ConnectionString = _connectionString;

            foreach (lfa.pmgmt.data.DTO.Schedule.Unit unit in unitList)
            {
                if (unit.Id_Zone == zoneId)
                {
                    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":
                                checkBox1.Checked = device.DeviceOn;
                                break;
                            case "Switch 2":
                                checkBox2.Checked = device.DeviceOn;
                                break;
                            case "Switch 3":
                                checkBox3.Checked = device.DeviceOn;
                                break;
                            case "Switch 4":
                                checkBox4.Checked = device.DeviceOn;
                                break;
                            case "Switch 5":
                                checkBox5.Checked = device.DeviceOn;
                                break;
                            case "Switch 6":
                                checkBox6.Checked = device.DeviceOn;
                                break;
                            case "Switch 7":
                                checkBox7.Checked = device.DeviceOn;
                                break;
                            case "Switch 8":
                                checkBox8.Checked = device.DeviceOn;
                                break;
                        }
                    }
                }
            }
        }