Example #1
0
        public int aftaleoplysninger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            int      dummy = 0;
            string   rec;
            string   leverance;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;


            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0603" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            int DebugCount = qrypbsfiles.Count();

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                //try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverance = "";
                    sektion   = "";
                    leverancespecifikation = "";


                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        //  Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance Start
                                leverance = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse("20" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            };

                            if (leverance == "0603")
                            {
                                // -- Leverance 0603
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0603",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0603",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                            ;
                        }
                        ;

                        if (leverance == "0603")
                        { //  Leverance 0603
                            //  Bestem Sektions Type
                            if (sektion == "")
                            {
                                if (rec.Substring(0, 5) == "BS012")
                                {  //  Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else
                                {
                                    if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                    {
                                        throw new Exception("243 - Første record er ikke en Sektions start record");
                                    }
                                    ;
                                };
                            }
                            ;

                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance start
                                //  BEHANDL: Leverance start
                                dummy = 1;
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0210")
                            {     //  Sektion 0210 Aktive aftaler
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0210"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0230"))
                                {  //  Aktive aftaler
                                    //  BEHANDL: Aktive aftaler
                                    readaftale042(p_dbData3060, sektion, "0230", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0210"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0212")
                            {     //  Sektion 0212 Til- og afgang af betalingsaftaler
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0212"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0231"))
                                {  //  Tilgang af nye betalingsaftaler
                                    //  BEHANDL: Tilgang af nye betalingsaftaler
                                    readaftale042(p_dbData3060, sektion, "0231", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0232"))
                                {  //  Aftale afmeldt af pengeinstitut
                                    //  BEHANDL: aftale afmeldt af pengeinstitut
                                    readaftale042(p_dbData3060, sektion, "0232", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0233"))
                                {  //  Aftaler afmeldt af kreditor
                                    //  BEHANDL: aftaler afmeldt af kreditor
                                    readaftale042(p_dbData3060, sektion, "0233", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0234"))
                                {  //  Aftaler afmeldt af betalingsservice
                                    //  BEHANDL: aftaler afmeldt af betalingsservice
                                    readaftale042(p_dbData3060, sektion, "0234", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0212"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0214")
                            {     //  Sektion 0214 Forfaldsoplysninger
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0214"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0235"))
                                {  //  Forfald automatisk betaling
                                    //  BEHANDL: Forfald automatisk betaling
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0295"))
                                {  //  Forfald manuel betaling
                                    //  BEHANDL: Forfald manuel betaling
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0214"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0215")
                            {     //  Sektion 0215 Debitornavn/-adresse
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(14 - 1, 4) == "0215"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS022") && (rec.Substring(13, 4) == "0240"))
                                {  //  Navn/adresse på debitor
                                    //  BEHANDL: Navn/adresse på debitor
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(14 - 1, 4) == "0215"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0217")
                            {     //  Sektion 0217 Oplysninger fra indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0217"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0295"))
                                {  //  Oplysninger fra indbetalingskort
                                    //  BEHANDL: Oplysninger fra indbetalingskort
                                    readgirokort042(p_dbData3060, sektion, "0295", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0217"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("248 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0219")
                            {     //  Sektion 0219 Aktive aftaler om Elektronisk Indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0219"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0230"))
                                {  //  Aktiv aftale om Elektronisk Indbetalingskort
                                    //  BEHANDL: Aktiv aftale om Elektronisk Indbetalingskort
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(14 - 1, 4) == "0219"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("249 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (rec.Substring(0, 5) == "BS992")
                            {  //  Leverance s**t
                                //  BEHANDL: Leverance S**t
                                leverance = "";
                            }
                            else
                            {
                                throw new Exception("250 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            };
                        }

                        else
                        {
                            throw new Exception("251 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        };
                    }
                }

                /*
                 * catch (Exception e)
                 * {
                 *  switch (e.Message.Substring(0, 3))
                 *  {
                 *      case "241":   //241 - Første record er ikke en Leverance start record
                 *      case "242":   //242 - Leverancen er indlæst tidligere
                 *      case "243":   //243 - Første record er ikke en Sektions start record
                 *      case "244":   //244 - Record ukendt
                 *      case "245":   //245 - Record ukendt
                 *      case "246":   //246 - Record ukendt
                 *      case "247":   //247 - Record ukendt
                 *      case "248":   //248 - Record ukendt
                 *      case "249":   //249 - Record ukendt
                 *      case "250":   //250 - Record ukendt
                 *      case "251":   //251 - Record ukendt
                 *          AntalFiler--;
                 *          break;
                 *
                 *      default:
                 *          throw;
                 *  }
                 * }
                 */
            }
            if (dummy == 1)
            {
                dummy = 2;
            }
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
Example #2
0
        public int aftaleoplysninger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            int      dummy = 0;
            string   rec;
            string   leverance;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;


            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0686" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            int DebugCount = qrypbsfiles.Count();

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                //try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverance = "";
                    sektion   = "";
                    leverancespecifikation = "";


                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        //  Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance Start
                                leverance = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse(rec.Substring(53, 4) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            };

                            if (leverance == "0686")
                            {
                                // -- Leverance 0686
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0686",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0686",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                            ;
                        }
                        ;

                        if (leverance == "0686")
                        { //  Leverance 0686
                            //  Bestem Sektions Type
                            if (sektion == "")
                            {
                                if (rec.Substring(0, 5) == "BS012")
                                {  //  Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else
                                {
                                    if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                    {
                                        throw new Exception("243 - Første record er ikke en Sektions start record");
                                    }
                                    ;
                                };
                            }
                            ;

                            if (rec.Substring(0, 5) == "BS002")
                            {  //  Leverance start
                                //  BEHANDL: Leverance start
                                dummy = 1;
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0195")
                            {     //  Sektion 0195 Indbetalingskort til e-Boks
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0195"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  Indbetalingskort til e-Boks
                                    //  BEHANDL: Indbetalingskort til e-Boks
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0195"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0196")
                            {     //  Sektion 0196 elektronisk indbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0196"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  elektronisk indbetalingskort
                                    //  BEHANDL: elektronisk indbetalingskort
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0196"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0197")
                            {     //  Sektion 0197 papirindbetalingskort
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0197"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  papirindbetalingskort
                                    //  BEHANDL: papirindbetalingskort
                                    readindbetalingskort042(p_dbData3060, sektion, "0274", rec);
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0197"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0198")
                            {     //  Sektion 0198 ej placerbare
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0198"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0274"))
                                {  //  ej placerbare
                                    //  BEHANDL: ej placerbare
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0198"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (sektion == "0199")
                            {     //  Sektion 0199 uanbringelig
                                if ((rec.Substring(0, 5) == "BS012") && (rec.Substring(13, 4) == "0199"))
                                { //  Sektion Start
                                    //  BEHANDL: Sektion Start
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS042") && (rec.Substring(13, 4) == "0275"))
                                {  //  uanbringelig
                                    //  BEHANDL: uanbringelig
                                    dummy = 1;
                                }
                                else if ((rec.Substring(0, 5) == "BS092") && (rec.Substring(13, 4) == "0199"))
                                {  //  Sektion S**t
                                    //  BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("248 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                };
                                // -******************************************************************************************************
                                // -******************************************************************************************************
                            }
                            else if (rec.Substring(0, 5) == "BS992")
                            {  //  Leverance s**t
                                //  BEHANDL: Leverance S**t
                                leverance = "";
                            }
                            else
                            {
                                throw new Exception("249 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            };
                        }

                        else
                        {
                            throw new Exception("250 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        };
                    }
                }

                /*
                 * catch (Exception e)
                 * {
                 *  switch (e.Message.Substring(0, 3))
                 *  {
                 *      case "241":   //241 - Første record er ikke en Leverance start record
                 *      case "242":   //242 - Leverancen er indlæst tidligere
                 *      case "243":   //243 - Første record er ikke en Sektions start record
                 *      case "244":   //244 - Record ukendt
                 *      case "245":   //245 - Record ukendt
                 *      case "246":   //246 - Record ukendt
                 *      case "247":   //247 - Record ukendt
                 *      case "248":   //248 - Record ukendt
                 *      case "249":   //249 - Record ukendt
                 *      case "250":   //250 - Record ukendt
                 *          AntalFiler--;
                 *          break;
                 *
                 *      default:
                 *          throw;
                 *  }
                 * }
                 */
            }
            if (dummy == 1)
            {
                dummy = 2;
            }
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
Example #3
0
        public void krdfaktura_overfoersel_action(dbData3060DataContext p_dbData3060, int lobnr)
        {
            string   rec;
            int      seq = 0;
            int      wleveranceid;
            DateTime wdispositionsdato;
            int      whour;
            int      wbankdage;

            // Betalingsoplysninger
            int belobint;

            // Tællere
            int antalos5;        // Antal OS5: Antal foranstående OS5 records
            int belobos5;        // Beløb: Nettobeløb i OS5 records

            int antalsek;        // Antal sektioner i leverancen
            int antalos5tot;     // Antal OS5: Antal foranstående OS5 records
            int belobos5tot;     // Beløb: Nettobeløb i OS5 records

            whour = DateTime.Now.Hour;
            if (whour > 17)
            {
                wbankdage = 3;
            }
            else
            {
                wbankdage = 2;
            }
            wdispositionsdato = clsOverfoersel.bankdageplus(DateTime.Now, wbankdage);

            antalos5 = 0;
            belobos5 = 0;

            antalsek    = 0;
            antalos5tot = 0;
            belobos5tot = 0;



            {
                var antal = (from c in p_dbData3060.tbltilpbs
                             where c.id == lobnr
                             select c).Count();
                if (antal == 0)
                {
                    throw new Exception("101 - Der er ingen PBS forsendelse for id: " + lobnr);
                }
            }
            {
                var antal = (from c in p_dbData3060.tbltilpbs
                             where c.id == lobnr && c.pbsforsendelseid != null
                             select c).Count();
                if (antal > 0)
                {
                    throw new Exception("102 - Pbsforsendelse for id: " + lobnr + " er allerede sendt");
                }
            }
            {
                var antal = (from c in p_dbData3060.tbloverforsels
                             where c.tilpbsid == lobnr
                             select c).Count();
                if (antal == 0)
                {
                    throw new Exception("103 - Der er ingen pbs transaktioner for tilpbsid: " + lobnr);
                }
            }

            var rsttil = (from c in p_dbData3060.tbltilpbs
                          where c.id == lobnr
                          select c).First();

            if (rsttil.udtrukket == null)
            {
                rsttil.udtrukket = DateTime.Now;
            }
            if (rsttil.bilagdato == null)
            {
                rsttil.bilagdato = rsttil.udtrukket;
            }
            if (rsttil.delsystem == null)
            {
                rsttil.delsystem = "OS1";
            }
            if (rsttil.leverancetype != null)
            {
                rsttil.leverancetype = null;
            }
            p_dbData3060.SubmitChanges();


            wleveranceid = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
            tblpbsforsendelse rec_pbsforsendelse = new tblpbsforsendelse
            {
                delsystem     = rsttil.delsystem,
                leverancetype = rsttil.leverancetype,
                oprettetaf    = "Udb",
                oprettet      = DateTime.Now,
                leveranceid   = wleveranceid
            };

            p_dbData3060.tblpbsforsendelses.InsertOnSubmit(rec_pbsforsendelse);
            rec_pbsforsendelse.tbltilpbs.Add(rsttil);

            tblpbsfilename rec_pbsfiles = new tblpbsfilename();

            rec_pbsforsendelse.tblpbsfilenames.Add(rec_pbsfiles);

            tblkreditor krd = (from k in p_dbData3060.tblkreditors
                               where k.delsystem == rsttil.delsystem
                               select k).First();


            // -- Leverance Start - OS1
            // - rstkrd.Datalevnr - Dataleverandørnr.: Dataleverandørens SE-nummer
            // - wleveranceid     - Leveranceidentifikation: Løbenummer efter eget valg
            rec = writeOS1(krd.datalevnr, wleveranceid);
            tblpbsfile rec_pbsfile = new tblpbsfile {
                seqnr = ++seq, data = rec
            };

            rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

            var qrydeb = from h in p_dbData3060.tbloverforsels
                         where h.tilpbsid == lobnr
                         select h;

            // Start loop over betalinger i tbloverforsel
            int testantal = qrydeb.Count();

            foreach (tbloverforsel rec_overfoersel in qrydeb)
            {
                DateTime Betalingsdato = (rec_overfoersel.betalingsdato == null) ? wdispositionsdato : (DateTime)rec_overfoersel.betalingsdato;
                if (Betalingsdato < wdispositionsdato)
                {
                    Betalingsdato = wdispositionsdato;
                }
                rec_overfoersel.betalingsdato = Betalingsdato; //opdater aktuel betalingsdato

                // Sektion start – (OS2)
                antalos5 = 0;
                belobos5 = 0;

                // -- OS2
                // - Betalingsdato  - Dispositionsdato
                // - krd.regnr      - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr    - Kontonr.: Overførselskontonummer
                // - krd.datalevnr  - Dataleverandørnr.: Dataleverandørens SE-nummer
                rec         = writeOS2(Betalingsdato, krd.regnr, krd.kontonr, krd.datalevnr);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                ++antalsek;

                // -- Forfald betaling
                if (rec_overfoersel.advisbelob > 0)
                {
                    belobint    = (int)(rec_overfoersel.advisbelob * ((decimal)100));
                    belobos5    = belobos5 + belobint;
                    belobos5tot = belobos5tot + belobint;
                }
                else
                {
                    belobint = 0;
                }

                // -- OS5
                // - debinfo.bankregnr   - Betalingsmodtager registreringsnummer
                // - debinfo.bankkontonr - Betalingsmodtager kontonummer
                // - belobint            - Beløb: Beløb i øre uden fortegn
                // - Betalingsdato       - Dispositionsdato
                // - krd.regnr           - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr         - Kontonr.: Overførselskontonummer
                // - deb.advistekst      - Tekst på Betalingsmodtagers kontoudtog
                // - deb.SFakID          - Ref til betalingsmodtager til eget brug
                rec         = writeOS5(rec_overfoersel.bankregnr, rec_overfoersel.bankkontonr, belobint, Betalingsdato, krd.regnr, krd.kontonr, rec_overfoersel.advistekst, (int)rec_overfoersel.SFakID);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

                antalos5++;
                antalos5tot++;


                // -- Sektion s**t – (OS8)
                // - OS8
                // - antalos5          - Antal 042: Antal foranstående 042 records
                // - belobos5          - Beløb: Nettobeløb i 042 records
                // - Betalingsdato     - Dispositionsdato
                // - krd.regnr         - Reg.nr.: Overførselsregistreringsnummer
                // - krd.kontonr       - Kontonr.: Overførselskontonummer
                // - krd.datalevnr     - Dataleverandørnr.: Dataleverandørens SE-nummer
                rec         = writeOS8(antalos5, belobos5, Betalingsdato, krd.regnr, krd.kontonr, krd.datalevnr);
                rec_pbsfile = new tblpbsfile {
                    seqnr = ++seq, data = rec
                };
                rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);
            }

            // -- Leverance s**t - (OS9)

            // --OS9
            // - antalos5tot    - Antal 042: Antal foranstående 042 records
            // - belobos5tot    - Beløb: Nettobeløb i 042 records
            // - krd.datalevnr  - Dataleverandørnr.: Dataleverandørens SE-nummer
            rec         = writeOS9(antalos5tot, belobos5tot, krd.datalevnr);
            rec_pbsfile = new tblpbsfile {
                seqnr = ++seq, data = rec
            };
            rec_pbsfiles.tblpbsfiles.Add(rec_pbsfile);

            rsttil.udtrukket = DateTime.Now;
            rsttil.leverancespecifikation = wleveranceid.ToString();
            p_dbData3060.SubmitChanges();
        }
Example #4
0
        public int betalinger_fra_pbs(dbData3060DataContext p_dbData3060)
        {
            string   rec;
            string   leverancetype;
            string   leverancespecifikation;
            DateTime leverancedannelsesdato;
            string   sektion;
            int      wpbsfilesid;
            int      wleveranceid;
            int      AntalFiler = 0;
            //  wpbsfilesid = 3450  //'--test test
            //  leverancetype = "0602"
            //  sektion = "0211"
            //  rec = "BS0420398564402360000000100000000001231312345678910120310000000012755000000125                         3112031112030000000012755"

            var qrypbsfiles = from h in p_dbData3060.tblpbsfilenames
                              where h.pbsforsendelseid == null
                              join d in p_dbData3060.tblpbsfiles on h.id equals d.pbsfilesid
                              where d.seqnr == 1 && d.data.Substring(16, 4) == "0602" && d.data.Substring(0, 2) == "BS"
                              select new
            {
                h.id,
                h.path,
                h.filename,
                leverancetype = d.data.Substring(16, 4),
                delsystem     = d.data.Substring(13, 3),
            };

            foreach (var rstpbsfiles in qrypbsfiles)
            {
                try
                {
                    wpbsfilesid = rstpbsfiles.id;
                    AntalFiler++;
                    leverancetype          = "";
                    sektion                = "";
                    leverancespecifikation = "";

                    var qrypbsfile = from d in p_dbData3060.tblpbsfiles
                                     where d.pbsfilesid == wpbsfilesid && d.data.Substring(0, 6) != "PBCNET"
                                     orderby d.seqnr
                                     select d;

                    foreach (var rstpbsfile in qrypbsfile)
                    {
                        rec = rstpbsfile.data;
                        // -- Bestem Leverance Type
                        if (rstpbsfile.seqnr == 1)
                        {
                            if ((rec.Substring(0, 5) == "BS002"))
                            {
                                // -- Leverance Start
                                leverancetype          = rec.Substring(16, 4);
                                leverancespecifikation = rec.Substring(20, 10);
                                leverancedannelsesdato = DateTime.Parse("20" + rec.Substring(53, 2) + "-" + rec.Substring(51, 2) + "-" + rec.Substring(49, 2));
                            }
                            else
                            {
                                throw new Exception("241 - Første record er ikke en Leverance start record");
                            }
                            if ((leverancetype == "0602"))
                            {
                                // -- Leverance 0602
                                var antal = (from c in p_dbData3060.tblfrapbs
                                             where c.leverancespecifikation == leverancespecifikation
                                             select c).Count();
                                if (antal > 0)
                                {
                                    throw new Exception("242 - Leverance med pbsfilesid: " + wpbsfilesid + " og leverancespecifikation: " + leverancespecifikation + " er indlæst tidligere");
                                }

                                wleveranceid         = (int)(from r in p_dbData3060.nextval("leveranceid") select r.id).First();
                                m_rec_pbsforsendelse = new tblpbsforsendelse
                                {
                                    delsystem     = "BS1",
                                    leverancetype = "0602",
                                    oprettetaf    = "Bet",
                                    oprettet      = DateTime.Now,
                                    leveranceid   = wleveranceid
                                };
                                p_dbData3060.tblpbsforsendelses.InsertOnSubmit(m_rec_pbsforsendelse);

                                m_rec_frapbs = new tblfrapb
                                {
                                    delsystem              = "BS1",
                                    leverancetype          = "0602",
                                    leverancespecifikation = leverancespecifikation,
                                    leverancedannelsesdato = leverancedannelsesdato,
                                    udtrukket              = DateTime.Now
                                };
                                m_rec_pbsforsendelse.tblfrapbs.Add(m_rec_frapbs);

                                m_rec_pbsfiles = (from c in p_dbData3060.tblpbsfilenames
                                                  where c.id == rstpbsfiles.id
                                                  select c).First();
                                m_rec_pbsforsendelse.tblpbsfilenames.Add(m_rec_pbsfiles);
                            }
                        }
                        if ((leverancetype == "0602"))
                        {
                            // -- Leverance 0602*********
                            // -- Bestem Sektions Type
                            if ((sektion == ""))
                            {
                                if ((rec.Substring(0, 5) == "BS012"))
                                {
                                    // -- Sektion Start
                                    sektion = rec.Substring(13, 4);
                                }
                                else if (!((rec.Substring(0, 5) == "BS992") || (rec.Substring(0, 5) == "BS002")))
                                {
                                    throw new Exception("243 - Første record er ikke en Sektions start record");
                                }
                            }
                            if ((rec.Substring(0, 5) == "BS002"))
                            {
                                // -- Leverance start
                                // -- BEHANDL: Leverance start
                            }
                            else if ((sektion == "0211"))
                            {
                                // -- Sektion 0211 Betalingsinformation
                                if (((rec.Substring(0, 5) == "BS012") &&
                                     (rec.Substring(13, 4) == "0211")))
                                {
                                    // -- Sektion Start
                                    // -- BEHANDL: Sektion Start
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0236")))
                                {
                                    // -- Gennemf?rt automatisk betaling
                                    // -- BEHANDL: Gennemf?rt automatisk betaling
                                    read042(sektion, "0236", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0237")))
                                {
                                    // -- Afvist betaling
                                    // -- BEHANDL: Afvist betaling
                                    read042(sektion, "0237", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0238")))
                                {
                                    // -- Afmeldt betaling
                                    // -- BEHANDL: Afmeldt betaling
                                    read042(sektion, "0238", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0239")))
                                {
                                    // -- Tilbagef?rt betaling
                                    // -- BEHANDL: Tilbagef?rt betaling
                                    read042(sektion, "0239", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS092") &&
                                          (rec.Substring(13, 4) == "0211")))
                                {
                                    // -- Sektion S**t
                                    // -- BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("244 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                }
                            }
                            else if ((sektion == "0215"))
                            {
                                // -- Sektion 0215 FI-Betalingsinformation
                                if (((rec.Substring(0, 5) == "BS012") &&
                                     (rec.Substring(13, 4) == "0215")))
                                {
                                    // -- Sektion Start
                                    // -- BEHANDL: Sektion Start
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0297")))
                                {
                                    // -- Gennemf?rt FI-betaling
                                    // -- BEHANDL: Gennemf?rt FI-betaling
                                    read042(sektion, "0297", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS042") &&
                                          (rec.Substring(13, 4) == "0299")))
                                {
                                    // -- Tilbagef?rt FI-betaling
                                    // -- BEHANDL: Tilbagef?rt FI-betaling
                                    read042(sektion, "0299", rec);
                                }
                                else if (((rec.Substring(0, 5) == "BS092") &&
                                          (rec.Substring(13, 4) == "0215")))
                                {
                                    // -- Sektion S**t
                                    // -- BEHANDL: Sektion S**t
                                    sektion = "";
                                }
                                else
                                {
                                    throw new Exception("245 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                                }
                            }
                            else if ((rec.Substring(0, 5) == "BS992"))
                            {
                                // -- Leverance s**t
                                // -- BEHANDL: Leverance S**t
                                leverancetype = "";
                            }
                            else
                            {
                                throw new Exception("246 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                            }
                        }
                        else
                        {
                            throw new Exception("247 - Rec# " + rstpbsfile.seqnr + " ukendt: " + rec);
                        }
                    }  // s**t rstpbsfile

                    // -- Update indbetalingsbelob
                    foreach (tblbet rec_bet in m_rec_frapbs.tblbets)
                    {
                        var SumIndbetalingsbelob = (
                            from c in rec_bet.tblbetlins
                            group c by c.betid into g
                            select new { Betid = g.Key, SumIndbetalingsbelob = g.Sum(c => c.indbetalingsbelob) }
                            ).First().SumIndbetalingsbelob;

                        rec_bet.indbetalingsbelob = SumIndbetalingsbelob;
                    }
                }
                catch (Exception e)
                {
                    switch (e.Message.Substring(0, 3))
                    {
                    case "241":       //241 - Første record er ikke en Leverance start record
                    case "242":       //242 - Leverancen er indlæst tidligere
                    case "243":       //243 - Første record er ikke en Sektions start record
                    case "244":       //244 - Record ukendt
                    case "245":       //245 - Record ukendt
                    case "246":       //246 - Record ukendt
                    case "247":       //247 - Record ukendt
                        AntalFiler--;
                        break;

                    default:
                        throw;
                    }
                }
            }  // s**t rstpbsfiles
            p_dbData3060.SubmitChanges();
            return(AntalFiler);
        }
Example #5
0
 partial void Deletetblpbsforsendelse(tblpbsforsendelse instance);
Example #6
0
 partial void Updatetblpbsforsendelse(tblpbsforsendelse instance);
Example #7
0
 partial void Inserttblpbsforsendelse(tblpbsforsendelse instance);