Esempio n. 1
0
        private async void btnAddCustomer_Click(object sender, EventArgs e)
        {
            string name     = txtCustomerAddName.Text.Trim();
            string lastname = txtCustomerAddLastName.Text.Trim();
            string phone    = txtCustomerAddPhone.Text.Trim();
            string email    = txtCustomerAddEmail.Text.Trim();

            if (name == "" || lastname == "" || phone == "" || email == "")
            {
                MessageBox.Show("Please Fill All Inputs", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!email.IsMail())
            {
                MessageBox.Show("Write Email Address Correctly", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            Customer customer = new Customer()
            {
                Name = name, Lastname = lastname, Phone = phone, Email = email
            };

            _db.Customers.Add(customer);
            await _db.SaveChangesAsync();

            MessageBox.Show("Successfully Added", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);

            FillCmb(cmbUpdateCustomer);
            FillCmb(cmbDeleteCustomer);
        }
Esempio n. 2
0
        private async void btnBooksDelete_Click(object sender, EventArgs e)
        {
            int id   = ((CB_Genre)cmbBooksGenre.SelectedItem).Id;
            var book = _db.Books.FirstOrDefault(b => b.Deleted == false && b.GenreId == id);

            book.Deleted = true;

            await _db.SaveChangesAsync();

            MessageBox.Show("Deleted", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 3
0
        private async void btnAdminDelete_Click(object sender, EventArgs e)
        {
            string    email     = txtboxAdmin.Text.Trim();
            Librarian librarian = _db.Librarians.First(l => l.Email == email);

            librarian.Deleted = true;
            await _db.SaveChangesAsync();

            MessageBox.Show("Deleted");
            FillDgv();
            HideInputs();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string name             = txt_Name_Registration.Text.Trim();
            string surname          = txt_Surname_Registration.Text.Trim();
            string patronymic       = txt_Patronymic_Registration.Text.Trim();
            string email            = txt_Email_Registration.Text.Trim();
            string password         = txt_Password_Registration.Password.Trim();
            string confirm_password = txt_Confirm_Password_Registration.Password.Trim();

            bool Email_is_Db = _libdb.Sellers.Any(s => s.Seller_Email == email);

            if (Email_is_Db)
            {
                MessageBox.Show("Этот эмэил пользуется другим пользователем!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            Sellers seller = new Sellers();

            seller.Seller_Name       = name;
            seller.Seller_Surname    = surname;
            seller.Seller_Patronymic = patronymic;
            seller.Seller_Email      = email;
            seller.Seller_Password   = password.HashPassword();

            _libdb.Sellers.Add(seller);
            await _libdb.SaveChangesAsync();

            if (Is_Valid(name, surname, patronymic, email, password, confirm_password))
            {
                MessageBox.Show("Ваша решистрация прошла успешно!!!", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
                return;
            }
        }
Esempio n. 5
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            Sellers seller        = _libdb.Sellers.First(s => s.Seller_Name == txt_User_Name.Text.Trim());
            int     Selected_Case = cb_Case.SelectedIndex;

            switch (Selected_Case)
            {
            case (int)Case.Activated:
                seller.Is_Activated = true;
                seller.Is_Admin     = false;
                seller.Is_Deleted   = false;
                break;

            case (int)Case.Admin:
                seller.Is_Activated = true;
                seller.Is_Admin     = true;
                seller.Is_Deleted   = false;
                break;

            case (int)Case.Deleted:
                seller.Is_Activated = false;
                seller.Is_Admin     = false;
                seller.Is_Deleted   = true;
                break;

            default:
                break;
            }
            await _libdb.SaveChangesAsync();

            txt_User_Name.Text = " ";
            cb_Case.Text       = "";
        }
Esempio n. 6
0
        private async void btnDashBoardRent_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Info",
                                                  MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                DateTime date = DateTime.Today;
                int      selected_customerid       = ((CB_Customer)cmbDashboardCustomers.SelectedItem).Id;
                int      selected_bookid           = ((CB_Books)cmbDashBoardBooks.SelectedItem).Id;
                DateTime return_date               = DateTime.Parse(txtDashBoardReturn.Text.ToString());
                int      selected_count            = int.Parse(numDashBoardCount.Value.ToString());
                string   selected_customerName     = ((CB_Customer)cmbDashboardCustomers.SelectedItem).Name;
                string   selected_customerLastName = ((CB_Customer)cmbDashboardCustomers.SelectedItem).Lastname;
                decimal  selected_bookPrice        = ((CB_Books)cmbDashBoardBooks.SelectedItem).Price;
                string   selected_bookName         = ((CB_Books)cmbDashBoardBooks.SelectedItem).Name;

                Rent rent = new Rent()
                {
                    Count            = selected_count,
                    BookId           = selected_bookid,
                    CustomerId       = selected_customerid,
                    Returndate       = return_date,
                    Date             = date,
                    LibrarianId      = _userid,
                    CustomerName     = selected_customerName,
                    CustomerLastName = selected_customerLastName,
                    Price            = selected_bookPrice,
                    BookName         = selected_bookName
                };

                _db.Rents.Add(rent);
                await _db.SaveChangesAsync();

                MessageBox.Show("Successfully Rented");
                FillCmbReturnCustomer();
            }
        }
Esempio n. 7
0
        private async void btn_Add_Book_Click(object sender, RoutedEventArgs e)
        {
            string Author_Name       = txt_Author_Name.Text.Trim();
            string Author_Surname    = txt_Author_Surname.Text.Trim();
            string Author_Patronymic = txt_Author_Patronymic.Text.Trim();
            string Book_Name         = txt_Book_Name.Text.Trim();

            Authors author = new Authors();

            author.Author_Name       = Author_Name;
            author.Author_Surname    = Author_Surname;
            author.Author_Patronymic = Author_Patronymic;

            Books book = new Books();

            book.Book_Name = Book_Name;


            _libdb.Authors.Add(author);
            await _libdb.SaveChangesAsync();
        }
Esempio n. 8
0
        private async void btnRegistration_Click(object sender, EventArgs e)
        {
            string name     = txtRegisterName.Text.Trim();
            string surname  = txtRegisterSurname.Text.Trim();
            string email    = txtRegisterEmail.Text.Trim();
            string password = txtRegisterPassword.Text.Trim();

            if (name == "" || password == "" || surname == "" || email == "")
            {
                MessageBox.Show("Please Fill All Inputs", "Warning", MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
                return;
            }
            if (_db.Librarians.Any(l => l.Email == email))
            {
                MessageBox.Show("This Email Address Already Exists", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning
                                );
                return;
            }
            if (!email.IsMail())
            {
                MessageBox.Show("Please Write Email Address Correctly", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            string    passHash  = password.HashPassword();
            Librarian librarian = new Librarian
            {
                Name     = name,
                Lastname = surname,
                Email    = email,
                Password = passHash
            };

            _db.Librarians.Add(librarian);
            await _db.SaveChangesAsync();

            MessageBox.Show("Succesfully Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }