Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        private DataGridViewRow CreateRow(DataGridView dgv)
        {
            try
            {
                dgv.Rows.Add();
                DataGridViewRow r = dgv.Rows[dgv.RowCount - 1];
                r.Cells["Bondsnummer"].Value = "Onbekend";
                r.Cells["Naam"].Value        = "Onbekend";

                r.Cells["CG Admin"].Value  = false;
                r.Cells["LB Admin"].Value  = false;
                r.Cells["Lic Admin"].Value = string.Empty;

                r.Cells["Team NAS"].Value      = false;
                r.Cells["CG NAS"].Value        = false;
                r.Cells["LB NAS"].Value        = false;
                r.Cells["Lic NAS"].Value       = string.Empty;
                r.Cells["Email NAS"].Value     = string.Empty;
                r.Cells["Niet in Admin"].Value = false;

                r.Height = 18;
                return(r);
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
                return(null);
            }
        }
Пример #4
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();
         }
     }
 }
Пример #5
0
        private void CreateRows()
        {
            try
            {
                dgView.Rows.Clear();
                dgView.AllowUserToResizeRows = false;

                foreach (tblLid lid in leden)
                {
                    DataGridViewRow r = CreateRow(dgView);
                    r.Cells["Bondsnummer"].Value = lid.BondsNr;
                    r.Cells["Naam"].Value        = lid.VolledigeNaam;

                    r.Cells["CG Admin"].Value = lid.CompGerechtigd;
                    r.Cells["LB Admin"].Value = lid.LidBond;

                    r.Cells["Lic Admin"].Value = lid.LicentieJun.Trim() + lid.LicentieSen.Trim();

                    r.Tag      = lid;
                    r.ReadOnly = false;
                }
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
        }
Пример #6
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;
        }
Пример #7
0
        private void cmdSaveMail_Click(object sender, EventArgs e)
        {
            mailFileName = GuiRoutines.GetSaveFileName(saveFileDialog1, "htm", mailFileName);
            PersistControlValue.SaveLocalAppSetting(@"Leden.Net", "LastUsedEmail", mailFileName);
            StreamWriter sw = new StreamWriter(mailFileName);

            sw.Write(htmlTextbox1.Text);

            sw.Close();
        }
Пример #8
0
        private void txtNASteamindeling_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // We zetten alle cellen op false. nodig omdat er anders kans is een true op true blijft staan bij een wijziging
                disableEventCellUpdate = true;
                foreach (DataGridViewRow r in dgView.Rows)
                {
                    r.Cells["Team NAS"].Value      = false;
                    r.Cells["Niet in Admin"].Value = false;
                }
                disableEventCellUpdate = false;

                foreach (string s in txtNASteamindeling.Lines)
                {
                    string line  = s.Replace("\t", " ");
                    bool   found = false;
                    if (line.Length < 8)
                    {
                        continue;
                    }
                    line = line.Substring(0, 8);
                    line = line.Trim();
                    if (line.IsNumeric())
                    {
                        foreach (DataGridViewRow r in dgView.Rows)
                        {
                            if (r.Cells["Bondsnummer"].Value.ToString() == line)
                            {
                                r.Cells["Team NAS"].Value = found = true;
                            }
                        }

                        // je hebt een bondsnr in de teamindeling gevonden die niet in je admin staat.
                        if (!found)
                        {
                            disableEventCellUpdate = true;
                            DataGridViewRow r = CreateRow(dgView);
                            r.Cells["Bondsnummer"].Value   = line;
                            r.Cells["Team NAS"].Value      = true;
                            r.Cells["Niet in Admin"].Value = true;

                            r.ReadOnly             = true;
                            disableEventCellUpdate = false;
                        }
                    }
                }
                Compare();
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
        }
