Exemplo n.º 1
0
        private void Search_button_Click(object sender, EventArgs e)
        {
            Data.Rows.Clear();
            NPOImethods methods = new NPOImethods();

            List <string> keys = new List <string>();

            keys = textForSearch.Text.Split(' ').ToList();
            if (keys.Count == 0)
            {
                MessageBox.Show(text: "Введите данные для поиска");
            }
            else
            {
                HashSet <int> indexes = new HashSet <int>();
                indexes = methods.SearchElement(keys);
                if (indexes.Count == 0)
                {
                    MessageBox.Show(text: "Ничего не найдено!");
                    loadData();
                }
                else
                {
                    foreach (int index in indexes)
                    {
                        Data.Rows.Add(methods.GetRowByIndex(index));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void loadData()
        {
            Data.Rows.Clear();
            Data.Columns.Clear();
            NPOImethods     methods = new NPOImethods();
            List <string[]> table   = new List <string[]>();

            methods.GetStringArray(table);
            for (int i = 0; i < methods.ColumsCnt; i++)
            {
                Data.Columns.Add(methods.header[i], methods.header[i]);
            }
            foreach (string[] i in table)
            {
                Data.Rows.Add(i);
            }

            Data.BorderStyle = BorderStyle.None;
            Data.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            Data.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            Data.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            Data.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            Data.BackgroundColor = Color.White;

            Data.EnableHeadersVisualStyles = false;
            Data.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
            Data.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
            Data.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
        }
Exemplo n.º 3
0
        private void AddBookButton_Click(object sender, EventArgs e)
        {
            NPOImethods file = new NPOImethods();

            string[] book = new string[file.ColumsCnt];
            for (int i = 0; i < TextboxList.Count; i++)
            {
                book[i] = TextboxList[i].Text.ToString();
                if ((i == file.BookNameRow || i == file.AuthorRow) && (book[i] == "*" || book[i] == ""))
                {
                    MessageBox.Show(caption: "Внимание!", text: "Не все основные поля заполнены", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Warning);
                    return;
                }
            }
            book[TextboxList.Count] = (InLibrary_chkbox.Checked ? "Да" : "Нет");
            FormatInput formatInput = new FormatInput();

            file.Add(formatInput.format(book));
            MessageBox.Show(text: "Добавлено!", caption: "Статус", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information);
            for (int i = 0; i < TextboxList.Count; i++)
            {
                if (i == file.BookNameRow || i == file.AuthorRow)
                {
                    TextboxList[i].Text = "*";
                }
                else
                {
                    TextboxList[i].Clear();
                }
            }
            InLibrary_chkbox.Checked = false;
        }
Exemplo n.º 4
0
        private void BeSafe(object sender, EventArgs e)
        {
            Parametrs parametrs = new Parametrs();

            if (File.Exists(parametrs.path) == false)
            {
                NPOImethods methods = new NPOImethods();
                methods.CreateBlank();
            }
        }
Exemplo n.º 5
0
 private void ОтчиститьБазуДанныхToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (CustomMessageBox.ShowOKCancel("Вы действительно хотите безвозвратно удалить базу данных Вашей библиотеки?", "Предупреждение", "Удалить", "Отменить") == MessageBoxResult.OK)
     {
         NPOImethods methods = new NPOImethods();
         methods.CreateBlank();
         MessageBox.Show("База данных удалена");
     }
     else
     {
         MessageBox.Show("База данных не удалена");
     }
 }
Exemplo n.º 6
0
        private void SaveEdits()
        {
            if (CustomMessageBox.ShowOKCancel("Вы действительно хотите сохранить изменения?", "Предупреждение", "Сохранить", "Отменить") == MessageBoxResult.OK)
            {
                NPOImethods methods = new NPOImethods();
                for (int i = 0; i < Data.Rows.Count; i++)
                {
                    string[] currentRow = new string[methods.ColumsCnt];
                    for (int j = 0; j < methods.ColumsCnt; j++)
                    {
                        currentRow[j] = Data.Rows[i].Cells[j].Value.ToString();
                    }

                    methods.SetNewValueInRow(currentRow, i + methods.startRow);
                }
                SaveEdits_button.Enabled = false;
                Abort_button.Enabled     = false;
            }
            else
            {
                loadData();
            }
        }