Exemple #1
0
 private void DoSomeWork(object status)
 {
     errorList = new StringBuilder();
     errorMail = false;
     errorList.AppendLine("Email not sent to:");
     callback = status as IProgressCallback;
     try
     {
         callback.Begin(0, nbrTxtInc);
         SendContributieIncassoAankondiging();
         SendInschrijfIncassoAankondiging();
         callback.WaitOK();
     }
     catch (System.Threading.ThreadAbortException)
     {
         // We want to exit gracefully here (if we're lucky)
     }
     catch (System.Threading.ThreadInterruptedException)
     {
         // And here, if we can
     }
     catch (Exception ex)
     {
         GuiRoutines.ExceptionMessageBox(this, ex);
     }
     finally
     {
         if (callback != null)
         {
             callback.End();
         }
     }
 }
        private void cmdVerstuurMail_Click(object sender, EventArgs e)
        {
            try
            {
                List <EmailAdresLid> emailList = new List <EmailAdresLid>();

                for (int i = 0; i < clbExtraEmail.Items.Count; i++)
                {
                    if (!clbExtraEmail.GetItemChecked(i))
                    {
                        continue;
                    }
                    EmailAdresLid email = new EmailAdresLid(clbExtraEmail.Items[i].ToString());
                    emailList.Add(email);
                }
                BodyString    body       = @"<P>Hierbij een nieuw bestand voor het mailprogramma. Lees het bestand in via 'File' --&gt; 'Open'.</P> <P>M.v.g.<BR>Ledenadministratie</P>";
                List <string> attachment = new List <string>();
                attachment.Add(fileName);
                new frmMultiMail(emailList, param, body, "Nieuw bestand voor " + param.ClubNameShort + " Mail programma", attachment).ShowDialog();
            }
            catch (Exception ex)
            {
                GuiRoutines.ExceptionMessageBox(this, ex);
            }
        }
        private void cmdExportCSV_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (tblLid lid in leden)
                {
                    lid.Gemerkt = false;
                    // we verwijderen zaken die niet nodig zijn voor de email functie.
                    lid.IBAN        = string.Empty;
                    lid.BIC         = string.Empty;
                    lid.VastBedrag  = 0;
                    lid.Korting     = 0;
                    lid.BetaalWijze = string.Empty;
                    lid.U_PasNr     = string.Empty;
                    lid.BetaalWijze = string.Empty;
                }

                fileName = txtOutputMailLocation.Text + @"\" + param.ClubNameShort + "_Ledenlijst_voor_Mail.xml";
                using (FileStream fs = new FileStream(fileName, FileMode.Create))
                {
                    XmlSerializer s = new XmlSerializer(typeof(LedenLijst));
                    s.Serialize(fs, leden);
                }
                MessageBox.Show(" Bestand met email adressen aangemaakt.\nZie " + fileName, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                GuiRoutines.ExceptionMessageBox(this, ex);
            }
        }