Пример #9
0
 private void cmdShowLogfileMail_Click(object sender, EventArgs e)
 {
     try
     {
         StreamReader sr = new StreamReader(EmailLogFile);
         GuiRoutines.ShowMessage(sr.ReadToEnd(), EmailLogFile);
         sr.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #10
0
 private void cmdSave_Click(object sender, EventArgs e)
 {
     try
     {
         dataAdaptor.UpdateLeden(leden);
         dataAdaptor.CommitTransaction(true);
         toolStripStatusLabel1.Text = "Bewaard";
     }
     catch (Exception ex)
     {
         GuiRoutines.ShowMessage(ex);
     }
 }
 private void cmdOutput_Click(object sender, EventArgs e)
 {
     try
     {
         StreamReader sr = new StreamReader(reportFileName);
         GuiRoutines.ShowMessage(sr.ReadToEnd(), reportFileName);
         sr.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #12
0
        private void dgView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (disableEventCellUpdate)
            {
                return;
            }
            DataGridViewRow row = ((DataGridView)sender).CurrentRow;

            if (row.Tag != null)
            {
                try
                {
                    tblLid lid = (tblLid)row.Tag;
                    lid.CompGerechtigd = (bool)row.Cells["CG Admin"].Value;
                    lid.LidBond        = (bool)row.Cells["LB Admin"].Value;
                    lid.LicentieJun    = lid.LicentieSen = string.Empty;
                    string l = (string)row.Cells["Lic Admin"].Value;
                    if (l != null)
                    {
                        l = l.Trim().ToUpper();
                        if (l.Length == 2)
                        {
                            if (!lid.Is_SEN1_65_SEN) // Alleen jun kunnen een dubbele licentie hebben
                            {
                                lid.LicentieJun = l.Substring(0, 1);
                                lid.LicentieSen = l.Substring(1, 1);
                            }
                            else
                            {
                                lid.LicentieJun = string.Empty;
                                lid.LicentieSen = l.Substring(1, 1);
                            }
                        }
                        else
                        if (lid.Is_SEN1_65_SEN)
                        {
                            lid.LicentieSen = l.Trim();
                        }
                        else
                        {
                            lid.LicentieJun = l.Trim();
                        }
                    }
                    Compare();
                }
                catch (Exception ex)
                {
                    GuiRoutines.ShowMessage(ex);
                }
            }
        }
Пример #13
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            try
            {
                dataAdaptor.UpdateCrediteuren(crediteuren);
                dataAdaptor.CommitTransaction(true);
                toolStripStatusLabel1.Text = "Bewaard";
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
//                MessageBox.Show("Er zijn nog openstaande rekeningen voor dit lid", "Waarschuwing", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #14
0
        private void cmdGetMail_Click(object sender, EventArgs e)
        {
            mailFileName = GuiRoutines.GetOpenFileName(openFileDialog1, "htm*");
            if (mailFileName == string.Empty)
            {
                return;
            }
            StreamReader sr  = File.OpenText(mailFileName);
            StringReader str = new StringReader(sr.ReadToEnd());

            htmlTextbox1.Text = str.ReadToEnd();
            sr.Close();
            sr.Dispose();
        }
Пример #15
0
        public static tblCompResult CreateCompResultRecord(tblLid lid)
        {
            tblCompResult CompResult = new tblCompResult();

            try
            {
                CompResult.LidNr = lid.LidNr;
                CompResult.Lid   = lid;
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
            return(CompResult);
        }
Пример #16
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);
                }
            }
        }
Пример #17
0
        public tblBetaling(BetalingenLijst Betalingen)
        {
            try
            {
                for (int i = 0; i < Betalingen.Count; i++)
                {
                    if (Betalingen[i].BetalingsSeqNr > _BetalingsSeqNr)
                    {
                        _BetalingsSeqNr = Betalingen[i].BetalingsSeqNr;
                    }
                }
                _BetalingsSeqNr++;
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }

            _IBAN_Creditor            = string.Empty;
            _BIC_Creditor             = string.Empty;
            _Omschrijving             = string.Empty;
            _EndToEndId               = string.Empty;
            _TotaalBedrag             = 0;
            _TypeBetaling             = 0;
            _AanmaakDatum             = DateTime.Now;
            _Verstuurd                = false;
            _VerstuurdDatum           = DateTime.Now;
            _GewensteVerwerkingsDatum = DateTime.Now;
            _Extra1    = 0;
            _Extra2    = 0;
            _Extra3    = 0;
            _Crediteur = string.Empty;
            _ExtraB    = string.Empty;
            _ExtraC    = string.Empty;

            _isDirty = true;
            Betalingen.Add(this);
        }
Пример #18
0
        public static tblRekening CreateRekeningRecord(tblLid lid, RekeningenLijst rekeningen)
        {
            tblRekening rekening = new tblRekening();

            try
            {
                for (int i = 0; i < rekeningen.Count; i++)
                {
                    if (rekeningen[i].RekeningSeqNr > rekening.RekeningSeqNr &&
                        rekeningen[i].LidNr == lid.LidNr)
                    {
                        rekening.RekeningSeqNr = rekeningen[i].RekeningSeqNr;
                    }
                }
                rekening.RekeningSeqNr++;
                rekening.Lid   = lid;
                rekening.LidNr = lid.LidNr;
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
            return(rekening);
        }
Пример #19
0
 private void lblBijlage3_Click(object sender, EventArgs e)
 {
     txtBijlage3.Text = GuiRoutines.GetOpenFileName(openFileDialog1, "*");
 }
Пример #20
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();
                }
            }
        }
