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); } }
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(); }