void mbtnSetAutoProperties_Click(object sender, EventArgs e) { Kunde customer = null; Lieferant supplier = null; Kundenkontakt contact = null; Kundenmaschine machine = null; var msg = string.Empty; var msgBoxTitle = "Ausfüllen der Termineigenschaften" + Environment.NewLine; var subject = string.Empty; var location = string.Empty; var body = string.Empty; foreach (var lItem in ModelManager.AppointmentService.GetLinkedItemsList(this.myAppointment)) { if (lItem is Kunde) { customer = lItem as Kunde; } else if (lItem is Kundenkontakt) { contact = lItem as Kundenkontakt; } else if (lItem is Kundenmaschine) { machine = lItem as Kundenmaschine; } else if (lItem is Lieferant) { supplier = lItem as Lieferant; } } if (customer == null && supplier == null) { msg = "Bitte vorher den Termin zumindest mit einem Kunden oder einem Lieferanten verknüpfen."; MetroMessageBox.Show(this, msg, msgBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } msg = "Ich trage die Eigenschaften dieses Termins automatisch ein."; if (MetroMessageBox.Show(this, msg, msgBoxTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK) { return; } switch (this.myAppointment.AppointmentType) { case "Kundenbesuch": if (customer != null) { subject = string.Format("{0}: Besuchstermin", customer.Matchcode); location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } } break; case "Schulung": if (supplier != null) { subject = string.Format("{0}: Schulung", supplier.Matchcode); location = string.Format("{0}, {1} {2}", supplier.Strasse, supplier.Postleitzahl, supplier.Ort); } break; case "Wartungstermin": if (machine != null) { subject = string.Format("{0}: Wartung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Wartung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Servicetermin": if (machine != null) { subject = string.Format("{0}: Service {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Wartung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Fernwartung": subject = string.Format("{0}: Fernwartung", customer.Matchcode); location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } break; case "Maschinenlieferung": if (machine != null) { subject = string.Format("{0}: Auslieferung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Auslieferung ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Maschinenabholung": if (machine != null) { subject = string.Format("{0}: Abholung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Auslieferung ", customer.Matchcode); } location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Telefonat": subject = string.Format("{0}: Telefonat", customer.Matchcode); location = "Technik CPM"; if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Undefiniert": subject = string.Format("{0}: Undefinierter Termin", customer.Matchcode); if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Demo": if (machine != null) { subject = string.Format("{0}: Abholung {1} ({2})", customer.Matchcode, machine.Modellbezeichnung, machine.Seriennummer); } else { subject = string.Format("{0}: Demo ", customer.Matchcode); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; case "Besprechung": subject = "Besprechung"; location = "Empfang CPM"; body = string.Format(@"<p><strong><u>Teilnehmer</u></strong></p><ul>{0}</ul>", myCurrentUser.CalendarSettings.TargetUser.NameFull); break; default: subject = string.Format("{0}: {1}", customer.Matchcode, myAppointment.AppointmentType); if (myCurrentUser.CalendarSettings.AddCustomerAddress) { location = string.Format("{0}, {1} {2}", customer.Street, customer.ZipCode, customer.City); } if (myCurrentUser.CalendarSettings.AddCustomerInfo) { body = customer.GetCustomerInfoHtml(contact); } if (myCurrentUser.CalendarSettings.AddCustomerNotes) { body += customer.GetNotesHtml(); } if (myCurrentUser.CalendarSettings.AddCustomerPriceList) { body += customer.GetSpecialPriceListHtml(); } break; } this.myAppointment.Subject = subject; this.myAppointment.Location = location; this.myAppointment.BodyHtml = body; this.RefreshDataBindings(); }