Example #1
0
        private static string getBestellungFilename(printumBestellung neueBestellung)
        {
            string destination = "";


            try
            {
                // das leere Template öffnen
                DAL.PrintumProjekteEntities db = new PrintumProjekteEntities();


                var projekt = db.Projekte.Find(neueBestellung.Projektnummer);

                destination = projekt.RootOrdner.Trim() + @"\06 Bestellungen\"//@"C:\Printum_server\06 printum BESTELLUNGEN\"
                              + neueBestellung.Firmenname.Trim() + "_"
                              + neueBestellung.BestellungIDText + "_"
                              + "Printumbestellung.xlsx";

                if (destination.Contains("PRINTUMSERVER"))
                {
                    destination = destination.Replace("PRINTUMSERVER", "192.168.26.250");
                }
            }
            catch (Exception ex)
            {
                Helper.LogHelper.WriteDebugLog("destination: " + destination + Environment.NewLine + ex.ToString());
            }
            return(destination);
        }
Example #2
0
 private void ReportViewer1_Load(object sender, EventArgs e)
 {
     dieBestellung       = new printumBestellung();
     dieBestellung.Text1 = "blabla";
     fillDieBestellung();
     ReportErstellen();
 }
Example #3
0
        private static void diePlatzhalterBefuellen(Excel.Worksheet excelSheet, printumBestellung neueBestellung)
        {
            //bool success = excelSheet.Rows.Replace(What: "####Bestellnummer####", Replacement: "17-12345");
            try
            {
                excelSheet.Rows.Replace(What: "####Bestellnummer####", Replacement: neueBestellung.BestellungIDText);

                excelSheet.Rows.Replace(What: "####Projektnummer####", Replacement: neueBestellung.ProjektnummerText);
                excelSheet.Rows.Replace(What: "####Ansprechpartner####", Replacement: Environment.UserName);
                excelSheet.Rows.Replace(What: "####Datum####", Replacement: DateTime.Now.Date.ToShortDateString());

                var leftHeader   = excelSheet.PageSetup.LeftHeader.Replace("####Bestellnummer####", neueBestellung.BestellungIDText);
                var middleHeader = excelSheet.PageSetup.CenterHeader.Replace("####Projektnummer####", neueBestellung.ProjektnummerText);
                excelSheet.PageSetup.LeftHeader   = leftHeader;
                excelSheet.PageSetup.CenterHeader = middleHeader;

                List <Templatmarker> liste = JsonConvert.DeserializeObject <List <Templatmarker> >(neueBestellung.Adresse);


                foreach (var cell in liste)
                {
                    if (cell.MarkerName != null)
                    {
                        if (cell.MarkerName.Length > 0)
                        {
                            excelSheet.Rows.Replace(What: cell.MarkerName, Replacement: cell.MarkerWert);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogHelper.WriteDebugLog(ex.ToString());
            }
        }
        public Form2_Bestellung(printumBestellung neueBestellung, List <Contact> alleAdressen)
        {
            InitializeComponent();

            var bestellunpfad = neueBestellung.Speicherort;



            this.neueBestellung = neueBestellung;

            this.alleAdressen = alleAdressen;

            this.label1.Text = alleAdressen.Count().ToString() + " Adressen aus 'Info PRINTUM'";

            this.label_ganzOben.Text += " " + neueBestellung.BestellungIDText + "                    an: " + neueBestellung.ProjektnummerText;
        }
Example #5
0
 private void fillDieBestellung()
 {
     using (DAL.PrintumProjekteEntities db = new DAL.PrintumProjekteEntities())
     {
         var q = from p in db.Bestellungen
                 where p.Bestellung_ID == bestellID
                 select new printumBestellung
         {
             Bestellung_ID = p.Bestellung_ID,
             Adresse       = p.Adresse
         };
         if (q.Count() > 0)
         {
             dieBestellung       = q.ToList().First();
             dieBestellung.Text1 = dieBestellung.Adresse;
         }
     }
 }
Example #6
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var tooltext = "Die nächste Bestellnummer ist : " + Environment.NewLine + Environment.NewLine;

            try
            {
                printumBestellung neueBestellung = new printumBestellung();
                neueBestellung.Bestellung_ID = neueBestellung.getNextBestellnr();

                tooltext += "   " + neueBestellung.BestellungIDText + Environment.NewLine + "   . ";

                MessageBox.Show(tooltext);
            }
            catch (Exception ex)
            {
                Helper.LogHelper.WriteDebugLog(ex.ToString());
            }
        }
Example #7
0
        private static void BestellungSpeichern(printumBestellung neueBestellung)
        {
            using (PrintumProjekteEntities db = new PrintumProjekteEntities())
            {
                Bestellungen b = new Bestellungen();

                b.Bestellung_ID    = neueBestellung.Bestellung_ID;
                b.BestellungIDText = neueBestellung.BestellungIDText;
                b.Adresse          = neueBestellung.Adresse;
                b.ErstelltVon      = neueBestellung.ErstelltVon;
                b.geaendert        = neueBestellung.geaendert;
                b.GeaendertVon     = neueBestellung.GeaendertVon;
                b.Projektnummer    = neueBestellung.Projektnummer;
                b.Speicherort      = neueBestellung.Speicherort;
                b.Vorlage          = neueBestellung.Vorlage;

                db.Bestellungen.Add(b);
                db.SaveChanges();
            }
        }
Example #8
0
        private static void BestellungSpeichern(printumBestellung neueBestellung)
        {
            using (PrintumProjekteEntities db = new PrintumProjekteEntities())
            {
                Bestellungen b = new Bestellungen();


                b.Bestellung_ID    = neueBestellung.Bestellung_ID;
                b.BestellungIDText = neueBestellung.BestellungIDText;
                b.Adresse          = neueBestellung.Adresse;
                b.ErstelltVon      = neueBestellung.ErstelltVon;
                b.geaendert        = neueBestellung.geaendert;
                b.GeaendertVon     = neueBestellung.GeaendertVon;
                b.Projektnummer    = neueBestellung.Projektnummer;
                b.Speicherort      = neueBestellung.Speicherort;
                b.AdressID         = neueBestellung.AdressID;
                b.Vorlage          = neueBestellung.Vorlage;
                b.Datum            = DateTime.Now;

                List <Templatmarker> liste = JsonConvert.DeserializeObject <List <Templatmarker> >(neueBestellung.Adresse);
                foreach (var cell in liste)
                {
                    if (cell.MarkerName != null)
                    {
                        if (cell.MarkerName.Length > 0)
                        {
                            if (cell.MarkerName == "####Matchcode####")
                            {
                                b.Adresse = cell.MarkerWert;
                            }
                        }
                    }
                }

                b.EmailAdresse = neueBestellung.Email1Adresse;
                b.AdressID     = neueBestellung.AdressID;

                db.Bestellungen.Add(b);
                db.SaveChanges();
            }
        }
Example #9
0
        private void button2_neueBestellung_Click(object sender, EventArgs e)
        {
            var tvNode = this.treeView1.SelectedNode;

            if (tvNode == null)
            {
                MessageBox.Show("Wie..." + Environment.NewLine +
                                Environment.NewLine +
                                "kein Projekt ausgewählt?");
            }
            else
            {
                this.Cursor = Cursors.WaitCursor;
                printumBestellung neueBestellung = new printumBestellung();
                neueBestellung.Bestellung_ID = neueBestellung.getNextBestellnr();



                try
                {
                    var item = this.treeView1.SelectedNode;

                    printumProjekt currProjekt = (printumProjekt)item.Tag;

                    neueBestellung.Projektnummer     = currProjekt.Projektnummer;
                    neueBestellung.ProjektnummerText = currProjekt.Projektnummer.ToString();
                }
                catch (Exception es)
                {
                    var bal = es.ToString();
                }

                Form2_Bestellung FormBestellung = new Form2_Bestellung(neueBestellung, alleAdressen);
                var FormErgebniss = FormBestellung.ShowDialog();

                this.bestellungenTableAdapter.Fill(this.dataSet11.Bestellungen);

                this.Cursor = Cursors.Default;
            }
        }
 public Form2_Bestellung(printumBestellung neueBestellung, List <Contact> alleAdressen, bool isEnglish) : this(neueBestellung, alleAdressen)
 {
     this.isEnglish = isEnglish;
 }
Example #11
0
        internal static void createNewWord(printumBestellung neueBestellung)
        {
            try
            {
                DAL.PrintumProjekteEntities db = new PrintumProjekteEntities();

                string orginal = @"C:\Printum_server\PT-99-Vorl\Dokumente\Template_Bestellung.doc";

                var projekt = db.Projekte.Find(neueBestellung.Projektnummer);

                string desitnation = projekt.RootOrdner + @"\06 Bestellungen\"//@"C:\Printum_server\06 printum BESTELLUNGEN\"
                                     + neueBestellung.Firmenname + "_"
                                     + neueBestellung.BestellungIDText + "_"
                                     + "sonstigeWichtigeTexte.doc";

                File.Copy(orginal, desitnation, true);

                neueBestellung.Vorlage     = orginal;
                neueBestellung.Speicherort = desitnation;

                Word.Application wApp     = new Word.Application();
                object           filename = desitnation;
                wApp.Documents.Add();
                var dasDocument = wApp.Documents.Open(filename, ReadOnly: false, Visible: true);
                dasDocument.Activate();



                JsonSerializer       serializer = new JsonSerializer();
                List <Templatmarker> liste      = JsonConvert.DeserializeObject <List <Templatmarker> >(neueBestellung.Adresse);

                FindAndReplace2(dasDocument, "####Bestellnummer####", neueBestellung.BestellungIDText);
                FindAndReplace2(dasDocument, "####Projektnummer####", neueBestellung.ProjektnummerText);
                FindAndReplace2(dasDocument, "####Ansprechpartner####", Environment.UserName);
                FindAndReplace2(dasDocument, "####Datum####", DateTime.Now.Date.ToShortDateString());


                foreach (var cell in liste)
                {
                    FindAndReplace2(dasDocument, cell.MarkerName, cell.MarkerWert);
                }

                dasDocument.Save();
                dasDocument.Close();

                Marshal.ReleaseComObject(dasDocument);
                Marshal.ReleaseComObject(wApp);

                BestellungSpeichern(neueBestellung);


                try
                {
                    System.Diagnostics.Process.Start(desitnation);
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Netzwerk"))
                    {
                        System.Diagnostics.Process.Start(desitnation.Replace("PRINTUMSERVER", "192.168.26.250"));
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.LogHelper.WriteDebugLog(ex.ToString());
            }
        }
Example #12
0
        public static void createNewExcel(printumBestellung neueBestellung, bool IsEnglish)
        {
            string destination = getBestellungFilename(neueBestellung);

            try
            {
                File.Copy(vorlageFile, destination, true);

                if (IsEnglish)
                {
                    neueBestellung.Vorlage = vorlageFileEnglish;
                }
                else
                {
                    neueBestellung.Vorlage = vorlageFile;
                }

                neueBestellung.Speicherort = destination;
            }
            catch (Exception ex)
            {
                Helper.LogHelper.WriteDebugLog(ex.ToString());
            }


            // das Excelsheet offnen
            if (File.Exists(destination))
            {
                try
                {
                    // die Excelanwendung
                    excelApp = new Excel.Application();
                    excelApp.DisplayAlerts = false;


                    // die Excelmappe
                    excelWorkbook = excelApp.Workbooks.Open(destination,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                                                            Type.Missing, Type.Missing);

                    int anzahlBlaetter = excelWorkbook.Sheets.Count;
                    if (anzahlBlaetter > 0)
                    {
                        // das Excelblatt
                        excelSheet = (Excel.Worksheet)excelWorkbook.Sheets[1];

                        diePlatzhalterBefuellen(excelSheet, neueBestellung);

                        excelWorkbook.Save();
                    }



                    // alles beenden und freigeben
                    excelWorkbook.Close(false, destination, null);
                    excelApp.Quit();
                    Marshal.ReleaseComObject(excelWorkbook);
                    Marshal.ReleaseComObject(excelApp);

                    BestellungSpeichern(neueBestellung);
                }
                catch (Exception ex)
                {
                    Helper.LogHelper.WriteDebugLog(ex.ToString());
                }
            }
        }