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); } }
private void Copy2NyFakturaToolStripButton_Click(object sender, EventArgs e) { bool bVareforbrug = true; Tblactebisfaktura recActebisfaktura = tblactebisfakturaBindingSource.Current as Tblactebisfaktura; if (recActebisfaktura.Leveringsadresse.ToUpper().Contains("HAFSJOLD")) { DialogResult result = DotNetPerls.BetterDialog.ShowDialog( "TransSumma", //titleString " JA: Dette er en Hafsjold Data ApS anskaffelse.\nNEJ: Dette et vareforbrug.", //bigString null, //smallString "JA", //leftButton == OK "NEJ", //rightButton == Cancel global::nsPuls3060.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.Tblactebisordre) { 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.Tblwfaklin.Add(recWfaklin); } FrmMain frmMain = this.ParentForm as FrmMain; try { FrmNyfaktura frmNyfaktura = frmMain.GetChild("Ny faktura") as FrmNyfaktura; frmNyfaktura.AddNyActebisFaktura(recWfak); } catch { Program.dbDataTransSumma.Tblwfak.InsertOnSubmit(recWfak); Program.dbDataTransSumma.SubmitChanges(); } }
public void load() { var qry = from w in this where w.Ordrestatus == "lukket" join a in Program.dbDataTransSumma.Tblactebisordre on new { w.Ordrenr, w.Pos, } equals new { a.Ordrenr, 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.Tblactebisfaktura 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.Tblactebisfaktura.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.Tblactebisordre.Add(recActebisordre); lastFakturanr = w.Fakturanr; } Program.dbDataTransSumma.SubmitChanges(); }