public void load() { var qry1 = from w in this join b in Program.dbDataTransSumma.tblmobilepays on w.bid equals b.mobilepay_id into bankkonto from b in bankkonto.DefaultIfEmpty(new tblmobilepay { pid = 0, belob = null }) where b.belob == null orderby w.bdato select w; int antal1 = qry1.Count(); foreach (var b in qry1) { tblmobilepay recBankkonto = new tblmobilepay { navn = b.bnavn.Length > 35 ? b.bnavn.Substring(0, 35) : b.bnavn, mobilnummer = b.bmobilnummer.Length > 10 ? b.bmobilnummer.Substring(0, 10) : b.bmobilnummer, belob = b.bbeløb, dato = b.bdato, mobilepay_id = b.bid.Length > 15 ? b.bid.Substring(0, 15) : b.bid, tekst = b.btekst.Length > 50 ? b.btekst.Substring(0, 50) : b.btekst, }; Program.dbDataTransSumma.tblmobilepays.InsertOnSubmit(recBankkonto); } Program.dbDataTransSumma.SubmitChanges(); var qry2 = from w in Program.dbDataTransSumma.tblmobilepays where w.Imported == null orderby w.dato select w; int antal2 = qry2.Count(); foreach (var b in qry2) { if (b.tekst.Length < 3) { b.tekst += " " + b.navn + " " + b.mobilnummer; b.tekst.Trim(); } tblbankkonto recBankkonto = new tblbankkonto { pid = clsPbs.nextval("Tblbankkonto"), bankkontoid = m_bankkontoid, saldo = 0, dato = b.dato, tekst = b.tekst.Length > 50 ? b.tekst.Substring(0, 50) : b.tekst, belob = b.belob, }; b.Imported = true; b.tblbankkontos.Add(recBankkonto); Program.dbDataTransSumma.SubmitChanges(); } }
public void load_Mobilepay() { var qry = from w in this join b in m_dbData3060.tblmobilepays on new { date = w.Date, name = w.Navn, type = w.Type, transaction_id = w.TransaktionsID, belob = w.Belob } equals new { date = b.Date, name = b.Navn, type = b.Type, transaction_id = b.TransaktionsID, belob = b.Belob } into Mobilepaykonto from b in Mobilepaykonto.DefaultIfEmpty(new tblmobilepay { pid = 0, Belob = null }) where b.Belob == null orderby w.Date select w; int iLinenr = 0; int antal = qry.Count(); foreach (var b in qry) { iLinenr++; tblmobilepay recMobilepay = new tblmobilepay { Type = b.Type, Navn = b.Navn, MobilNummer = b.MobilNummer, Belob = b.Belob, MobilePayNummer = b.MobilePayNummer, NavnBetalingssted = b.NavnBetalingssted, Date = b.Date, TransaktionsID = b.TransaktionsID, Besked = b.Besked, Gebyr = b.Gebyr }; m_dbData3060.tblmobilepays.InsertOnSubmit(recMobilepay); m_dbData3060.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict); } }
public int InsertGLDailyJournalLines(IOrderedQueryable <tblbankkonto> qrybankkonto) { var GLDailyJournalLines = 0; var crit = new List <PropValuePair>(); var pair = PropValuePair.GenereteWhereElements("KeyStr", typeof(String), "Dag"); crit.Add(pair); var task1 = m_api.Query <GLDailyJournalClient>(crit); task1.Wait(); var col = task1.Result; var rec_Master = col.FirstOrDefault(); foreach (var bk in qrybankkonto) { tblmobilepay mp = null; var qrymobilepay = from v in m_dbData3060.tblmobilepays where v.pid == bk.mobilepay_pid && (v.Bogfoert == null || v.Bogfoert == false) select v; var qrycount = qrymobilepay.Count(); if (qrycount == 1) { mp = qrymobilepay.First(); } else { continue; } GLDailyJournalLines++; GLDailyJournalLineClient jl = new GLDailyJournalLineClient() { Date = (DateTime)bk.dato, Text = bk.tekst, Account = "5850", }; if (bk.belob > 0) { jl.Debit = (double)bk.belob; } else { jl.Credit = -(double)bk.belob; } switch (mp.Type.ToUpper()) { case "SALG": jl.OffsetAccount = "1004"; break; case "REFUNDERING": jl.OffsetAccount = "1004"; break; case "GEBYR": jl.OffsetAccount = "4471"; break; case "OVERFØRSEL": jl.OffsetAccount = "5840"; break; default: jl.OffsetAccount = "9900"; break; } jl.SetMaster(rec_Master); var task2 = m_api.Insert(jl); task2.Wait(); var err = task2.Result; mp.Bogfoert = true; } m_dbData3060.SubmitChanges(); return(GLDailyJournalLines); }