Пример #1
0
 private void UpdateForm()
 {
     Title           = titleTextBox.Text;
     Author          = authorTextBox.Text;
     Publisher       = publisherTextBox.Text;
     Year            = Convert.ToInt32(yearNumericUpDown.Value);
     Quality         = qualityTextBox.Text;
     Price           = Convert.ToSingle(priceNumericUpDown.Value);
     button1.Enabled = InputValidator.validateTitle(Title) &&
                       InputValidator.validateAuthor(Author) &&
                       InputValidator.validatePublisher(Publisher) &&
                       InputValidator.validateYear(Year) &&
                       InputValidator.validateQuality(Quality) &&
                       InputValidator.validatePrice(Price);
 }
Пример #2
0
        private void UpdateForm()
        {
            if (this.tabControl1.SelectedTab == this.yearTabPage)
            {
                YearMinimum = this.lessRadioButton.Checked ? InputValidator.YearMinimum : Convert.ToInt32(yearNumericUpDown.Value);
                YearMaximum = this.moreRadioButton.Checked ? InputValidator.YearMaximum : Convert.ToInt32(yearNumericUpDown.Value);
            }
            else if (this.tabControl1.SelectedTab == this.rangeTabPage)
            {
                YearMinimum = Convert.ToInt32(fromNumericUpDown.Value);
                YearMaximum = Convert.ToInt32(toNumericUpDown.Value);
            }

            this.button1.Enabled = InputValidator.validateYear(YearMinimum) &&
                                   InputValidator.validateYear(YearMaximum) &&
                                   (YearMinimum <= YearMaximum);
        }
Пример #3
0
        private void UpdateForm()
        {
            if (this.tabControl1.SelectedTab == this.yearTabPage)
            {
                PriceMinimum = this.lessRadioButton.Checked ? InputValidator.PriceMinimum : Convert.ToSingle(Math.Round(priceNumericUpDown.Value, 2));
                PriceMaximum = this.moreRadioButton.Checked ? InputValidator.PriceMaximum : Convert.ToSingle(Math.Round(priceNumericUpDown.Value, 2));
            }
            else if (this.tabControl1.SelectedTab == this.rangeTabPage)
            {
                PriceMinimum = Convert.ToSingle(Math.Round(fromNumericUpDown.Value, 2));
                PriceMaximum = Convert.ToSingle(Math.Round(toNumericUpDown.Value, 2));
            }

            this.button1.Enabled = InputValidator.validatePrice(PriceMinimum) &&
                                   InputValidator.validatePrice(PriceMaximum) &&
                                   (PriceMinimum <= PriceMaximum);
        }
Пример #4
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.RowIndex >= 0)
            {
                Book book = BookManager.Main.GetBook(
                    dataGridView1.Rows[e.RowIndex].Cells["ID"].Value.ToString());
                if (book != null)
                {
                    var propertyInfo = typeof(Book)
                                       .GetProperty(senderGrid.Columns[e.ColumnIndex].Name);
                    object cellValue =
                        dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
                    try
                    {
                        if (cellValue == null)
                        {
                            throw new Exception("Значение не может быть null");
                        }
                        object validatedCellValue = null;
                        string cellText           = cellValue.ToString();
                        switch (senderGrid.Columns[e.ColumnIndex].Name)
                        {
                        case "Title":
                        {
                            validatedCellValue = InputValidator.parseTitle(cellText);
                        }
                        break;

                        case "Author":
                        {
                            validatedCellValue = InputValidator.parseAuthor(cellText);
                        }
                        break;

                        case "Publisher":
                        {
                            validatedCellValue = InputValidator.parsePublisher(cellText);
                        }
                        break;

                        case "Year":
                        {
                            validatedCellValue = InputValidator.parseYear(cellText);
                        }
                        break;

                        case "Quality":
                        {
                            validatedCellValue = InputValidator.parseQuality(cellText);
                        }
                        break;

                        case "Price":
                        {
                            validatedCellValue = InputValidator.parsePrice(cellText);
                        }
                        break;
                        }

                        if (validatedCellValue != null && validatedCellValue.ToString() != propertyInfo.GetValue(book).ToString())
                        {
                            if (Authorization.Main.Request())
                            {
                                propertyInfo.SetValue(book, cellText);
                                BookManager.Main.Save();
                            }

                            this.BeginInvoke(new MethodInvoker(() =>
                            {
                                displayBookAt(e.RowIndex, book);
                            }));
                        }
                    } catch (ArgumentException exception)
                    {
                        dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].ErrorText = exception.Message;
                    } catch (Exception exception)
                    {
                        MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        this.BeginInvoke(new MethodInvoker(() =>
                        {
                            displayBookAt(e.RowIndex, book);
                        }));
                    }
                }
            }
        }
 private void UpdateForm()
 {
     Quality         = comboBox1.Text;
     button1.Enabled = InputValidator.validateQuality(Quality);
 }
 private void UpdateForm()
 {
     Publisher       = textBox1.Text;
     button1.Enabled = InputValidator.validatePublisher(Publisher);
 }
Пример #7
0
 private void UpdateForm()
 {
     Author          = textBox1.Text;
     button1.Enabled = InputValidator.validateAuthor(Author);
 }
Пример #8
0
 private void UpdateForm()
 {
     Title           = textBox1.Text;
     button1.Enabled = InputValidator.validateTitle(Title);
 }