Exemplo n.º 1
0
 partial void DeleteInvoiceNumber(InvoiceNumber instance);
Exemplo n.º 2
0
 partial void InsertInvoiceNumber(InvoiceNumber instance);
Exemplo n.º 3
0
 partial void UpdateInvoiceNumber(InvoiceNumber instance);
Exemplo n.º 4
0
        /// <summary>
        /// Druckt die Rechnung im Original als PDF erstellt einen Datensatz zum Speichern des PDF in der Datenbank.
        /// </summary>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <param name="ms">MemoryStream, in den das PDF geschrieben wird.</param>
        /// <param name="logoFilePath">Dateipfad zum Logo für das PDF.</param>
        ///  <param name="defaultAccountNumber">Das Standard definierte Konto</param>
        public void Print(DataClasses1DataContext dbContext, MemoryStream ms, string logoFilePath, bool defaultAccountNumber = true)
        {
            if (this.IsPrinted)
            {
                throw new Exception("Die Rechnung wurde bereits gedruckt.");
            }

            this.LogDBContext = dbContext;

            InvoiceNumber num = this.InvoiceNumber;
            if (num == null)
            {
                num = new InvoiceNumber()
                            {
                                InvoiceId = this.Id
                            };
                dbContext.InvoiceNumber.InsertOnSubmit(num);
                dbContext.SubmitChanges();
                this.InvoiceNumber = num;

            }

            InvoicePDF pdf = new InvoicePDF(dbContext, this, logoFilePath);
            pdf.WritePDF(ms);
            Document doc = new Document()
            {
                Data = ms.ToArray(),
                DocumentType = dbContext.DocumentType.Where(q => q.Id == (int)DocumentTypes.Invoice).Single(),
                FileName = "Rechnung_" + num.Number.ToString() + ".pdf",
                MimeType = "application/pdf"
            };

            this.Document = doc;
            dbContext.Document.InsertOnSubmit(doc);
            dbContext.SubmitChanges();
            dbContext.WriteLogItem("Rechnung " + num.Number.ToString() + " wurde gedruckt.", LogTypes.UPDATE, this.Id, "Invoice", doc.Id);
            this.IsPrinted = true;
            this.PrintDate = DateTime.Now;

            if (defaultAccountNumber)
            {
                InvoiceItemAccountItem.UpdateAuthorativeAccounts(dbContext, this, Convert.ToString(ConfigurationManager.AppSettings["DefaultAccountNumber"]));
            }
        }