public AddUser(User u, LibraryDBContainer dbContext) { this.dbContext = dbContext; InitializeComponent(); this.Text = "Edytuj użytkownika"; editedUser = u; initSpinner(); typeSpinner.Hide(); label11.Hide(); initUser(u); textBoxPassword.PasswordChar = '*'; textBoxLogin.Enabled = false; switch (u.Type) { case "U": typeSpinner.SelectedIndex = 0; textBoxTel.Text = u.Reader.PhoneNumber; textBoxStreet.Text = u.Reader.Street; textBoxStrNum.Text = u.Reader.HouseNumber; textBoxApt.Text = u.Reader.ApartmentNumber; textBoxCity.Text = u.Reader.City; textBoxPostal.Text = u.Reader.PostalCode; break; case "L": typeSpinner.SelectedIndex = 1; readerComponents(false); break; case "A": typeSpinner.SelectedIndex = 2; readerComponents(false); break; } }
public static User AddUser(String type, LibraryDBContainer dbContext, String login, String password, String name, String surname, String mail) { if (string.IsNullOrWhiteSpace(login) || string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(surname) || string.IsNullOrWhiteSpace(mail)) { MessageBox.Show("Pola: Login, Haslo, Email, Imie, Nazwisko nie moga byc puste!"); return(null); } if (dbContext.Users.Any(x => x.Login == login)) { MessageBox.Show("Użytkownik o podanym loginie istnieje!"); return(null); } if (!mail.Contains("@")) { MessageBox.Show("Email nieprawidłowy!"); return(null); } var newUser = new User { Login = login, Password = password, Name = name, Surname = surname, Type = type, E_Mail = mail }; dbContext.Users.Add(newUser); dbContext.SaveChanges(); return(newUser); }
public static bool IsResourceAvailable(LibraryDBContainer dbContext, Resource resource) { List <Borrowing> borrowings = dbContext.Borrowings .Include("User") .Include("Reader") .Include("Resource") .Where(b => b.ResourceId == resource.Id) .Where(b => b.ReturnDate == null) .ToList(); int availableAmount = resource.Amount; if (borrowings != null) { availableAmount -= borrowings.Count; } List <Reservation> reservations = dbContext.Reservations .Include("Reader") .Include("Resource") .Where(r => r.ResourceId == resource.Id) .Where(r => r.RealizationDate > DateTime.Now) .ToList(); if (reservations != null) { availableAmount -= reservations.Count; } return(availableAmount > 0); }
public UserDebtForm(LibraryDBContainer dbContext, Reader reader) { this.dbContext = dbContext; this.reader = reader; InitializeComponent(); txtBoxDebt.Text = ((double)reader.Debt / 100).ToString(); }
public HandleReaderApplicationForm(LibraryDBContainer dbContext, ReaderApplication readerApplication) { this.dbContext = dbContext; this.readerApplication = readerApplication; InitializeComponent(); PopulateData(); }
public SearchResource(LibraryDBContainer dbContext, EventHandler <List <Resource> > search) { this.dbContext = dbContext; this.searchClicked += search; InitializeComponent(); initSpinner(); }
// Przykład użycia Entity Framework private void dbExample() { using (var db = new LibraryDBContainer()) { // Stworzenie nowego użytkownika var jpUser = new User { Login = "******", Password = "******", Name = "Jakub", Surname = "Plachta", Type = "A", E_Mail = "*****@*****.**" }; db.Users.Add(jpUser); // Dodanie użytkownika do tabeli Users db.SaveChanges(); // Zapisanie zmian do bazy // Zapytanie do bazy pobierające wszystkich użytkowników. var query = from u in db.Users orderby u.Surname, u.Name select u; foreach (var user in query) { dbExampleListBox.Items.Add(user.Surname + " " + user.Name); } } }
public GenreForm(LibraryDBContainer dbContext, Genre editedGenre) { InitializeComponent(); this.dbContext = dbContext; this.editedGenre = editedGenre; this.textBoxName.Text = editedGenre.Name; this.formAction = FormAction.Edit; }
public PublisherForm(LibraryDBContainer dbContext, Publisher editedPublisher) { InitializeComponent(); this.dbContext = dbContext; this.editedPublisher = editedPublisher; this.textBoxName.Text = editedPublisher.Name; this.formAction = FormAction.Edit; }
public GuestForm(Form parent, LibraryDBContainer dbContext) { InitializeComponent(); parent.Hide(); this.parent = parent; this.dbContext = dbContext; refreshListView(dbContext.Resources.ToList()); }
public LibrarianForm(Form parent, LibraryDBContainer dbContext, User librarian) { parent.Hide(); this.parent = parent; this.dbContext = dbContext; this.librarian = librarian; InitializeComponent(); }
public AdminForm(Form parent, LibraryDBContainer dbContext) { InitializeComponent(); parent.Hide(); this.parent = parent; this.dbContext = dbContext; refreshListView(dbContext.Users.ToList()); }
public BorrowingForm(LibraryDBContainer dbContext, Resource resource, Reader reader, User librarian) { this.resource = resource; this.reader = reader; this.librarian = librarian; this.dbContext = dbContext; InitializeComponent(); }
public ResourceForm(LibraryDBContainer dbContext, Resource resource) { this.dbContext = dbContext; InitializeComponent(); this.editedResource = resource; txtBoxCategory.Text = GetCategory(resource.Position); txtBoxAmount.Text = editedResource.Amount.ToString(); formAction = FormAction.Edit; }
public ReportForm(LibraryDBContainer dbContext) { this.dbContext = dbContext; InitializeComponent(); comboBoxReports.Items.Add("Zwroty"); // zwroty z ostatnich 30 dni comboBoxReports.Items.Add("Wypożyczone książki"); // all borrowed books comboBoxReports.Items.Add("Użytkownicy biblioteki"); //all normal users listed textBoxReport.ScrollBars = RichTextBoxScrollBars.ForcedBoth; }
public PublisherForm(LibraryDBContainer dbContext, bool searchPublisher = false) { InitializeComponent(); if (searchPublisher) { buttonSave.Text = "Wyszukaj"; } this.dbContext = dbContext; this.formAction = searchPublisher ? FormAction.Search : FormAction.Add; }
public LoginForm() { InitializeComponent(); txtBxPassword.PasswordChar = '*'; context = new LibraryDBContainer(); if (context == null) { this.Close(); } }
public AuthorForm(LibraryDBContainer dbContext, Author editedAuthor) { InitializeComponent(); this.dbContext = dbContext; this.editedAuthor = editedAuthor; this.textBoxName.Text = editedAuthor.Name; this.textBoxSurname.Text = editedAuthor.Surname; this.dateTimePicker1.Value = (DateTime)editedAuthor.BirthDate; this.formAction = FormAction.Edit; }
public MagazineForm(LibraryDBContainer dbContext, Magazine editedMagazine) { InitializeComponent(); this.dbContext = dbContext; this.editedMagazine = editedMagazine; this.txtBoxName.Text = editedMagazine.Title; InitSpinners(); this.publisherSpinner.Text = editedMagazine.Publisher.Name; this.genreSpinner.Text = editedMagazine.Genre.Name; this.formAction = FormAction.Edit; }
public PositionForm(LibraryDBContainer dbContext, Position editedPosition) { InitializeComponent(); this.dbContext = dbContext; this.editedPosition = editedPosition; this.formAction = FormAction.Edit; InitSpinner(); InitControls(editedPosition); SetControls(typeSpinner.SelectedIndex); // genreSpinner.Text = editedBook.Genre.Name; }
public AuthorForm(LibraryDBContainer dbContext, bool searchAuthor = false) { InitializeComponent(); if (searchAuthor) { buttonSave.Text = "Wyszukaj"; dateTimePicker1.ShowCheckBox = true; dateTimePicker1.Checked = false; } this.dbContext = dbContext; this.formAction = searchAuthor ? FormAction.Search : FormAction.Add; }
public BookForm(LibraryDBContainer dbContext, bool searchBook = false) { InitializeComponent(); if (searchBook) { buttonSave.Text = "Wyszukaj"; genreSpinner.Items.Add("Dowolny"); } this.dbContext = dbContext; this.formAction = searchBook ? FormAction.Search : FormAction.Add; InitSpinner(); }
public BookForm(LibraryDBContainer dbContext, Book editedBook) { InitializeComponent(); this.dbContext = dbContext; this.editedBook = editedBook; textBoxTitle.Text = editedBook.Title; this.formAction = FormAction.Edit; InitSpinner(); genreSpinner.Text = editedBook.Genre.Name; addedAuthors = editedBook.Authorship.Select(a => a.Author).ToList(); RefreshAddedAuthorListView(); }
public MagazineForm(LibraryDBContainer dbContext, bool searchMagazine = false) { InitializeComponent(); if (searchMagazine) { buttonSave.Text = "Wyszukaj"; genreSpinner.Items.Add("Dowolny"); publisherSpinner.Items.Add("Dowolny"); } this.dbContext = dbContext; InitSpinners(); this.formAction = searchMagazine ? FormAction.Search : FormAction.Add; }
public ResourceForm(LibraryDBContainer dbContext, Position position) { this.dbContext = dbContext; this.position = position; InitializeComponent(); if (position == null) { MessageBox.Show("Nie wybrano pozycji!", "Błąd"); this.Close(); } txtBoxCategory.Text = GetCategory(position); formAction = FormAction.Add; }
public ReaderApplicationForm(Reader u, LibraryDBContainer dbContext) { InitializeComponent(); this.user = u; this.dbContext = dbContext; textBoxName.Text = u.User.Name; textBoxSurname.Text = u.User.Surname; textBoxTel.Text = u.PhoneNumber; textBoxStreet.Text = u.Street; textBoxStrNum.Text = u.HouseNumber; textBoxApt.Text = u.ApartmentNumber; textBoxCity.Text = u.City; textBoxPostal.Text = u.PostalCode; }
public static User AddReader(LibraryDBContainer dbContext, String login, String password, String name, String surname, String mail, String phone, String street, String houseNum, String aptNum, String city, String postal) { var user = AddUser("U", dbContext, login, password, name, surname, mail); if (user != null) { if (!phone.All(Char.IsDigit)) { MessageBox.Show("Telefon nie zawiera tylko cyfr"); dbContext.Users.Remove(user); dbContext.SaveChanges(); return(null); } if (!postal.All(x => Char.IsDigit(x) || x == '-')) { MessageBox.Show("Nieprawidłowy kod pocztowy"); dbContext.Users.Remove(user); dbContext.SaveChanges(); return(null); } if (!houseNum.All(Char.IsDigit)) { MessageBox.Show("Numer domu nie zawiera tylko cyfr"); dbContext.Users.Remove(user); dbContext.SaveChanges(); return(null); } var newReader = new Reader { PhoneNumber = phone, Street = street, HouseNumber = houseNum, ApartmentNumber = aptNum, City = city, PostalCode = postal, Debt = 0, User = user }; user.Reader = newReader; dbContext.Readers.Add(newReader); dbContext.SaveChanges(); } return(user); }
public AddUser(bool hideTypeSpinner, LibraryDBContainer dbContext) { this.dbContext = dbContext; InitializeComponent(); this.Text = "Dodaj użytkownika"; textBoxPassword.PasswordChar = '*'; initSpinner(); typeSpinner.SelectedIndex = 0; if (hideTypeSpinner) { typeSpinner.Hide(); label11.Hide(); } }
public PositionForm(LibraryDBContainer dbContext, bool searchPosition = false) { InitializeComponent(); if (searchPosition) { buttonSave.Text = "Wyszukaj"; publisherSpinner.Items.Add("Dowolny"); genreSpinner.Items.Add("Dowolny"); datePicker.ShowCheckBox = true; datePicker.Checked = false; } this.dbContext = dbContext; this.formAction = searchPosition ? FormAction.Search : FormAction.Add; InitSpinner(); }
public static void RefreshBookListView(LibraryDBContainer dbContext, ref ListView lstViewBooks, ref Dictionary <String, Book> bookTagSet, List <Book> books = null) { if (books == null) { books = dbContext.Books.ToList(); } lstViewBooks.Items.Clear(); bookTagSet.Clear(); foreach (Book book in books) { string[] row = { book.Title }; ListViewItem item = new ListViewItem(row); item.Tag = book.GetHashCode(); bookTagSet.Add(item.Tag.ToString(), book); lstViewBooks.Items.Add(item); } }