Beispiel #1
0
        private SIMcard GetInfoFromNumber(string number)
        {
            DataAccessLayer dal = new DataAccessLayer();

            dal.AddParameter("@Number", number.Substring(3), DbType.String);
            dal.AddParameter("@Simnumber", null, DbType.String, ParameterDirection.Output);
            dal.AddParameter("@MANR", null, DbType.String, ParameterDirection.Output);
            dal.AddParameter("@Stabsnummer", null, DbType.String, ParameterDirection.Output);
            dal.AddParameter("@Name", null, DbType.String, ParameterDirection.Output);
            dal.ExecuteScalar("SELECT @Simnumber = [Simnumber], @MANR = [MANR], @Stabsnummer = [Stabsnummer], @Name = [Name] FROM [SimcardView] WHERE [Number] = @Number");

            SIMcard sim = new SIMcard();

            sim.Number      = number;
            sim.Simnumber   = dal.GetParameterValue("@Simnumber").ToString();
            sim.MANR        = dal.GetParameterValue("@MANR").ToString();
            sim.Stabsnummer = dal.GetParameterValue("@Stabsnummer").ToString();
            sim.Name        = dal.GetParameterValue("@Name").ToString();

            dal.ClearParameters();
            return(sim);
        }
Beispiel #2
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            dgvOutput.Rows.Clear();

            if (File.Exists(txtFilePath.Text))
            {
                try
                {
                    StringBuilder text = new StringBuilder();
                    Regex         re   = new Regex(@"(\+45\d+)(.*) (\d*\.?\d+,\d+)");

                    using (PdfReader reader = new PdfReader(File.OpenRead(txtFilePath.Text)))
                    {
                        pbBottom.Maximum = reader.NumberOfPages;

                        for (int i = 1; i <= reader.NumberOfPages; i++)
                        {
                            foreach (Match m in re.Matches(PdfTextExtractor.GetTextFromPage(reader, i)))
                            {
                                SIMcard sim = GetInfoFromNumber(m.Groups[1].Value);
                                dgvOutput.Rows.Add(m.Groups[1], m.Groups[2], m.Groups[3], sim.Simnumber, $"{sim.Stabsnummer} {sim.Name}", sim.MANR);
                            }
                            pbBottom.PerformStep();
                        }
                    }

                    pbBottom.Value = 0;
                }
                catch (BadPdfFormatException)
                {
                    MessageBox.Show("PDF-filen kunne ikke læses");
                }
            }
            else
            {
                MessageBox.Show("Filen findes ikke");
            }
        }