Пример #21
0
        private void Compare()
        {
            try
            {
                foreach (DataGridViewRow r in dgView.Rows)
                {
                    bool   CGAdmin     = (bool)r.Cells["CG Admin"].Value;
                    bool   LBAdmin     = (bool)r.Cells["LB Admin"].Value;
                    bool   inTeam      = (bool)r.Cells["Team NAS"].Value;
                    bool   CGNas       = (bool)r.Cells["CG NAS"].Value;
                    bool   LBNas       = (bool)r.Cells["LB NAS"].Value;
                    bool   NietInAdmin = (bool)r.Cells["Niet in Admin"].Value;
                    string LicAdmin    = (string)r.Cells["Lic Admin"].Value;
                    string LicNAS      = (string)r.Cells["Lic NAS"].Value;
                    string EmailNas    = (string)r.Cells["Email NAS"].Value;

                    if ((CGAdmin != CGNas) || (CGAdmin != inTeam) || (CGNas != inTeam))
                    {
                        r.Cells["CG Admin"].Style.BackColor = System.Drawing.Color.Red;
                        r.Cells["Team NAS"].Style.BackColor = System.Drawing.Color.Red;
                        r.Cells["CG NAS"].Style.BackColor   = System.Drawing.Color.Red;
                    }
                    else
                    {
                        r.Cells["CG Admin"].Style.BackColor = System.Drawing.Color.White;
                        r.Cells["Team NAS"].Style.BackColor = System.Drawing.Color.White;
                        r.Cells["CG NAS"].Style.BackColor   = System.Drawing.Color.White;
                    }

                    if (LBNas != LBAdmin)
                    {
                        r.Cells["LB Admin"].Style.BackColor = System.Drawing.Color.Red;
                        r.Cells["LB NAS"].Style.BackColor   = System.Drawing.Color.Red;
                    }
                    else
                    {
                        r.Cells["LB Admin"].Style.BackColor = System.Drawing.Color.White;
                        r.Cells["LB NAS"].Style.BackColor   = System.Drawing.Color.White;
                    }

                    if (NietInAdmin)
                    {
                        r.Cells["Niet in Admin"].Style.BackColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        r.Cells["Niet in Admin"].Style.BackColor = System.Drawing.Color.White;
                    }

                    if (LicAdmin != LicNAS)
                    {
                        r.Cells["Lic Admin"].Style.BackColor = System.Drawing.Color.Red;
                        r.Cells["Lic NAS"].Style.BackColor   = System.Drawing.Color.Red;
                    }
                    else
                    {
                        r.Cells["Lic Admin"].Style.BackColor = System.Drawing.Color.White;
                        r.Cells["Lic NAS"].Style.BackColor   = System.Drawing.Color.White;
                    }

                    if ((r.Tag != null) && ((tblLid)r.Tag).MainEmailAdress != EmailNas)
                    {
                        r.Cells["Email NAS"].Style.BackColor = System.Drawing.Color.Red;
                    }
                    else
                    {
                        r.Cells["Email NAS"].Style.BackColor = System.Drawing.Color.White;
                    }
                }
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
        }
Пример #22
0
        private void txtNASLeden_TextChanged(object sender, EventArgs e)
        {
            try
            {
                // We zetten alle cellen op false. nodig omdat er anders kans is een true op true blijft staan bij een wijziging
                disableEventCellUpdate = true;
                foreach (DataGridViewRow r in dgView.Rows)
                {
                    r.Cells["LB NAS"].Value = false;
                    r.Cells["CG NAS"].Value = false;
                }
                disableEventCellUpdate = false;

                foreach (string s in txtNASLeden.Lines)
                {
                    bool     found  = false;
                    string   line   = s.Replace("\t", " ");
                    string[] values = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (values.Length < 10)
                    {
                        continue;
                    }

                    string lic      = string.Empty;
                    string email    = string.Empty;
                    int    zoeknaam = 0;
                    for (int i = 2; i < values.Length; i++)
                    {
                        string l = values[i];
                        if ((l == "A" || l == "B" || l == "C" || l == "D" || l == "E" || l == "F" || l == "G" || l == "H") && l.Length == 1)
                        {
                            lic += l;
                        }
                        if (values[i].Contains("@"))
                        {
                            email = values[i];
                        }

                        // Als er NAS een bondsnummer staat die niet in onze admin staat dan moeten we iets in de naam invullen
                        // De best guess is dat de naam diect na het geslacht komt
                        if (zoeknaam == 0 && (values[i] == "M" || values[i] == "V") && values[i].Length == 1)
                        {
                            zoeknaam = i + 1;
                        }
                    }

                    foreach (DataGridViewRow r in dgView.Rows)
                    {
                        if (r.Cells["Bondsnummer"].Value.ToString() == values[1])
                        {
                            r.Cells["LB NAS"].Value    = found = true;
                            r.Cells["CG NAS"].Value    = (values[2] == "J");
                            r.Cells["Lic NAS"].Value   = lic;
                            r.Cells["Email NAS"].Value = email;
                        }
                    }
                    if (!found)
                    {
                        disableEventCellUpdate = true;
                        DataGridViewRow r = CreateRow(dgView);
                        r.Cells["Bondsnummer"].Value = values[1];

                        r.Cells["Naam"].Value = values[zoeknaam] + values[zoeknaam + 1];

                        r.Cells["Lic NAS"].Value                 = lic;
                        r.Cells["CG NAS"].Value                  = (values[2] == "J");
                        r.Cells["LB NAS"].Value                  = true;
                        r.Cells["Niet in Admin"].Value           = true;
                        r.Cells["Niet in Admin"].Style.BackColor = System.Drawing.Color.Red;

                        r.Cells["LB NAS"].ReadOnly   = true;
                        r.Cells["LB Admin"].ReadOnly = true;

                        r.Cells["Email NAS"].ReadOnly = true;
                        r.Cells["Email NAS"].Value    = string.Empty;

                        r.ReadOnly             = true;
                        disableEventCellUpdate = false;
                    }
                }
                Compare();
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
        }
        /// <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);
            }
        }
