Beispiel #1
0
        private string getVaretekst(tblactebisfaktura recActebisfaktura, tblactebisordre recActebisordre, bool bVareforbrug)
        {
            string Tekst = recActebisordre.beskrivelse.Trim();

            if (!bOmkostningsVarenr(recActebisordre.varenr))
            {
                if (bVareforbrug)
                {
                    if ((recActebisfaktura.ordreref != null) && (recActebisfaktura.ordreref.Length > 0))
                    {
                        Tekst += ". Indkøbsordre: " + recActebisfaktura.ordreref.Trim();
                    }
                }
                if ((recActebisordre.sku != null) && (recActebisordre.sku.Length > 0))
                {
                    Tekst += ". Producent varenr: " + recActebisordre.sku.Trim();
                }
                if ((recActebisordre.serienr != null) && (recActebisordre.serienr.Length > 0))
                {
                    Tekst += ". Serienr: " + recActebisordre.serienr.Trim();
                }
                if ((recActebisordre.producent != null) && (recActebisordre.producent.Length > 0))
                {
                    Tekst += ". Producent: " + recActebisordre.producent.Trim();
                }
            }
            if (Tekst.Length > 512)
            {
                return(Tekst.Substring(0, 511));
            }
            else
            {
                return(Tekst);
            }
        }
Beispiel #2
0
        private void Copy2NyFakturaToolStripButton_Click(object sender, EventArgs e)
        {
            bool bVareforbrug = true;
            tblactebisfaktura recActebisfaktura = bsTblactebisfaktura.Current as tblactebisfaktura;

            if (recActebisfaktura.leveringsadresse.ToUpper().Contains("HAFSJOLD"))
            {
                DialogResult result = DotNetPerls.BetterDialog.ShowDialog(
                    "Trans2Summa3060",                                                             //titleString
                    " JA: Dette er en Hafsjold Data ApS anskaffelse.\nNEJ: Dette et vareforbrug.", //bigString
                    null,                                                                          //smallString
                    "JA",                                                                          //leftButton == OK
                    "NEJ",                                                                         //rightButton == Cancel
                    global::Trans2Summa3060.Properties.Resources.Message_info);                    //iconSet

                if (result == DialogResult.OK)
                {
                    bVareforbrug = false;
                }
            }
            tblwfak recWfak = new tblwfak
            {
                sk               = "K",
                dato             = recActebisfaktura.ordredato,
                konto            = 200064,
                kreditorbilagsnr = recActebisfaktura.fakturanr
            };

            foreach (tblactebisordre recActebisordre in recActebisfaktura.tblactebisordres)
            {
                tblwfaklin recWfaklin = new tblwfaklin
                {
                    antal      = recActebisordre.antal,
                    enhed      = "stk",
                    pris       = recActebisordre.stkpris,
                    varenr     = recActebisordre.varenr.ToString(),
                    nettobelob = recActebisordre.antal * recActebisordre.stkpris,
                    tekst      = getVaretekst(recActebisfaktura, recActebisordre, bVareforbrug),
                    konto      = getVarenrKonto(recActebisordre.varenr, bVareforbrug),
                    momskode   = KarKontoplan.getMomskode(getVarenrKonto(recActebisordre.varenr, bVareforbrug))
                };
                recWfak.tblwfaklins.Add(recWfaklin);
            }

            FrmMain frmMain = this.ParentForm as FrmMain;

            try
            {
                FrmNyfaktura frmNyfaktura = frmMain.GetChild("Ny faktura") as FrmNyfaktura;
                frmNyfaktura.AddNyActebisFaktura(recWfak);
            }
            catch
            {
                Program.dbDataTransSumma.tblwfaks.InsertOnSubmit(recWfak);
                Program.dbDataTransSumma.SubmitChanges();
            }
        }
Beispiel #3
0
        public void load()
        {
            var qry = from w in this
                      where w.Ordrestatus == "lukket"
                      join a in Program.dbDataTransSumma.tblactebisordres
                      on new
            {
                w.Ordrenr,
                w.Pos,
            }
            equals new
            {
                Ordrenr = a.ordrenr,
                Pos     = a.pos,
            }
            into actebisordre
            from a in actebisordre.DefaultIfEmpty(new tblactebisordre {
                pid = 0, ordrenr = null
            })
            where a.ordrenr == null
            orderby w.Fakturanr, w.Pos
            select w;


            int antal         = qry.Count();
            int?lastFakturanr = null;
            tblactebisfaktura recActebisfaktura = null;

            foreach (var w in qry)
            {
                if ((w.Fakturanr != lastFakturanr) && (w.Fakturanr != null))
                {
                    try
                    {
                        recActebisfaktura = (from f in Program.dbDataTransSumma.tblactebisfakturas where f.fakturanr == w.Fakturanr select f).First();
                    }
                    catch
                    {
                        recActebisfaktura = new tblactebisfaktura
                        {
                            import           = true,
                            ordredato        = w.Ordredato,
                            fakturanr        = w.Fakturanr,
                            ordrenr          = w.Ordrenr,
                            ordreref         = w.Ordreref,
                            ordrebelob       = w.Ordrebelob,
                            ordrestatus      = w.Ordrestatus,
                            leveringsadresse = w.Leveringsadresse,
                        };
                        Program.dbDataTransSumma.tblactebisfakturas.InsertOnSubmit(recActebisfaktura);
                    }
                }

                tblactebisordre recActebisordre = new tblactebisordre
                {
                    ordrenr        = w.Ordrenr,
                    pos            = w.Pos,
                    antal          = w.Antal,
                    varenr         = w.Varenr,
                    sku            = w.Sku,
                    beskrivelse    = w.Beskrivelse,
                    ordrerefpos    = w.Ordrerefpos,
                    stkpris        = w.Stkpris,
                    leveringsnr    = w.Leveringsnr,
                    serienr        = w.Serienr,
                    ordrestatuspos = w.Ordrestatuspos,
                    producent      = w.Producent,
                };
                recActebisfaktura.tblactebisordres.Add(recActebisordre);
                lastFakturanr = w.Fakturanr;
            }
            Program.dbDataTransSumma.SubmitChanges();
        }