コード例 #1
0
        static public void Sort()
        {
            int[] sortedArrByIndexes = new int[strs.Length];
            switch (st)
            {
            case SortType.lettersCount:
            {
                sortedArrByIndexes = SortingTypes.CountByLettersA(strs);
                break;
            }

            case SortType.lineLength:
            {
                sortedArrByIndexes = SortingTypes.CountByLength(strs);
                break;
            }

            case SortType.wordsCount:
            {
                sortedArrByIndexes = SortingTypes.CountByWords(strs);
                break;
            }

            case SortType.signsCount:
            {
                sortedArrByIndexes = SortingTypes.CountByPunctSings(strs);
                break;
            }

            case SortType.wordsDigitCount:
            {
                sortedArrByIndexes = SortingTypes.CountByWordsDigit(strs);
                break;
            }

            default:
                break;
            }

            switch (sm)
            {
            case SortMethod.bubble:
            {
                Sorting.BubbleSort(strs, sortedArrByIndexes);
                break;
            }

            case SortMethod.insertion:
            {
                Sorting.InsertSort(strs, sortedArrByIndexes);
                break;
            }

            case SortMethod.selection:
            {
                Sorting.SelectionSort(strs, sortedArrByIndexes);

                break;
            }

            case SortMethod.shell:
            {
                Sorting.ShellSorting(strs, sortedArrByIndexes);
                break;
            }

            default:
                break;
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Add")
            {
                /*string get_current_data = "";
                 * foreach (string line in File.ReadLines(FORM1.database_source_file))
                 * {
                 *  if (line != "")
                 *  {
                 *      get_current_data = get_current_data + line + "\n";
                 *  }
                 * }*/

                List <string> addlist = new List <string> (new string[14]);

                textLOCATION.Text = CleanCommas(textLOCATION.Text);
                textTYPE.Text     = CleanCommas(textTYPE.Text);
                textNUMBER.Text   = CleanCommas(textNUMBER.Text);

                if (int.TryParse(textNUMBER.Text, out int testout) == false)
                {
                    textNUMBER.Text = "";
                }

                textMAC.Text        = CleanCommas(textMAC.Text);
                textMAKE.Text       = CleanCommas(textMAKE.Text);
                textMODEL.Text      = CleanCommas(textMODEL.Text);
                textVERSION.Text    = CleanCommas(textVERSION.Text);
                textSERIAL.Text     = CleanCommas(textSERIAL.Text);
                textOS.Text         = CleanCommas(textOS.Text);
                textUSER.Text       = CleanCommas(textUSER.Text);
                textDEPARTMENT.Text = CleanCommas(textDEPARTMENT.Text);
                textCOMMENTS.Text   = CleanCommas(textCOMMENTS.Text);

                addlist[0]  = textLOCATION.Text;
                addlist[1]  = textTYPE.Text;
                addlist[2]  = textNUMBER.Text;
                addlist[3]  = textMAC.Text;
                addlist[4]  = textMAKE.Text;
                addlist[5]  = textMODEL.Text;
                addlist[6]  = textVERSION.Text;
                addlist[7]  = textSERIAL.Text;
                addlist[8]  = textOS.Text;
                addlist[9]  = textUSER.Text;
                addlist[10] = textDEPARTMENT.Text;

                if (checkBox1.Checked == true)
                {
                    addlist[11] = "";
                }

                else
                {
                    addlist[11] = monthCalendar1.SelectionRange.Start.ToShortDateString();
                }

                addlist[12] = textCOMMENTS.Text;
                addlist[13] = comboRETIRED.Text;

                DM.inventory_database.Add(addlist);
                //FORM1.RefreshList();
                //FORM1.RefreshCombos();

                Sorting sortingnotification = new Sorting();
                sortingnotification.label1.Text = "Refreshing Inventory";
                sortingnotification.Show();
                sortingnotification.Refresh();
                sortingnotification.TopMost = true;
                sortingnotification.Activate();

                DatabaseManager dbm = new DatabaseManager();
                DM.inventory_database = dbm.SortDatabase(DM.inventory_database, FORM1.sort_mode);

                FORM1.RefreshCombos();
                FORM1.RefreshList();

                sortingnotification.Close();

                FORM1.changes_to_data = true;

                this.Close();
            }

            if (button1.Text == "Edit")
            {
                textLOCATION.Text = CleanCommas(textLOCATION.Text);
                textTYPE.Text     = CleanCommas(textTYPE.Text);
                textNUMBER.Text   = CleanCommas(textNUMBER.Text);

                if (int.TryParse(textNUMBER.Text, out int testout) == false)
                {
                    textNUMBER.Text = "";
                }

                textMAC.Text        = CleanCommas(textMAC.Text);
                textMAKE.Text       = CleanCommas(textMAKE.Text);
                textMODEL.Text      = CleanCommas(textMODEL.Text);
                textVERSION.Text    = CleanCommas(textVERSION.Text);
                textSERIAL.Text     = CleanCommas(textSERIAL.Text);
                textOS.Text         = CleanCommas(textOS.Text);
                textUSER.Text       = CleanCommas(textUSER.Text);
                textDEPARTMENT.Text = CleanCommas(textDEPARTMENT.Text);
                textCOMMENTS.Text   = CleanCommas(textCOMMENTS.Text);

                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][0]  = textLOCATION.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][1]  = textTYPE.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][2]  = textNUMBER.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][3]  = textMAC.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][4]  = textMAKE.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][5]  = textMODEL.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][6]  = textVERSION.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][7]  = textSERIAL.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][8]  = textOS.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][9]  = textUSER.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][10] = textDEPARTMENT.Text;

                if (checkBox1.Checked == true)
                {
                    DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][11] = "";
                }

                else
                {
                    DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][11] = monthCalendar1.SelectionRange.Start.ToShortDateString();
                }

                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][12] = textCOMMENTS.Text;
                DM.inventory_database[FORM1.listbox_tracker[FORM1.track_selected_index]][13] = comboRETIRED.Text;

                FORM1.RefreshList();
                FORM1.RefreshCombos();

                if (FORM1.dataOUTPUT.Rows.Count != 0)
                {
                    if (FORM1.track_selected_index == 0)
                    {
                        FORM1.track_selected_index = 0;
                    }

                    if (FORM1.dataOUTPUT.Rows.Count <= FORM1.track_selected_index)
                    {
                        FORM1.track_selected_index = FORM1.dataOUTPUT.Rows.Count - 1;
                    }

                    FORM1.dataOUTPUT.Rows[FORM1.track_selected_index].Cells[0].Selected = true;
                }

                FORM1.changes_to_data = true;
                this.Close();
            }
        }