Пример #24
0
 private void lblInformatieFolder_Click(object sender, EventArgs e)
 {
     txtInfoFolder.Text = GuiRoutines.GetOpenFileName(openFileDialog1, "*");
 }
Пример #25
0
 private void lblReglement_Click(object sender, EventArgs e)
 {
     txtReglement.Text = GuiRoutines.GetOpenFileName(openFileDialog1, "*");
 }
Пример #26
0
        private tblVCard Import()
        {
            tblVCard newVCardLijst = new tblVCard();
            int      aantal        = 0;
            string   filename      = Util.Forms.GuiRoutines.GetOpenFileName(openFileDialog1, "vcf");

            if (filename == string.Empty)
            {
                return(null);
            }
            try
            {
                using (StreamReader sr = File.OpenText(filename))
                {
                    string line   = string.Empty;
                    string prefix = string.Empty;
                    VCard  vCard  = null;
                    while (!sr.EndOfStream)
                    {
                        line = sr.ReadLine();

                        prefix = "BEGIN:VCARD";
                        if (line.StartsWith(prefix))
                        {
                            vCard = new VCard();
                            newVCardLijst.Add(vCard);
                            aantal++;
                        }
                        prefix = "N:";
                        if (line.StartsWith(prefix))
                        {
                            line = line.Replace(prefix, string.Empty);
                            string[] naamdelen = line.Split(new char[] { ';' });
                            if (naamdelen[0] != null)
                            {
                                vCard.Achternaam = naamdelen[0];
                            }
                            if (naamdelen[1] != null)
                            {
                                vCard.Voornaam = naamdelen[1];
                            }
                            if (naamdelen[2] != null)
                            {
                                vCard.Tussenvoegsel = naamdelen[2];
                            }
                        }
                        prefix = "N;";
                        if (line.StartsWith(prefix))
                        {
                            vCard.Achternaam = "Onbekend";
                        }

                        //prefix = "FN:";
                        //if (line.StartsWith(prefix))
                        //{
                        //    vCard.NetteNaam = line.Replace(prefix, string.Empty);
                        //}

                        prefix = "ORG:";
                        if (line.StartsWith(prefix))
                        {
                            vCard.Organisatie = line.Replace(prefix, string.Empty);
                        }

                        prefix = "BDAY:";
                        if (line.StartsWith(prefix))
                        {
                            vCard.GeboorteDatum = line.Replace(prefix, string.Empty);
                        }

                        prefix = "NOTE:";
                        if (line.StartsWith(prefix))
                        {
                            vCard.Note = line.Replace(prefix, string.Empty);
                        }

                        prefix = "TITLE:";
                        if (line.StartsWith(prefix))
                        {
                            vCard.Title = line.Replace(prefix, string.Empty);
                        }

                        prefix = "ADR";
                        if (line.StartsWith(prefix))
                        {
                            line = line.Replace(prefix, string.Empty);

                            if (line.StartsWith(";HOME"))
                            {
                                vCard.adresLijst.Add(ExtractAddress("HOME", line));
                            }
                            if (line.StartsWith(";WORK"))
                            {
                                vCard.adresLijst.Add(ExtractAddress("WORK", line));
                            }
                            if (line.StartsWith(";PREF"))
                            {
                                vCard.adresLijst.Add(ExtractAddress("", line));
                            }
                            if (line.StartsWith(":"))
                            {
                                vCard.adresLijst.Add(ExtractAddress("", line));
                            }
                        }

                        prefix = "TEL";
                        if (line.StartsWith(prefix))
                        {
                            //Console.WriteLine(line);
                            line = line.Replace(prefix, string.Empty);

                            if (line.StartsWith(";HOME"))
                            {
                                vCard.telefoonNummerLijst.Add(ExtractTelephoneNumber("HOME", line));
                            }
                            if (line.StartsWith(";WORK"))
                            {
                                vCard.telefoonNummerLijst.Add(ExtractTelephoneNumber("WORK", line));
                            }
                            if (line.StartsWith(";CELL"))
                            {
                                vCard.telefoonNummerLijst.Add(ExtractTelephoneNumber("CELL", line));
                            }
                            if (line.StartsWith(";PREF"))
                            {
                                vCard.telefoonNummerLijst.Add(ExtractTelephoneNumber("", line));
                            }
                            if (line.StartsWith(":"))
                            {
                                vCard.telefoonNummerLijst.Add(ExtractTelephoneNumber("", line));
                            }
                        }

                        prefix = "EMAIL";
                        if (line.StartsWith(prefix))
                        {
                            line = line.Replace(prefix, string.Empty);

                            if (line.StartsWith(";HOME"))
                            {
                                vCard.emailLijst.Add(ExtractEmailAddress("HOME", line));
                            }
                            if (line.StartsWith(";WORK"))
                            {
                                vCard.emailLijst.Add(ExtractEmailAddress("WORK", line));
                            }
                            if (line.StartsWith(":"))
                            {
                                vCard.emailLijst.Add(ExtractEmailAddress("", line));
                            }
                            if (line.StartsWith(";PREF"))
                            {
                                vCard.emailLijst.Add(ExtractEmailAddress("", line));
                            }
                        }
                    }
                }
                toolStripStatusLabel1.Text = "VCards ingelezen (" + aantal.ToString() + ")";
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
            }
            return(newVCardLijst);
        }
