Esempio n. 1
0
        private void readerDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var readerRepository = new ReaderRepository();

            SelectedReader = readerRepository.FindById((int)readerDataGridView.SelectedRows[0].Cells[0].Value);
            this.Close();
        }
Esempio n. 2
0
        public void changeButton_Click(object sender, EventArgs e)
        {
            if (!(dataGridView1.SelectedRows.Count > 0))
            {
                return;
            }
            AddReaderForm    addReaderForm    = new AddReaderForm();
            ReaderRepository readerRepository = new ReaderRepository();

            int  index     = dataGridView1.SelectedRows[0].Index;
            int  id        = 0;
            bool converted = Int32.TryParse(dataGridView1[0, index].Value.ToString(), out id);

            if (converted == false)
            {
                return;
            }

            Reader reader = readerRepository.FindById(id);

            addReaderForm.nameTextBox.Text       = reader.Name;
            addReaderForm.surnameTextBox.Text    = reader.Surname;
            addReaderForm.patronymicTextBox.Text = reader.Patronymic;
            addReaderForm.dateTimePicker.Value   = reader.DateOfBirth;
            addReaderForm.emailTextBox.Text      = reader.Email;
            addReaderForm.telNumberTextBox.Text  = reader.TelephoneNumber;

            DialogResult dialogResult = addReaderForm.ShowDialog(this);

            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            string   name       = addReaderForm.nameTextBox.Text;
            string   surname    = addReaderForm.surnameTextBox.Text;
            string   patronymic = addReaderForm.patronymicTextBox.Text;
            DateTime DoB        = addReaderForm.dateTimePicker.Value;
            string   email      = addReaderForm.emailTextBox.Text;
            string   telNumber  = addReaderForm.telNumberTextBox.Text;


            reader.Name            = name;
            reader.Surname         = surname;
            reader.Patronymic      = patronymic;
            reader.DateOfBirth     = DoB;
            reader.Email           = email;
            reader.TelephoneNumber = telNumber;


            readerRepository.Update(reader);

            _db.SaveChanges();
            SetDataGridView();
        }
Esempio n. 3
0
        private void findByIdButton_Click(object sender, EventArgs e)
        {
            var readerRepository = new ReaderRepository();

            if (string.IsNullOrEmpty(idNumericUpDown.Value.ToString()))
            {
                SetDataGridView();
                return;
            }

            List <Reader> readers = new List <Reader>();
            Reader        reader  = readerRepository.FindById((int)idNumericUpDown.Value);

            readers.Add(reader);
            if (reader == null)
            {
                readerDataGridView.DataSource = "No readers found";
                return;
            }

            readerDataGridView.DataSource = readers;
        }