示例#1
0
        private void DeleteSelectedTech()
        {
            if (SelectedTechID == 0)
            {
                return;
            }
            DialogResult result = MessageBox.Show(
                this, "Are you sure you wish to delete this tech " +
                "and all of its connections?", "Confirm Tech Deletion",
                MessageBoxButtons.OKCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }
            TechEditView deletor = new TechEditView(
                99999, SelectedTechID, TechEditView.ViewMode.EDITING);

            deletor.techListView = this;
            bool success = true;

            success &= deletor.DeletePrereqsOfOriginal();
            success &= deletor.DeleteGrantreqsOfOriginal();
            success &= deletor.DeletePermanizesOfOriginal();
            success &= deletor.DeletePrereqs();
            success &= deletor.DeleteGrantreqs();
            success &= deletor.DeletePermanizes();
            success &= deletor.DeleteOriginalTech();
            if (success)
            {
                Log("Tech deleted: " + HexConverter.IntToHex(SelectedTechID));
            }
            else
            {
                Log("Error(s) encountered during tech deletion. Check " +
                    "integrity of id " + HexConverter.IntToHex(SelectedTechID));
            }
            deletor.Dispose();
            RefreshList();
        }
示例#2
0
        private bool GetPermanizedBy()
        {
            bool         success = true;
            MySqlCommand command = new MySqlCommand();

            command.Connection  = connection;
            command.CommandText = "SELECT id FROM tech_permanizes " +
                                  "WHERE permanizes_id=" + techID + ";";
            command.CommandTimeout = 2;
            MySqlDataReader reader;

            connection.Open();
            try
            {
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    permanizedBy.Add(reader.GetUInt32(0));
                }
            }
            catch (MySqlException ex)
            {
                techListView.QuietLog("An error occurred while getting permanizedBy " +
                                      "for the graph view of tech with id " + HexConverter.IntToHex(techID) +
                                      ": " + ex.Message, command.CommandText);
                success = false;
            }
            catch (Exception ex)
            {
                techListView.QuietLog("An unknown error occurred while getting permanizedBy " +
                                      "for the graph view of tech with id " + HexConverter.IntToHex(techID) +
                                      ": " + ex.Message, command.CommandText);
                success = false;
            }
            finally
            {
                connection.Close();
            }
            return(success);
        }
示例#3
0
        private void FetchTechList(FilterOptions filters)
        {
            MySqlCommand command = new MySqlCommand();

            command.Connection  = connection;
            command.CommandText = "SELECT id,name,category " +
                                  "FROM tech ";

            //Structure the filter command conditions
            int numFilters = 0;

            if (filters.idRangeActive ||
                filters.categoryActive ||
                filters.fieldNameActive ||
                filters.nameStringMatchActive)
            {
                command.CommandText += "WHERE ";
            }
            if (filters.idRangeActive)
            {
                command.CommandText += "(id BETWEEN " + filters.idRangeMin +
                                       " AND " + filters.idRangeMax + ") ";
                numFilters++;
            }
            if (filters.categoryActive)
            {
                if (numFilters > 0)
                {
                    command.CommandText += "AND ";
                }
                command.CommandText += "category='" + filters.category + "' ";
                numFilters++;
            }
            if (filters.fieldNameActive)
            {
                if (numFilters > 0)
                {
                    command.CommandText += "AND ";
                }
                command.CommandText += "field_name LIKE '%" + filters.fieldName + "%' ";
                numFilters++;
            }
            if (filters.nameStringMatchActive)
            {
                if (numFilters > 0)
                {
                    command.CommandText += "AND ";
                }
                command.CommandText += "name LIKE '%" + filters.nameString + "%' ";
                numFilters++;
            }
            command.CommandText += "ORDER BY id ASC;";
            uint rowsFetched = 0;

            try
            {
                connection.Open();
                TechListGrid.Rows.Clear();
                MySqlDataReader reader = command.ExecuteReader();
                string[]        values = new string[3];
                while (reader.Read())
                {
                    values[0] = HexConverter.IntToHex(reader.GetUInt32(0));
                    values[1] = reader.GetString(1);
                    values[2] = reader.GetString(2);
                    TechListGrid.Rows.Add(values);
                    rowsFetched++;
                }
            }
            catch (MySqlException ex)
            {
                Log("An error occurred: " + ex.Message);
            }
            finally
            {
                connection.Close();
                Log("Fetched " + rowsFetched + " records.");
            }
        }