Пример #27
0
        public frmSnelInvoeren(DataAdapters da)
        {
            InitializeComponent();
            this.da = da;
            #region Create Controls
            lblNaamSpeler = new Label[maxNbrSpelers];
            txtGespeeld   = new TextBox[maxNbrSpelers];
            txtGewonnen   = new TextBox[maxNbrSpelers];
            int beginHoogte  = 190;
            int controlSpace = 2;

            for (int y = 0; y < maxNbrSpelers; y++)
            {
                #region Create all dynamic control)
                lblNaamSpeler[y] = new Label();                                                         // Voeg ik runtime toe
                this.Controls.Add(this.lblNaamSpeler[y]);

                lblNaamSpeler[y].Location         = new System.Drawing.Point(10, beginHoogte + controlHeight + controlSpace);
                lblNaamSpeler[y].Size             = new System.Drawing.Size(120, controlHeight);
                lblNaamSpeler[y].Name             = "lblNaamSpeler" + y.ToString();
                lblNaamSpeler[y].CausesValidation = true;
                lblNaamSpeler[y].Visible          = false;
                lblNaamSpeler[y].Text             = "Spelers " + y.ToString();

                txtGespeeld[y] = new TextBox();
                txtGewonnen[y] = new TextBox();
                this.Controls.Add(txtGespeeld[y]);
                this.Controls.Add(txtGewonnen[y]);

                txtGespeeld[y].Location         = new System.Drawing.Point((lblNaamSpeler[y].Right + 10), beginHoogte + controlHeight + controlSpace);
                txtGespeeld[y].Size             = new System.Drawing.Size(16, controlHeight);
                txtGespeeld[y].Name             = "Gespeeld" + y.ToString();
                txtGespeeld[y].MaxLength        = 1;
                txtGespeeld[y].ReadOnly         = false;
                txtGespeeld[y].TextAlign        = HorizontalAlignment.Center;
                txtGespeeld[y].TabIndex         = y;
                txtGespeeld[y].Visible          = false;
                txtGespeeld[y].CausesValidation = true;
                txtGespeeld[y].BorderStyle      = BorderStyle.None;
                txtGespeeld[y].TabStop          = false;
                txtGespeeld[y].MouseDown       += new System.Windows.Forms.MouseEventHandler(this.SelectAll_MouseDown);
                txtGespeeld[y].Enter           += new System.EventHandler(this.SelectAll_Enter);
                txtGespeeld[y].KeyDown         += new System.Windows.Forms.KeyEventHandler(this.txtGespeeld_KeyDown);
                txtGespeeld[y].KeyPress        += new System.Windows.Forms.KeyPressEventHandler(this.NumericCheck_KeyPress);
                txtGespeeld[y].Validating      += new System.ComponentModel.CancelEventHandler(textBox_Validating);
                txtGespeeld[y].BackColor        = System.Drawing.SystemColors.Control;

                txtGewonnen[y].Location         = new System.Drawing.Point(txtGespeeld[y].Right + 10, beginHoogte + controlHeight + controlSpace);
                txtGewonnen[y].Size             = new System.Drawing.Size(16, controlHeight);
                txtGewonnen[y].Name             = "Gewonnen" + y.ToString();
                txtGewonnen[y].MaxLength        = 1;
                txtGewonnen[y].ReadOnly         = false;
                txtGewonnen[y].TextAlign        = HorizontalAlignment.Center;
                txtGewonnen[y].TabIndex         = y + 2;
                txtGewonnen[y].TabStop          = true;
                txtGewonnen[y].Visible          = false;
                txtGewonnen[y].CausesValidation = true;
                txtGewonnen[y].BorderStyle      = BorderStyle.None;;
                txtGewonnen[y].Text             = string.Empty;
                txtGewonnen[y].MouseDown       += new System.Windows.Forms.MouseEventHandler(this.SelectAll_MouseDown);
                txtGewonnen[y].Enter           += new System.EventHandler(this.SelectAll_Enter);
                txtGewonnen[y].KeyDown         += new System.Windows.Forms.KeyEventHandler(this.txtGewonnen_KeyDown);
                txtGewonnen[y].KeyPress        += new System.Windows.Forms.KeyPressEventHandler(this.NumericCheck_KeyPress);
                txtGewonnen[y].Validating      += new System.ComponentModel.CancelEventHandler(textBox_Validating);


                beginHoogte += (controlSpace + controlHeight);
                #endregion
            }
            #endregion

            GuiRoutines.SetFlatStyle(this.Controls);
            m_windowState = new PersistWindowState(this, @"Stand\SnelInvoeren");
        }