Exemple #4
0
        private void cmdExportCSV_Click(object sender, EventArgs e)
        {
            try
            {
                #region Create CSV op Naam
                vCardLijst = new tblVCard();
                CopyLocalToVCardList();

                StreamWriter vcardWriter = new StreamWriter(txtOutputLocation.Text + @"\" + param.ClubNameShort + "_VCard_" + DateTime.Now.ToString("yyyyMMdd") + ".vcf");

                foreach (VCard vCard in vCardLijst)
                {
                    vcardWriter.WriteLine(WriteLid(vCard));
                }

                vcardWriter.Flush();
                vcardWriter.Close();

                #endregion
            }
            catch (Exception ex)
            {
                GuiRoutines.ExceptionMessageBox(this, ex);
            }

            Cursor = Cursors.Arrow;
            //            MessageBox.Show("VCards (" + aantal.ToString() + ") aangemaakt in " + txtOutputLocation.Text, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            toolStripStatusLabel1.Text = "VCards aangemaakt in " + txtOutputLocation.Text;
        }
Exemple #5
0
        private void cmdMailRek_Click(object sender, EventArgs e)
        {
            string fileName = param.LocationTemplates + @"\Template_ContributieRekening.htm";;

            if (!File.Exists(fileName))
            {
                MessageBox.Show("Template voor rekening mail " + fileName + " bestaat niet", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            StreamReader sr       = File.OpenText(fileName);
            StringReader str      = new StringReader(sr.ReadToEnd());
            string       template = str.ReadToEnd();

            foreach (Leden.Net.tblRekening rekening in selectedRek)
            {
                if (rekening.TypeRekening != 0)
                {
                    continue;                                              // Alleen contributie rekening
                }
                BodyString body = ReplaceRekeningItems(template, rekening);

                string subject;
                if (rekening.Lid.MainEmailAdress != string.Empty)
                {
                    subject = "Aankondiging contributie rekening TTVN";
                }
                else
                {
                    subject = "Geen email adres bij Aankondiging contributie rekening TTVN";
                }

                try
                {
                    frmMultiMail frm = new frmMultiMail(rekening, param, body, subject, new List <string>());
                    frm.ShowDialog();
                }
                catch (Exception ex)
                {
                    GuiRoutines.ExceptionMessageBox(this, ex);
                }
            }
        }
Exemple #6
0
        private void DoSomeWork(object status)
        {
            errorList = new StringBuilder();
            errorMail = false;
            string sSource = "MultiMail";
            string sLog    = "Application";

            errorList.AppendLine("Email not sent to:");
            IProgressCallback callback = status as IProgressCallback;

            try
            {
                callback.Begin(0, clbLeden.CheckedItems.Count + clbExtraEmail.CheckedItems.Count);

                SmtpClientExt client = new SmtpClientExt(param.STMPserver, param.STMPport, param.EmailUserId, param.EmailPassword,
                                                         EmailLogFile, chkLogEmail.Checked, ckbDoNotSendEmail.Checked, callback.SetText);

                MailMessage message = new MailMessage();
                message.Subject = txtSubject.Text;
                message.From    = new MailAddress(param.EmailReturnAdress);
                message.ReplyToList.Add(param.EmailReturnAdress);
                message.IsBodyHtml = ckbHtml.Checked;
                string messid = string.Format("<{0}@{1}>", Guid.NewGuid().ToString(), "wwww.ttvn.nl");
                message.Headers.Add("Message-Id", messid);

                string strBody = string.Empty;
                if (ckbHtml.Checked)
                {
                    strBody = string.Format(@"<html><head><meta http-equiv=Content-Type content=""text/html; charset=us-ascii""></head>{0}</html>", htmlTextbox1.Text);
                }
                else
                {
                    strBody = htmlTextbox1.PlainText;
                }

                if (txtBijlage1.Text != string.Empty)
                {
                    //emailer.Attachments.Add(new SmtpAttachment(txtBijlage1.Text));
                    message.Attachments.Add(new Attachment(txtBijlage1.Text));
                }
                if (txtBijlage2.Text != string.Empty)
                {
                    //emailer.Attachments.Add(new SmtpAttachment(txtBijlage2.Text));
                    message.Attachments.Add(new Attachment(txtBijlage2.Text));
                }
                if (txtBijlage3.Text != string.Empty)
                {
                    //emailer.Attachments.Add(new SmtpAttachment(txtBijlage3.Text));
                    message.Attachments.Add(new Attachment(txtBijlage3.Text));
                }

                for (int i = 0; i < clbLeden.Items.Count; i++)
                {
                    if (!clbLeden.GetItemChecked(i))
                    {
                        continue;
                    }

                    message.To.Clear();
                    message.To.Add(clbLeden.Items[i].ToString());
                    message.Body = MailRoutines.ReplaceKeyWords(strBody, ledenSchaduwlijst[i], param);



                    //emailer.To.Clear();
                    //emailer.To.Add(clbLeden.Items[i].ToString());
                    //emailer.Body = MailRoutines.ReplaceKeyWords(strBody, ledenSchaduwlijst[i], param);
                    try
                    {
                        //emailer.SendMessage();
                        client.Send(message);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            if (!EventLog.SourceExists("MultiMail"))
                            {
                                EventLog.CreateEventSource(sSource, sLog);
                            }

                            EventLog.WriteEntry(sSource, ex.Message + @"/n" + message.Body,
                                                EventLogEntryType.Warning, 001);
                        }
                        catch (Exception ex2)
                        {
                            GuiRoutines.ExceptionMessageBox(this, ex);
                            Console.WriteLine(ex2.ToString());
                        }
                        errorMail = true;
                        errorList.AppendLine(clbLeden.Items[i].ToString());
                    }
                    callback.Increment(1);
                    callback.SetText(clbLeden.Items[i].ToString());
                    System.Threading.Thread.Sleep(50);
                    if (callback.IsAborting)
                    {
                        return;
                    }
                }


                for (int i = 0; i < clbExtraEmail.Items.Count; i++)
                {
                    if (!clbExtraEmail.GetItemChecked(i))
                    {
                        continue;
                    }

                    message.To.Clear();
                    message.To.Add(clbExtraEmail.Items[i].ToString());
                    message.Body = MailRoutines.ReplaceKeyWords(strBody, new tblLid(), param);

                    try
                    {
                        client.Send(message);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            if (!EventLog.SourceExists("MultiMail"))
                            {
                                EventLog.CreateEventSource(sSource, sLog);
                            }
                            EventLog.WriteEntry(sSource, ex.Message,
                                                EventLogEntryType.Warning, 001);
                        }
                        catch { }

                        errorMail = true;
                        errorList.AppendLine(clbExtraEmail.Items[i].ToString());
                    }
                    callback.Increment(1);
                    callback.SetText(clbExtraEmail.Items[i].ToString());
                    System.Threading.Thread.Sleep(50);
                    if (callback.IsAborting)
                    {
                        return;
                    }
                }

                callback.WaitOK();
            }
            catch (System.Threading.ThreadAbortException ex)
            {
                // We want to exit gracefully here (if we're lucky)
                try
                {
                    if (!EventLog.SourceExists("MultiMail"))
                    {
                        EventLog.CreateEventSource(sSource, sLog);
                    }
                    EventLog.WriteEntry(sSource, ex.Message,
                                        EventLogEntryType.Warning, 001);
                }
                catch { }
            }
            catch (System.Threading.ThreadInterruptedException ex)
            {
                // And here, if we can
                try
                {
                    if (!EventLog.SourceExists("MultiMail"))
                    {
                        EventLog.CreateEventSource(sSource, sLog);
                    }
                    EventLog.WriteEntry(sSource, ex.Message,
                                        EventLogEntryType.Warning, 001);
                }
                catch { }
            }
            catch (Exception ex)
            {
                try
                {
                    if (!EventLog.SourceExists("MultiMail"))
                    {
                        EventLog.CreateEventSource(sSource, sLog);
                    }
                    EventLog.WriteEntry(sSource, ex.Message,
                                        EventLogEntryType.Warning, 001);
                }
                catch { }

                GuiRoutines.ExceptionMessageBox(this, ex);
            }
            finally
            {
                if (callback != null)
                {
                    callback.End();
                }
            }
        }
        /// <summary>
        /// Het aanmaken van het betaling bestand.
        /// De list selectedInc moet gesorteed zijn op 'geincasseerd' omdat we hierop batchen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdMaakbestand_Click(object sender, EventArgs e)
        {
            try
            {
                if (betalingen.Count == 0)
                {
                    MessageBox.Show("Geen betalingen", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                //dit fileSeqnr gebruiken we om in de db terug te schrijven zodat we weten in welk bestand een betaling zit
                // dit verder niet gebruikt maar miscchien later handig voor het nazoeken.
                fileSeqnr = txtFileSeqnrB.Text.IsNumeric() ? Convert.ToInt32(txtFileSeqnrB.Text) : 0;
                string outputfile = txtOutputLocationIncB.Text + @"\" + txtFilePrefixB.Text + fileSeqnr.ToString("000") + ".xml";

                #region BetalingVerslag init
                outputverslag = txtOutputLocationIncB.Text + @"\" + txtFilePrefixB.Text + fileSeqnr.ToString("000") + "_OutputVerslag.txt";
                betalingVerslag.AppendLine("Betalingverslag: " + outputfile);
                betalingVerslag.AppendLine();
                #endregion

                #region Template voor betaling
                //Ik maak hier eerst de template voor de credit's.
                StringBuilder templateBetaling = new StringBuilder();
                templateBetaling.AppendLine("      <CdtTrfTxInf>");
                templateBetaling.AppendLine("        <PmtId>");
                templateBetaling.AppendLine("          <EndToEndId>***EndToEndId***</EndToEndId>");
                templateBetaling.AppendLine("        </PmtId>");
                templateBetaling.AppendLine("        <Amt>");
                templateBetaling.AppendLine(@"        <InstdAmt Ccy=""EUR"">***InstdAmt***</InstdAmt>");
                templateBetaling.AppendLine("        </Amt>");
                templateBetaling.AppendLine("        <CdtrAgt>");
                templateBetaling.AppendLine("          <FinInstnId>");
                templateBetaling.AppendLine("            <BIC>***BIC***</BIC>");
                templateBetaling.AppendLine("          </FinInstnId>");
                templateBetaling.AppendLine("        </CdtrAgt>");
                templateBetaling.AppendLine("        <Cdtr>");
                templateBetaling.AppendLine("          <Nm>***Nm***</Nm>");
                templateBetaling.AppendLine("        </Cdtr>");
                templateBetaling.AppendLine("        <CdtrAcct>");
                templateBetaling.AppendLine("          <Id>");
                templateBetaling.AppendLine("            <IBAN>***IBAN***</IBAN>");
                templateBetaling.AppendLine("          </Id>");
                templateBetaling.AppendLine("        </CdtrAcct>");
                templateBetaling.AppendLine("        <RmtInf>");
                templateBetaling.Append("           ***RmtInf***");
                templateBetaling.AppendLine("        </RmtInf>");
                templateBetaling.AppendLine("      </CdtTrfTxInf>");
                #endregion

                #region Template on batchlevel for Payment Info
                // Ik maak hier de template voor de  batches.
                StringBuilder templateBatch = new StringBuilder();

                templateBatch.AppendLine("    <PmtInf>");
                templateBatch.AppendLine("      <PmtInfId>***PmtInfId***</PmtInfId> ");
                templateBatch.AppendLine("      <PmtMtd>TRF</PmtMtd>");
                templateBatch.AppendLine("      <BtchBookg>true</BtchBookg>");
                templateBatch.AppendLine("      <NbOfTxs>***NbOfTxs***</NbOfTxs>");
                templateBatch.AppendLine("      <CtrlSum>***InstdAmt***</CtrlSum>");
                templateBatch.AppendLine("      <PmtTpInf>");
                templateBatch.AppendLine("        <SvcLvl>");
                templateBatch.AppendLine("          <Cd>SEPA</Cd>");
                templateBatch.AppendLine("        </SvcLvl>");
                templateBatch.AppendLine("       <CtgyPurp>");
                templateBatch.AppendLine("          <Cd>OTHR</Cd>");
                templateBatch.AppendLine("       </CtgyPurp>");
                templateBatch.AppendLine("      </PmtTpInf>");
                templateBatch.AppendLine("      <ReqdExctnDt>***ReqdExctnDt***</ReqdExctnDt>");
                templateBatch.AppendLine("      <Dbtr>");
                templateBatch.AppendLine("        <Nm>***Nm***</Nm>");
                templateBatch.AppendLine("      </Dbtr>");
                templateBatch.AppendLine("      <DbtrAcct>");
                templateBatch.AppendLine("        <Id>");
                templateBatch.AppendLine("          <IBAN>***IBAN***</IBAN>");
                templateBatch.AppendLine("        </Id>");
                templateBatch.AppendLine("        <Ccy>EUR</Ccy>");
                templateBatch.AppendLine("      </DbtrAcct>");
                templateBatch.AppendLine("      <DbtrAgt>");
                templateBatch.AppendLine("        <FinInstnId>");
                templateBatch.AppendLine("          <BIC>***BIC***</BIC>");
                templateBatch.AppendLine("        </FinInstnId>");
                templateBatch.AppendLine("      </DbtrAgt>");
                templateBatch.AppendLine("      <ChrgBr>SLEV</ChrgBr>");
                templateBatch.Append("***insertCred****");
                templateBatch.AppendLine("    </PmtInf>");
                #endregion

                #region Template on file level
                StringBuilder templateFile = new StringBuilder();

                templateFile.AppendLine(@"<Document xmlns=""urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">");
                templateFile.AppendLine("  <CstmrCdtTrfInitn>");
                templateFile.AppendLine("    <GrpHdr>");
                templateFile.AppendLine("      <MsgId>***MsgId***</MsgId>");
                templateFile.AppendLine("      <CreDtTm>***CreDtTm***</CreDtTm>");
                templateFile.AppendLine("      <NbOfTxs>***NbOfTxs***</NbOfTxs>");
                templateFile.AppendLine("      <InitgPty>");
                templateFile.AppendLine("        <Nm>***InitgPtyNm***</Nm>");
                templateFile.AppendLine("        <Id>");
                templateFile.AppendLine("          <OrgId>");
                templateFile.AppendLine("            <Othr>");
                templateFile.AppendLine("              <Id>***InitgPtyId***</Id>");
                templateFile.AppendLine("            </Othr>");
                templateFile.AppendLine("          </OrgId>");
                templateFile.AppendLine("        </Id>");
                templateFile.AppendLine("      </InitgPty>");
                templateFile.AppendLine("    </GrpHdr>");
                templateFile.Append("***insertBET***");
                templateFile.AppendLine("  </CstmrCdtTrfInitn>");
                templateFile.AppendLine("</Document>");
                #endregion

                decimal  amtBetalingenInBatch = 0M;
                int      nbrBetalingenInBatch = 0;
                int      nbrBetalingenInFile  = 0;
                string   batchName            = string.Empty;
                DateTime batchDatum           = new DateTime().Date;

                //Sorteren op gewenste uitvoer datum en selecteerd alleen niet verstuurde
                IEnumerable <tblBetaling> OnverstuurdeBetalingen = from betaling in betalingen where !betaling.Verstuurd orderby betaling.GewensteVerwerkingsDatum select betaling;

                //Sorteren op gewenste uitvoer datum
                //betalingen.Sort(new BetalingenComparer("GewensteDatum"));

                BetalingenLijst        betalingenPerDatum    = new BetalingenLijst();
                List <BetalingenLijst> betalingPerDatumLijst = new List <BetalingenLijst>();
                foreach (tblBetaling bet in OnverstuurdeBetalingen)
                {
                    if (bet.GewensteVerwerkingsDatum.Date == batchDatum.Date)
                    {
                        betalingenPerDatum.Add(bet);
                    }
                    else
                    {
                        if (betalingenPerDatum.Count > 0)
                        {
                            betalingPerDatumLijst.Add(betalingenPerDatum);
                        }
                        betalingenPerDatum = new BetalingenLijst();
                        betalingenPerDatum.Add(bet);
                        batchDatum = bet.GewensteVerwerkingsDatum.Date;
                    }
                }
                betalingPerDatumLijst.Add(betalingenPerDatum);

                StringBuilder sbrBatches = new StringBuilder();

                foreach (BetalingenLijst bl in betalingPerDatumLijst)
                {
                    StringBuilder sbrBetalingenInABatch = new StringBuilder();

                    foreach (tblBetaling betaling in bl)
                    {
                        #region Create betaling from template replacing placeholders
                        StringBuilder sbrBetaling = new StringBuilder(templateBetaling.ToString());

                        sbrBetaling.Replace("***EndToEndId***", "Ref: " + betaling.EndToEndId);
                        sbrBetaling.Replace("***InstdAmt***", betaling.TotaalBedrag.ToXMLString());
                        sbrBetaling.Replace("***BIC***", betaling.BIC_Creditor);
                        sbrBetaling.Replace("***Nm***", betaling.Crediteur);
                        sbrBetaling.Replace("***IBAN***", betaling.IBAN_Creditor);
                        StringBuilder RmtInf = new StringBuilder();
                        if (betaling.Omschrijving == string.Empty)
                        {
                            RmtInf.AppendLine("<Strd>");
                            RmtInf.AppendLine("                <CdtrRefInf>");
                            RmtInf.AppendLine("                  <Tp>");
                            RmtInf.AppendLine("                    <CdOrPrtry>");
                            RmtInf.AppendLine("                      <Cd>SCOR</Cd>");
                            RmtInf.AppendLine("                    </CdOrPrtry>");
                            RmtInf.AppendLine("                  </Tp>");
                            RmtInf.AppendLine("                  <Ref>" + betaling.EndToEndId + "</Ref>");
                            RmtInf.AppendLine("                </CdtrRefInf>");
                            RmtInf.AppendLine("              </Strd>");
                        }
                        else
                        {
                            RmtInf.AppendLine("<Ustrd>" + betaling.Omschrijving + "</Ustrd>");
                        }
                        sbrBetaling.Replace("***RmtInf***", RmtInf.ToString());
                        #endregion

                        sbrBetalingenInABatch.Append(sbrBetaling.ToString());
                        nbrBetalingenInBatch++;
                        nbrBetalingenInFile++;
                        amtBetalingenInBatch += betaling.TotaalBedrag;

                        regelVerslag.Append(betaling.Crediteur.PadRight(30));
                        regelVerslag.Append(betaling.GewensteVerwerkingsDatum.ToShortDateString().PadRight(15));
                        regelVerslag.Append(betaling.TotaalBedrag.ToEuroString().PadRight(12));
                        if (betaling.Omschrijving == string.Empty)
                        {
                            regelVerslag.Append(betaling.FormattedEndToEndId.PadRight(30));
                        }
                        else
                        {
                            regelVerslag.Append(betaling.Omschrijving.PadRight(30));
                        }
                        regelVerslag.AppendLine();

                        betaling.Verstuurd      = true;
                        betaling.VerstuurdDatum = DateTime.Now;
                        betaling.ExtraB         = txtFilePrefixB.Text + fileSeqnr.ToString("000");
                    }
                    StringBuilder B = CreateBatchHeader(templateBatch, sbrBetalingenInABatch, nbrBetalingenInBatch, amtBetalingenInBatch, batchDatum);
                    sbrBatches.Append(B.ToString());
                }

                // batch (mits gevuld) worden hier in de body geplaatst
                templateFile.Replace("***MsgId***", param.ClubNameShort + " betaling " + fileSeqnr.ToString("000"));
                templateFile.Replace("***CreDtTm***", DateTime.Now.ToString("s"));
                templateFile.Replace("***NbOfTxs***", nbrBetalingenInFile.ToString());
                templateFile.Replace("***InitgPtyNm***", param.ClubNameLong);
                templateFile.Replace("***InitgPtyId***", param.KvK);
                templateFile.Replace("***insertBET***", sbrBatches.ToString());

                #region replace unwanted characters
                // We vervangen niet toegestane tekens.
                // Wie weet een mooiere methode?
                templateFile.Replace("À", "A");
                templateFile.Replace("Á", "A");
                templateFile.Replace("Â", "A");
                templateFile.Replace("Ã", "A");
                templateFile.Replace("Ä", "A");
                templateFile.Replace("Å", "A");
                templateFile.Replace("Æ", "AE");
                templateFile.Replace("Ç", "C");
                templateFile.Replace("È", "E");
                templateFile.Replace("É", "E");
                templateFile.Replace("Ê", "E");
                templateFile.Replace("Ë", "E");
                templateFile.Replace("Ì", "I");
                templateFile.Replace("Í", "I");
                templateFile.Replace("Î", "I");
                templateFile.Replace("Ï", "I");
                templateFile.Replace("Ð", "D");
                templateFile.Replace("Ñ", "N");
                templateFile.Replace("Ò", "O");
                templateFile.Replace("Ó", "O");
                templateFile.Replace("Ô", "O");
                templateFile.Replace("Õ", "O");
                templateFile.Replace("Ö", "O");
                templateFile.Replace("Ø", "O");
                templateFile.Replace("Ù", "U");
                templateFile.Replace("Ú", "U");
                templateFile.Replace("Û", "U");
                templateFile.Replace("Ü", "U");
                templateFile.Replace("ß", "ss");
                templateFile.Replace("à", "a");
                templateFile.Replace("á", "a");
                templateFile.Replace("â", "a");
                templateFile.Replace("ã", "a");
                templateFile.Replace("ä", "a");
                templateFile.Replace("å", "a");
                templateFile.Replace("æ", "ae");
                templateFile.Replace("ç", "c");
                templateFile.Replace("è", "e");
                templateFile.Replace("é", "e");
                templateFile.Replace("ê", "e");
                templateFile.Replace("ë", "e");
                templateFile.Replace("ì", "i");
                templateFile.Replace("í", "i");
                templateFile.Replace("î", "i");
                templateFile.Replace("ï", "i");
                templateFile.Replace("ð", "o");
                templateFile.Replace("ñ", "n");
                templateFile.Replace("ò", "o");
                templateFile.Replace("ó", "o");
                templateFile.Replace("ô", "o");
                templateFile.Replace("õ", "o");
                templateFile.Replace("ö", "o");
                templateFile.Replace("ø", "o");
                templateFile.Replace("ù", "u");
                templateFile.Replace("ú", "u");
                templateFile.Replace("û", "u");
                templateFile.Replace("ü", "u");
                templateFile.Replace("ý", "u");
                templateFile.Replace("ÿ", "y");
                templateFile.Replace("ÿ", "y");
                templateFile.Replace("€", "E");
                #endregion

                // En klaar is kees. Nu het bestand inschrijven.
                StreamWriter swOutput = new StreamWriter(outputfile);

                swOutput.WriteLine(templateFile.ToString());
                swOutput.Flush();
                swOutput.Close();
                swOutput.Dispose();


                StreamWriter swVerslag = new StreamWriter(outputverslag);
                swVerslag.WriteLine(betalingVerslag.ToString());
                swVerslag.Flush();
                swVerslag.Close();
                swVerslag.Dispose();

                if (chkPrintVerslagB.Checked)
                {
                    fileToPrint = new System.IO.StreamReader(outputverslag);
                    printFont   = new System.Drawing.Font("Courier New", 8);
                    printDocument1.DocumentName = "Betaling Verslag";
                    printDocument1.Print();
                    fileToPrint.Close();
                }
                #endregion

                // We controleren nog even of het bestand aan het schema voldoet.
                CheckPain(outputfile);

                fileSeqnr++;
                txtFileSeqnrB.Text = fileSeqnr.ToString();

                dataAdaptor.UpdateBetalingen(betalingen);
                dataAdaptor.CommitTransaction(true);
                MessageBox.Show("Bestand aangemaakt: " + outputfile + "\nAantal betaling's: " + nbrBetalingenInFile.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cmdMaakbestand.Enabled = false;
            }
            catch (Exception ex)
            {
                GuiRoutines.ExceptionMessageBox(this, ex);
            }
        }