예제 #1
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);
            }
        }
예제 #2
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);
            }
        }
예제 #3
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);
            }
        }
예제 #4
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);
     }
 }
 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);
     }
 }
예제 #6
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);
     }
 }
예제 #7
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);
                }
            }
        }
예제 #8
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);
            }
        }
예제 #9
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);
        }
예제 #10
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);
        }
예제 #11
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);
        }
예제 #12
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);
            }
        }
예제 #13
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);
            }
        }
예제 #14
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);
            }
        }
예제 #15
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);
        }