Пример #28
0
        private tblCompResult ScrapeTTKaart(string bondsnummer, int jaar, string seizoen)
        {
            try
            {
                // Scrape the website
                WebClient client = new WebClient();
                //this is the important bit...
                client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4");
                client.Headers.Add("Accept-Language", "en-us,en;q=0.5");
                //end of the important bit...


                client.UseDefaultCredentials = true;
                IWebProxy theProxy = client.Proxy;
                if (theProxy != null)
                {
                    theProxy.Credentials = CredentialCache.DefaultCredentials;
                }
                client.Proxy = WebRequest.DefaultWebProxy;
                byte[] data = null;
                try
                {
                    string url = @"http://ttkaart.nl/spelers/" + bondsnummer + @"/";
                    data = client.DownloadData(url);
                }
                catch
                {
                    //GuiRoutines.ShowMessage("Bondsnummer niet gevonden: " + bondsnummer);
                    return(null);
                }



                // Zet de byte-array om in een string
                StringReader sr = new StringReader(Encoding.UTF8.GetString(data, 0, data.Length));

                tblCompResult cr     = null;
                int           j      = 0;
                string        seiz   = string.Empty;
                string        klasse = string.Empty;
                string        type   = string.Empty;
                int           perc   = 0;

                HtmlTag    tag;
                HtmlParser parse = new HtmlParser(sr.ReadToEnd());
                parse.ParseNext("tbody", out tag);
                if (parse.ParseNext("tbody", out tag))
                {
                    parse.ParseNext("td", out tag);
                    if (parse.ParseNext("td", out tag))
                    {
                        string s = parse.ParseTagValue();
                        j    = int.Parse(s.Substring(0, 4));
                        seiz = s.Substring(6, 1).ToUpper();
                    }
                    parse.ParseNext("td", out tag);  //Jeugd
                    type = parse.ParseTagValue();
                    parse.ParseNext("td", out tag);  // Midden
                    if (parse.ParseNext("td", out tag))
                    {
                        if (parse.ParseNext("a", out tag))
                        {
                            klasse = parse.ParseTagValue().Substring(0, 11);
                            switch (klasse)
                            {
                            case "Kampioensgr": klasse = "K"; break;

                            case "Landelijk A": klasse = "A"; break;

                            case "Landelijk B": klasse = "B"; break;

                            case "Landelijk C": klasse = "C"; break;

                            case "Starterskla": klasse = "S"; break;

                            case "1e Divisie ": klasse = "1D"; break;

                            case "2e Divisie ": klasse = "2D"; break;

                            case "3e Divisie ": klasse = "3D"; break;

                            case "Duo 1e Klas": klasse = "D1"; break;

                            case "Duo 2e Klas": klasse = "D2"; break;

                            case "Duo 3e Klas": klasse = "D3"; break;

                            case "Duo 4e Klas": klasse = "D4"; break;

                            case "Duo 5e Klas": klasse = "D5"; break;

                            case "Duo 6e Klas": klasse = "D6"; break;


                            default:
                                if (klasse.Substring(0, 1).IsNumeric())
                                {
                                    klasse = klasse.Substring(0, 1);
                                }
                                break;
                            }
                            ;
                        }
                    }
                    parse.ParseNext("td", out tag);  // Aantal wedstrijden
                    parse.ParseNext("td", out tag);  // gewonnen

                    if (parse.ParseNext("td", out tag))
                    {
                        perc = int.Parse(parse.ParseTagValue());
                    }
                    if (j == jaar && seiz == seizoen)
                    {
                        cr                = new tblCompResult();
                        cr.Klasse         = klasse;
                        cr.Percentage     = perc;
                        cr.CompetitieType = type;
                    }
                }


                return(cr);
            }
            catch (Exception ex)
            {
                GuiRoutines.ShowMessage(ex);
                return(null);
            }
        }
Пример #29
0
 private void lblStatuten_Click(object sender, EventArgs e)
 {
     txtStatuten.Text = GuiRoutines.GetOpenFileName(openFileDialog1, "*");
 }