/// <summary> /// Führt die Buchausgabe aus /// </summary> private void Buchausgabe() { Costumer costumer = borrowHelper.Costumer; DialogResult dialogResult = MetroMessageBox.Show(this, borrowHelper.GetAusleihList() + "an: '" + borrowHelper.TrimText(costumer.CostumerFirstName + " " + costumer.CostumerSurname, 30) + "' wirklich ausleihen?", "Achtung", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, 211 + borrowHelper.BorrowTable.Rows.Count * 17); if (dialogResult == DialogResult.OK) { try { foreach (DataRow row in borrowHelper.BorrowTable.Rows) { borrowHelper.Execute_Ausleihe(Convert.ToInt32(row[0].ToString()), DateTime.Now.Date.ToShortDateString(), dp_RueckDatum.Value.ToShortDateString(), Convert.ToInt32(costumer.CostumerId)); //ausleihe.Save_Transaction(); In Bearbeitung!!! } MetroMessageBox.Show(this, "Die Buchausgabe wurde erfolgreich abgeschlossen!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); borrowHelper.ClearBorrowTable(); } catch { MetroMessageBox.Show(this, "Die Buchausgabe konnte nicht abgeschlossen werden!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } borrowHelper.SetSlider(ref leihList_Slider, ref tb_listVon, ref tb_listBis); tb_BuchCode.Text = ""; tb_BuchCode.Focus(); } }
/// <summary> /// Laden der KundenID, und des Ausleih- und Rückgabedatums eines Buches /// </summary> public void LoadInfo(int copyId, bool loadFullCostumerInfo = false) { CustomSqlConnection con = new CustomSqlConnection(); if (con.ConnectError()) { return; } string RawCommand = "SELECT aus_leihdatum, aus_rückgabedatum, aus_kundenid, aus_buchid FROM t_bd_ausgeliehen WHERE aus_buchid = @0"; SqlDataReader dr = con.ExcecuteCommand(RawCommand, copyId); while (dr.Read()) { Costumer = new Costumer(); if (loadFullCostumerInfo) { Costumer = new Costumer(int.Parse(dr["aus_kundenid"].ToString())); } else { Costumer.CostumerId = int.Parse(dr["aus_kundenid"].ToString()); } Copy = new Copy(int.Parse(dr["aus_buchid"].ToString())); BorrowDate = (DateTime)dr["aus_leihdatum"]; ReturnDate = (DateTime)dr["aus_rückgabedatum"]; } dr.Close(); con.Close(); }
/// <summary> /// Füllt ein DataGridView-Objekt mit den Schulbüchern /// </summary> public void FillSuggestGrid(ref MetroGrid grid, object value = null) { DataTable table = SuggestBuecher(Costumer.ReturnGrade()); grid.DataSource = table; if (grid.Columns.Count == 0) { return; } grid.Columns["bf_fachid"].Visible = false; }
private void MarkSchueler(int grade) { foreach (DataGridViewRow costumerRow in gv_Schueler.Rows) { Costumer costumer = new Costumer(Convert.ToInt32(costumerRow.Cells["kunde_ID"].Value)); autoausleihe.Costumer = costumer; List <Book> suggestedBooks = autoausleihe.SuggestedBooks(grade); //costumer.CostumerFirstName = costumerRow.Cells["Vorname"].Value.ToString(); //costumer.CostumerSurname = costumerRow.Cells["Nachname"].Value.ToString(); //costumer.CostumerSchoolClass.SchoolClassId = Convert.ToInt32(costumerRow.Cells["kunde_klasse"].Value); List <string> borrowedBookIsbns = costumer.BorrowedBookIsbns(); int countBooks = 0; for (int i = 0; i < suggestedBooks.Count; i++) //foreach (Book book in suggestedBooks) { if (!borrowedBookIsbns.Contains(suggestedBooks[i].BookIsbn)) { countBooks++; } } if (countBooks > 0 && countBooks == suggestedBooks.Count) { costumerRow.DefaultCellStyle.SelectionBackColor = default; costumerRow.DefaultCellStyle.SelectionForeColor = default; costumerRow.DefaultCellStyle.BackColor = default; costumerRow.DefaultCellStyle.ForeColor = default; } else if (countBooks > 0 && countBooks < suggestedBooks.Count) { costumerRow.DefaultCellStyle.SelectionBackColor = Color.LightGray; costumerRow.DefaultCellStyle.SelectionForeColor = Color.Black; costumerRow.DefaultCellStyle.BackColor = Color.Gray; costumerRow.DefaultCellStyle.ForeColor = Color.Black; } else { costumerRow.DefaultCellStyle.SelectionBackColor = Color.GreenYellow; costumerRow.DefaultCellStyle.SelectionForeColor = Color.Black; costumerRow.DefaultCellStyle.BackColor = Color.LimeGreen; costumerRow.DefaultCellStyle.ForeColor = Color.Black; } } }
private void MarkSchueler() { foreach (DataGridViewRow costumerRow in gv_Schueler.Rows) { Costumer costumer = new Costumer(); costumer.CostumerId = Convert.ToInt32(costumerRow.Cells["kunde_ID"].Value); if (costumer.HasBorrowedSomething()) { costumerRow.DefaultCellStyle.SelectionBackColor = default; costumerRow.DefaultCellStyle.SelectionForeColor = default; costumerRow.DefaultCellStyle.BackColor = default; costumerRow.DefaultCellStyle.ForeColor = default; } else { costumerRow.DefaultCellStyle.SelectionBackColor = Color.GreenYellow; costumerRow.DefaultCellStyle.SelectionForeColor = Color.Black; costumerRow.DefaultCellStyle.BackColor = Color.LimeGreen; costumerRow.DefaultCellStyle.ForeColor = Color.Black; } } }
public FormInformation(int modus, int id) { InitializeComponent(); LoadTheme(); if (modus == 1) { Text = "Buch-Details"; bt_Verwaltung.Text = "Bücherverwaltung"; tLP_Information.RowStyles[8].Height = 0; Book book = new Book(); book.LoadBookByCopyId(id); lb_1.Text = "Buch-ISBN:"; lb_2.Text = "Buchtitel:"; lb_3.Text = "Autor:"; lb_4.Text = "Genre:"; lb_5.Text = "Verlag:"; lb_6.Text = "Auflage:"; lb_7.Text = "Neupreis:"; lb_8.Text = "Erscheinungsdatum:"; lb_2_1.Text = book.BookIsbn; lb_2_2.Text = book.BookTitle; if (book.BookAuthors.Count > 0) { lb_2_3.Text = ""; foreach (Author author in book.BookAuthors) { lb_2_3.Text = lb_2_3.Text + author.AuthorName + ", "; } lb_2_3.Text = lb_2_3.Text.Substring(0, lb_2_3.Text.Length - 2); } else { lb_2_3.Text = "-"; } lb_2_4.Text = book.BookGenre.GenreName; lb_2_5.Text = book.BookPublisher.PublisherName; lb_2_6.Text = book.BookEdition; lb_2_7.Text = book.BookPrice.ToString() + " €"; lb_2_8.Text = book.BookDatePublication.ToShortDateString(); } else if (modus == 2) { Text = "Kunden-Details"; bt_Verwaltung.Text = "Kundenverwaltung"; Costumer kunde = new Costumer(id); lb_1.Text = "Vorname:"; lb_2.Text = "Nachname:"; lb_3.Text = "Straße, Hausnummer"; lb_4.Text = "PLZ:"; lb_5.Text = "Ort:"; lb_6.Text = "Klasse:"; lb_7.Text = "E-Mail:"; lb_8.Text = "Telefonnummer:"; lb_2_1.Text = kunde.CostumerFirstName; lb_2_2.Text = kunde.CostumerSurname; lb_2_3.Text = kunde.CostumerStreet + kunde.CostumerHouseNumber; lb_2_4.Text = kunde.CostumerZipcode; lb_2_5.Text = kunde.CostumerCity; lb_2_6.Text = kunde.CostumerSchoolClass.SchoolClassName; lb_2_7.Text = kunde.CostumerEmail; lb_2_8.Text = kunde.CostumerTelephone; } }
/// <summary> /// Lädt die Schulbücher für den gewählte Schüler /// </summary> private void LoadSchulBuecher() { try { schulBuecher.Rows.Clear(); if (gv_Schueler.CurrentRow != null) { DataGridViewRow row = gv_Schueler.Rows[gv_Schueler.CurrentRow.Index]; autoausleihe.Costumer = new Costumer(int.Parse(row.Cells["kunde_ID"].Value.ToString())); autoausleihe.FillSuggestGrid(ref gv_suggested); try { lb_selected.Text = "bereits geliehene Bücher:"; Costumer costumer = new Costumer(int.Parse(row.Cells["kunde_ID"].Value.ToString())); DataTable rueck = costumer.GetBorrowedSchoolBooks(); gv_selected.DataSource = rueck; gv_selected.Refresh(); for (int i = 0; i <= gv_suggested.RowCount - 1; i++) { DataGridViewRow row1 = gv_suggested.Rows[i]; int j = 0; bool found = false; do { if (row1.Cells["ISBN"].Value.ToString() == rueck.Rows[j]["ISBN"].ToString()) { found = true; row1.DefaultCellStyle.BackColor = Color.LimeGreen; row1.DefaultCellStyle.ForeColor = Color.Black; } else { row1.DefaultCellStyle.BackColor = default; row1.DefaultCellStyle.ForeColor = default; } j++; } while (!found && j <= rueck.Rows.Count - 1); } } catch { } gv_suggested.ClearSelection(); if (IsComplete(ref gv_suggested)) { row.DefaultCellStyle.SelectionBackColor = Color.GreenYellow; row.DefaultCellStyle.SelectionForeColor = Color.Black; row.DefaultCellStyle.BackColor = Color.LimeGreen; row.DefaultCellStyle.ForeColor = Color.Black; } else if (IsNotEmpty(ref gv_suggested)) { row.DefaultCellStyle.SelectionBackColor = Color.LightGray; row.DefaultCellStyle.SelectionForeColor = Color.Black; row.DefaultCellStyle.BackColor = Color.Gray; row.DefaultCellStyle.ForeColor = Color.Black; } else { row.DefaultCellStyle.SelectionBackColor = default; row.DefaultCellStyle.SelectionForeColor = default; row.DefaultCellStyle.BackColor = default; row.DefaultCellStyle.ForeColor = default; } } } catch { MetroMessageBox.Show(this, "Beim Laden der Zuordnungsliste ist ein Fehler aufgetreten.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Zeigt die Suchergebnisse an /// </summary> private void ShowBuchResults() { #region Buchcode parsen if (tb_BuchCode.Text.Length == 8) { string seven = tb_BuchCode.Text.Substring(0, 7); string eight = tb_BuchCode.Text.Substring(7, 1); if (_checksum_ean8(seven).ToString().Equals(eight)) { tb_BuchCode.Text = int.Parse(seven).ToString(); } } #endregion if (tb_BuchCode.Text != "") { try { Copy copy = new Copy(int.Parse(tb_BuchCode.Text)); if (copy.CopyActivated) { rueckgabe.Copy = copy; if (rueckgabe.CheckRueckList()) { bt_AddBuch.Text = "-"; } else { bt_AddBuch.Text = "+"; } rueckgabe.IsAvailable = copy.IsAvailable(); llb_BuchTitel.Enabled = true; llb_BuchTitel.Text = rueckgabe.TrimText(copy.CopyTitle, 30); //llb_BuchTitel.Text = rueckgabe.TrimText(new Buch(buch_exemplar.ISBN).Titel, 30); cb_Zustand.SelectedValue = copy.Condition.ConditionId; rueckgabe.StartCondition = copy.Condition; rueckgabe.EndCondition = copy.Condition; HistoryHelper verlauf = new HistoryHelper(rueckgabe.Copy.CopyId); verlauf.FillGrid(ref gv_Verlauf); if (!rueckgabe.IsAvailable) { rueckgabe.LoadInfo(rueckgabe.Copy.CopyId, true); kunde = rueckgabe.Costumer; llb_Kunde.Enabled = true; lb_AusleihStart.Enabled = true; lb_AusleihEnde.Enabled = true; bt_Zu_aendern.Enabled = true; llb_Kunde.Text = rueckgabe.TrimText(kunde.CostumerFirstName + ", " + kunde.CostumerSurname, 30); lb_AusleihStart.Text = rueckgabe.BorrowDate.Date.ToShortDateString(); lb_AusleihEnde.Text = rueckgabe.ReturnDate.Date.ToShortDateString(); if (rueckgabe.ReturnDate.Date < DateTime.Now.Date) { lb_AusleihEnde.ForeColor = Color.Red; lb_AusleihEnde.Text = lb_AusleihEnde.Text + " (überfällig)"; } } else { llb_Kunde.Enabled = false; lb_AusleihStart.Enabled = false; lb_AusleihEnde.Enabled = false; bt_Zu_aendern.Enabled = false; llb_Kunde.Text = "nicht verliehen"; lb_AusleihStart.Text = "nicht verfügbar"; lb_AusleihEnde.Text = "nicht verfügbar"; lb_AusleihEnde.ForeColor = default; } rueckgabe.ShowBuchCover(ref picBox_Buchcover); } else { Reset_Window(); } } catch { Reset_Window(); } } else { Reset_Window(); } Cursor = Cursors.Default; }