Ejemplo n.º 1
0
		private void detach_Document(Document entity)
		{
			this.SendPropertyChanging();
			entity.DocumentType = null;
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Erstellt den Lieferschein als PDF und schreibt ihn in den übergebenen MemoryStream.
        /// </summary>
        /// <param name="ms">Der MemoryStream, in den das PDF geschrieben wird.</param>
        /// <param name="headerLogoPath">Der Pfad zum Logo für den Header.</param>
        /// <param name="dbContext">Datenbankkontext für die Transaktion.</param>
        /// <remarks>Setzt im Erfolgsfall im Lieferscheindatensatz das Merkmal "IsPrinted" auf "true".</remarks>
        public void Print(MemoryStream ms, string headerLogoPath, DataClasses1DataContext dbContext, string fileName, bool isZulassungsStelle)
        {
            if (headerLogoPath == string.Empty)
            {
                headerLogoPath = dbContext.DocumentConfiguration.FirstOrDefault(q => q.Id == "LOGOPATH").Text;
            }

            if (!this.IsSelfDispatch.HasValue)
            {
                throw new Exception("Der Lieferschein kann nicht gedruckt werden. Es wurde nicht angegeben, ob es sich um eine Eigenverbringung handelt oder nicht.");
            }

            if (!this.IsSelfDispatch.Value && string.IsNullOrEmpty(this.DispatchOrderNumber))
            {
                throw new Exception("Der Lieferschein kann nicht gedruckt werden. Es wurde keine Versandauftragsnummer angegeben.");
            }

            //if (isZulassungsStelle)
            //{
            //    KVSCommon.PDF.PackingListPDF_Zulassungsstelle pdf = new PDF.PackingListPDF_Zulassungsstelle(this, headerLogoPath, dbContext);
            //    pdf.WritePDF(ms);
            //}
            else
            {
                KVSCommon.PDF.PackingListPDF pdf = new PDF.PackingListPDF(dbContext, this, headerLogoPath);
                pdf.WritePDF(ms);
            }

            Document doc = new Document()
            {
                Data = ms.ToArray(),
                DocumentType = dbContext.DocumentType.Where(q => q.Id == (int)DocumentTypes.PackagingList).Single(),
                FileName = fileName,
                MimeType = "application/pdf"
            };

            dbContext.Document.InsertOnSubmit(doc);
            dbContext.SubmitChanges();
            this.DocumentId = doc.Id;

            dbContext.WriteLogItem("Lieferschein " + fileName + " wurde gedruckt.", LogTypes.UPDATE, this.PackingListNumber, "Versand", doc.Id);

            if (this.LogDBContext == null)
            {
                this.LogDBContext = dbContext;
            }

            this.IsPrinted = true;
            dbContext.WriteLogItem("Lieferschein wurde gedruckt.", LogTypes.UPDATE, this.PackingListNumber, "PackingList");
        }
Ejemplo n.º 3
0
		private void attach_Document(Document entity)
		{
			this.SendPropertyChanging();
			entity.DocumentType = this;
		}
Ejemplo n.º 4
0
 partial void DeleteDocument(Document instance);
Ejemplo n.º 5
0
 partial void UpdateDocument(Document instance);
Ejemplo n.º 6
0
 partial void InsertDocument(Document instance);
Ejemplo n.º 7
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"]));
            }
        }