Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                case "Rules":

                    if (grdMain.SelectedRows.Count == 0)
                    {
                        Exception ex = new Exception("Please selected a ruleset to delete!");
                        HandleException(ex);
                    }
                    else
                    {
                        DeleteRuleset();
                    }
                    break;

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

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

                        lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                        zoneDAO.ConnectionString = _connectionString;
                        zoneDAO.Delete(selectedZoneId);

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

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

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

                        HandleInformationMesssage("Data successfully deleted! Please refresh the data!");
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }
                    break;
                }
            }
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (_loadComplete)
            {
                switch (_currentModule)
                {
                    case "Rules":

                        if (grdMain.SelectedRows.Count == 0)
                        {
                            Exception ex = new Exception("Please selected a ruleset to delete!");
                            HandleException(ex);
                        }
                        else
                        {
                            DeleteRuleset();
                        }
                        break;
                    case "LoadShed":
                        HandleInformationMesssage("Load shedding data can not be deleted! Data is only for control purposes!");
                       break;
                    case "Configuration":
                       try
                       {
                           int selectedZoneId = int.Parse(grdMain.SelectedRows[0].Cells[0].Value.ToString());

                           lfa.pmgmt.data.DAO.Configuration.Zone zoneDAO = new data.DAO.Configuration.Zone();
                           zoneDAO.ConnectionString = _connectionString;
                           zoneDAO.Delete(selectedZoneId);

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

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

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