private void entfernenToolStripMenuItem_Click(object sender, EventArgs e) { int errorCount = 0; for (int i = 0; i < gv_Exemplare.SelectedRows.Count; i++) { int copyId = int.Parse(gv_Exemplare.SelectedRows[i].Cells[0].Value.ToString()); Copy copy = new Copy(copyId); if (copy.IsAvailable()) { copy.Deactivate(); } else { errorCount++; } } //exemplar.FillGrid(ref gv_Exemplare); //tb_Vorhanden.Text = gv_Exemplare.RowCount.ToString(); Clear_Form(); if (errorCount > 0) { MetroMessageBox.Show(this, "Nicht alle Exemplare konnten gelöscht werden, da sie sich noch im Verleih befinden. Bitte markieren Sie diese zuerst als 'zurückgegeben'!", "Achtung", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!backgroundWorker.IsBusy) { backgroundWorker.RunWorkerAsync(); } }
private void DeleteCopy() { Copy copy = new Copy(int.Parse(tb_ID.Text)); if (copy.IsAvailable()) { copy.Deactivate(); Clear_Form(); ShowMessage(SaveOption.delete); } else { MetroMessageBox.Show(this, "Das Exemplar konnte nicht gelöscht werden, da es sich noch im Verleih befindet. " + "Bitte markieren Sie es zuerst als 'zurückgegeben'!", "Achtung", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Übernimmt eine vorgefertigte Liste in die Buchausleihliste /// </summary> public void FillAusleihListe(string[] inputList) { try { ClearBorrowTable(); DataRow relation; string[] exemlarDetails = new string[2]; List <string> newList = new List <string>(); foreach (string s in inputList) { Copy ex = new Copy(int.Parse(s)); if (ex.IsAvailable()) { newList.Add(s); } } inputList = newList.ToArray(); if (BorrowTable.Columns.Count != 2) { BorrowTable.Columns.Add(); BorrowTable.Columns.Add(); } for (int i = 0; i <= inputList.Length - 1; i++) { exemlarDetails[0] = inputList[i]; exemlarDetails[1] = DateTime.Now.Date.ToShortDateString(); relation = BorrowTable.NewRow(); relation.ItemArray = exemlarDetails; BorrowTable.Rows.Add(relation); } } catch { MessageBox.Show("Beim Laden der Liste in die Buchausleihliste 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) { borrowHelper.Copy = copy; if (borrowHelper.CheckBorrowTable()) { borrowHelper.ReturnDate = Convert.ToDateTime(borrowHelper.BorrowTable.Rows[borrowHelper.GetIndexInLeihliste()][1]); bt_AddBuch.Text = "-"; } else { borrowHelper.ReturnDate = DateTime.Now.Date; bt_AddBuch.Text = "+"; } borrowHelper.IsAvailable = copy.IsAvailable(); llb_BuchTitel.Enabled = true; llb_BuchTitel.Text = borrowHelper.TrimText(copy.CopyTitle, 30); lb_BuchZustand.Enabled = true; lb_BuchZustand.Text = copy.Condition.ConditionName; lb_BuchStatus.Enabled = true; if (borrowHelper.IsAvailable) { lb_BuchStatus.Text = "verfügbar"; lb_BuchStatus.ForeColor = Color.Green; borrowHelper.Costumer = null; } else { lb_BuchStatus.Text = "nicht verfügbar (verliehen)"; lb_BuchStatus.ForeColor = Color.Red; } borrowHelper.ShowBuchCover(ref picBox_Buchcover); } else { Reset_Window(); } } catch { Reset_Window(); } } else { Reset_Window(); } }
private void tb_ExemplarID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { #region Buchcode parsen if (tb_ExemplarID.Text.Length == 8) { string seven = tb_ExemplarID.Text.Substring(0, 7); string eight = tb_ExemplarID.Text.Substring(7, 1); if (ParseBuchcode(seven).ToString().Equals(eight)) { tb_ExemplarID.Text = int.Parse(seven).ToString(); } } #endregion if (tb_ExemplarID.Text != "") { try { Copy copy = new Copy(int.Parse(tb_ExemplarID.Text)); if (copy.CopyActivated) { lb_selected.Text = "ausgewählte Bücher:"; autoausleihe.Copy = copy; if (selectedBuecher.Columns.Count < 2) { selectedBuecher.Columns.Add("ID"); selectedBuecher.Columns.Add("Titel"); } if (copy.IsAvailable()) { DataGridViewRow Buchrow = new DataGridViewRow(); if (GetIndexInSuggestedBuecher() != -1) { Buchrow = gv_suggested.Rows[GetIndexInSuggestedBuecher()]; if (!autoausleihe.CheckBorrowTable()) { if (autoausleihe.SuggestedBookAlreadyBorrowed(autoausleihe.Copy.CopyIsbn, autoausleihe.Costumer.CostumerId)) { DialogResult dr = MetroMessageBox.Show(this, "Ein Exemplar von diesem Buch wurde bereits an die Person verliehen. Soll es trotzdem hinzugefügt werden?", "Vorgeschlagenes Buch bereits verliehen", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.No) { tb_ExemplarID.Focus(); tb_ExemplarID.SelectAll(); return; } } SelectExemplar(); Buchrow.DefaultCellStyle.BackColor = Color.LimeGreen; Buchrow.DefaultCellStyle.ForeColor = Color.Black; } else { UnSelectExemplar(); if (!autoausleihe.SuggestedBookAlreadyBorrowed(autoausleihe.Copy.CopyIsbn, autoausleihe.Costumer.CostumerId)) { Buchrow.DefaultCellStyle.BackColor = default; Buchrow.DefaultCellStyle.ForeColor = default; } } } else { if (!autoausleihe.CheckBorrowTable()) { DialogResult dialogResult = MetroMessageBox.Show(this, "Dieses Buch ist als nicht notwendig eingestuft! Soll es ungeachtet dessen zur Buchausleihliste hinugefügt werden?", "Achtung", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { SelectExemplar(); Buchrow.DefaultCellStyle.BackColor = Color.LimeGreen; Buchrow.DefaultCellStyle.ForeColor = Color.Black; } } else { UnSelectExemplar(); Buchrow.DefaultCellStyle.BackColor = default; Buchrow.DefaultCellStyle.ForeColor = default; } } } else { MetroMessageBox.Show(this, "Dieses Buch wurde verliehen. Es kann nicht zur Buchausleihliste hinzugefügt werden.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } gv_selected.DataSource = selectedBuecher; gv_selected.Refresh(); gv_selected.ClearSelection(); tb_ExemplarID.Focus(); tb_ExemplarID.SelectAll(); } else { tb_ExemplarID.Focus(); tb_ExemplarID.SelectAll(); MetroMessageBox.Show(this, "Dieser Buchcode existiert nicht.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MetroMessageBox.Show(this, "Dieser Buchcode existiert nicht.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void Tb_ExemplarID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == (char)13) { #region Buchcode parsen if (tb_ExemplarID.Text.Length == 8) { string seven = tb_ExemplarID.Text.Substring(0, 7); string eight = tb_ExemplarID.Text.Substring(7, 1); if (ParseBuchcode(seven).ToString().Equals(eight)) { tb_ExemplarID.Text = int.Parse(seven).ToString(); } } #endregion if (tb_ExemplarID.Text != "") { try { Copy copy = new Copy(int.Parse(tb_ExemplarID.Text)); if (copy.CopyActivated) { lb_selected.Text = "ausgewählte Bücher:"; returnHelper.Copy = copy; returnHelper.StartCondition = copy.Condition; returnHelper.EndCondition = copy.Condition; if (selectedBuecher.Columns.Count < 2) { selectedBuecher.Columns.Add("ID"); selectedBuecher.Columns.Add("Vorheriger Zustand"); selectedBuecher.Columns.Add("Titel"); } if (!copy.IsAvailable()) { DataGridViewRow Buchrow = new DataGridViewRow(); if (GetIndexInLeihBuecher() != -1) { Buchrow = gv_suggested.Rows[GetIndexInLeihBuecher()]; if (!returnHelper.CheckRueckList()) { SelectExemplar(); Buchrow.DefaultCellStyle.BackColor = Color.LimeGreen; Buchrow.DefaultCellStyle.ForeColor = Color.Black; } else { UnSelectExemplar(); Buchrow.DefaultCellStyle.BackColor = default; Buchrow.DefaultCellStyle.ForeColor = default; } } else { DialogResult dialogResult = MetroMessageBox.Show(this, "Dieses Buch wurde nicht von diesem Kunden ausgeliehen!", "Achtung", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MetroMessageBox.Show(this, "Dieses Buch wurde nicht verliehen. Es kann nicht zur Buchrückgabeliste hinzugefügt werden.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } gv_selected.DataSource = selectedBuecher; gv_selected.Refresh(); if (gv_selected.Columns.Contains("cbzustand")) { gv_selected.Columns.Remove("cbzustand"); } DataGridViewComboBoxColumn combobox = new DataGridViewComboBoxColumn(); combobox = conditionHelper.FillDataGridViewComboBox(); gv_selected.Columns.Add(combobox); gv_selected.Columns["cbzustand"].DisplayIndex = 2; gv_selected.Columns["cbzustand"].HeaderText = "aktueller Ist-Zustand"; for (int i = 0; i < gv_selected.RowCount; i++) { DataGridViewComboBoxCell comboValue = (DataGridViewComboBoxCell)(gv_selected.Rows[i].Cells["cbzustand"]); //comboValue.Value = 0; string valueMember = gv_selected.Rows[i].Cells[1].Value.ToString(); Condition condition = new Condition(conditionHelper.FindIdByName(valueMember)); valueMember = condition.ConditionId.ToString(); gv_selected.Rows[i].Cells[3].Value = int.Parse(valueMember); } gv_selected.ClearSelection(); tb_ExemplarID.Focus(); tb_ExemplarID.SelectAll(); combobox.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; } else { tb_ExemplarID.Focus(); tb_ExemplarID.SelectAll(); MetroMessageBox.Show(this, "Dieser Buchcode existiert nicht.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MetroMessageBox.Show(this, "Dieser Buchcode existiert nicht.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
/// <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; }