Esempio n. 1
0
        private void btnGridChildTwo_AddNew_Click(object sender, EventArgs e)
        {
            try
            {
                _selectedItemDataId = int.Parse(grdChildOne.SelectedRows[0].Cells[0].Value.ToString());

                switch (_currentModule)
                {
                    case "Configuration":
                        if (grdChildOne.SelectedRows.Count <= 0)
                        {
                            Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                            HandleException(ex);
                        }
                        else
                        {
                            if (_selectedItemDataId > 0)
                            {
                                Forms.Frm_AddNew_Device frmAddNewDevice = new Forms.Frm_AddNew_Device(_selectedItemDataId);
                                frmAddNewDevice.ShowDialog();
                            }
                            else
                            {
                                Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                                HandleException(ex);
                            }
                        }
                        break;
                    case "Schedule":
                        if (grdChildOne.SelectedRows.Count <= 0)
                        {
                            Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                            HandleException(ex);
                        }
                        else
                        {
                            if (_selectedItemDataId > 0)
                            {
                                int selectedSchedule = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());
                                Forms.Frm_AddNew_ScheduleDevice frmAddNewScheduleDevice = new Forms.Frm_AddNew_ScheduleDevice(_selectedItemDataId, selectedSchedule);
                                frmAddNewScheduleDevice.ShowDialog();
                            }
                            else
                            {
                                Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                                HandleException(ex);
                            }
                        }
                        break;
                    case "LoadShed":
                        HandleInformationMesssage("Load shedding data can not be saved! Data is only for control purposes!");
                        break;
                    case "Rules":
                        HandleInformationMesssage("This action is disabled for power management rules!");
                        break;
                }
            }
            catch
            {
                Exception ex = new Exception("There are either no item selected in the previous grid, or there are no data available to allow this action!");
                HandleException(ex);
            }
        }
Esempio n. 2
0
        private void btnGridChildTwo_AddNew_Click(object sender, EventArgs e)
        {
            try
            {
                _selectedItemDataId = int.Parse(grdChildOne.SelectedRows[0].Cells[0].Value.ToString());

                switch (_currentModule)
                {
                case "Configuration":
                    if (grdChildOne.SelectedRows.Count <= 0)
                    {
                        Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                        HandleException(ex);
                    }
                    else
                    {
                        if (_selectedItemDataId > 0)
                        {
                            Forms.Frm_AddNew_Device frmAddNewDevice = new Forms.Frm_AddNew_Device(_selectedItemDataId);
                            frmAddNewDevice.ShowDialog();
                        }
                        else
                        {
                            Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                            HandleException(ex);
                        }
                    }
                    break;

                case "Schedule":
                    if (grdChildOne.SelectedRows.Count <= 0)
                    {
                        Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                        HandleException(ex);
                    }
                    else
                    {
                        if (_selectedItemDataId > 0)
                        {
                            int selectedSchedule = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());
                            Forms.Frm_AddNew_ScheduleDevice frmAddNewScheduleDevice = new Forms.Frm_AddNew_ScheduleDevice(_selectedItemDataId, selectedSchedule);
                            frmAddNewScheduleDevice.ShowDialog();
                        }
                        else
                        {
                            Exception ex = new Exception("Please select a unit from the panel panel on the left!");
                            HandleException(ex);
                        }
                    }
                    break;

                case "LoadShed":
                    HandleInformationMesssage("Load shedding data can not be saved! Data is only for control purposes!");
                    break;

                case "Rules":
                    HandleInformationMesssage("This action is disabled for power management rules!");
                    break;
                }
            }
            catch
            {
                Exception ex = new Exception("There are either no item selected in the previous grid, or there are no data available to allow this action!");
                HandleException(ex);
            }
        }