public static OrderLine Load(string Id) { bool success = false; OrderLine result = new OrderLine (); { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("ordlinie"); qb.Columns ( "sidstrettet", "varenummer", "linienr", "antal", "pris", "belxb", "tekst", "enhed", "oprettet" ); qb.AddWhere ("lxbenummer like '"+ Id +"'"); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { result._id = Id; result._createtimestamp = SNDK.Date.DateTimeToTimestamp (query.GetDateTime (qb.ColumnPos ("oprettet"))); result._productid = query.GetString (qb.ColumnPos ("varenummer")); result._sort = query.GetDecimal (qb.ColumnPos ("linienr")); result._amount = query.GetDecimal (qb.ColumnPos ("antal")); result._price = query.GetDecimal (qb.ColumnPos ("pris")); result._total = query.GetDecimal (qb.ColumnPos ("belxb")); result._text = query.GetString (qb.ColumnPos ("tekst")); result._unit = query.GetString (qb.ColumnPos ("enhed")); result._updatetimestamp = SNDK.Date.DateTimeToTimestamp (query.GetDateTime (qb.ColumnPos ("sidstrettet"))); success = true; } } query.Dispose (); query = null; qb = null; if (!success) { // Exception: Exception.OrderLineLoadId throw new Exception (string.Format (Strings.Exception.OrderLineLoadId, Id)); } } // Load notes. { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("notat"); qb.Columns ( "tekst" ); qb.AddWhere ("notatrecid = '"+ Id +"'"); qb.OrderBy ("linienummer", QueryBuilderOrder.Accending); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { while (query.NextRow ()) { result._notes += query.GetString (qb.ColumnPos ("tekst")) +"\n"; } } query.Dispose (); query = null; qb = null; result._notes = result._notes.TrimEnd ("\n".ToCharArray ()); } // TEMP1 result._temp1 = false; return result; }
// 2600 public static void GetInvoice(int invoice) { { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("debjournal"); qb.Columns ( "dato", "forfald", "saldodkk", "momsberegnes", "moms", "transaktion" ); qb.AddWhere ("faktura = "+ invoice.ToString ()); Query query = qnaxLib.Runtime.C5Connection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { Console.WriteLine (query.GetDateTime (qb.ColumnPos ("dato"))); Console.WriteLine (query.GetDateTime (qb.ColumnPos ("forfald"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("saldodkk"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("momsberegnes"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("moms"))); Console.WriteLine (query.GetInt (qb.ColumnPos ("transaktion"))); } } query.Dispose (); } { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("ordkartarkiv"); qb.Columns ( "konto", "navn", "adresse1", "adresse2", "postby", "attention" ); qb.AddWhere ("fakturafxlgeseddel = "+ invoice.ToString ()); Query query = qnaxLib.Runtime.C5Connection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { Console.WriteLine (query.GetString (qb.ColumnPos ("konto"))); Console.WriteLine (query.GetString (qb.ColumnPos ("navn"))); Console.WriteLine (query.GetString (qb.ColumnPos ("adresse1"))); Console.WriteLine (query.GetString (qb.ColumnPos ("adresse2"))); Console.WriteLine (query.GetString (qb.ColumnPos ("postby"))); Console.WriteLine (query.GetString (qb.ColumnPos ("attention"))); } } query.Dispose (); } { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("debpost"); qb.Columns ( "posttype" ); qb.AddWhere ("bilag = "+ invoice.ToString ()); Query query = qnaxLib.Runtime.C5Connection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { Console.WriteLine (query.GetInt (qb.ColumnPos ("posttype"))); } } query.Dispose (); } // $nquery = mssql_query("SELECT * FROM ORDLINIEARKIV WHERE TRANSAKTION = ".$data['TRANSAKTION']." ORDER BY LINIENR ASC"); // while($ndata = mssql_fetch_array($nquery)){ // $fquery = mssql_query("SELECT * FROM NOTAT WHERE NOTATRECID=".$ndata['LXBENUMMER']); // while($fdata = mssql_fetch_array($fquery)){ // if (substr($fdata['TEKST'], 1, 1) == ""){ // $notelines[] = ""; // } else { // $notelines[] = $fdata['TEKST']; // } // $totalcount++; // } // $note = @implode("\n", $notelines); // // if (substr($ndata['ENHED'], 1) == ""){ // $enhed = ""; // } else { // $enhed = $ndata['ENHED']; // } // // $line = array( // "id" => $ndata['LINIENR'], // "itemnumber" => $ndata['VARENUMMER'], // "itemamount" => $ndata['ANTAL'], // "itemprice" => $ndata['PRIS'], // "itemdiscount" => $ndata['RABAT'], // "linetotal" => $ndata['BELXB'], // "linetext" => $ndata['TEKST'], // "linenote" => $note, // "itemunit" => $enhed // ); // $pricetotal = $pricetotal + $ndata['BELXB']; // $totalcount++; // $return['lines'][] = $line; // unset($notelines); // } // $return['totalcount'] = $totalcount; // return $return; // 11808 { // $nquery = mssql_query("SELECT * FROM ORDLINIEARKIV WHERE TRANSAKTION = ".$data['TRANSAKTION']." ORDER BY LINIENR ASC"); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("ordliniearkiv"); qb.Columns ( "linienr", "varenummer", "antal", "enhed", "pris", "rabat", "belxb", "tekst", "lxbenummer" ); qb.AddWhere ("transaktion = "+ "11808"); qb.OrderBy ("linienr", QueryBuilderOrder.Accending); Query query = qnaxLib.Runtime.C5Connection.Query (qb.QueryString); if (query.Success) { while (query.NextRow ()) { Console.WriteLine ("---"); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("linienr"))); Console.WriteLine (query.GetString (qb.ColumnPos ("varenummer"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("antal"))); Console.WriteLine (query.GetString (qb.ColumnPos ("enhed"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("pris"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("rabat"))); Console.WriteLine (query.GetDecimal (qb.ColumnPos ("belxb"))); Console.WriteLine (query.GetString (qb.ColumnPos ("tekst"))); Console.WriteLine (query.GetInt (qb.ColumnPos ("lxbenummer"))); int test = query.GetInt (qb.ColumnPos ("lxbenummer")); QueryBuilder qb2 = new QueryBuilder (QueryBuilderType.Select); qb2.Table ("notat"); qb2.Columns ( "tekst" ); qb2.AddWhere ("notatrecid = "+ test.ToString ()); Query query2 = qnaxLib.Runtime.C5Connection.Query (qb2.QueryString); if (query2.Success) { if (query2.NextRow ()) { Console.WriteLine ("\t "+ query2.GetString (qb2.ColumnPos ("tekst"))); } } query2.Dispose (); Console.WriteLine ("---"); } } query.Dispose (); } }
public static Invoice Get(int invoice) { Invoice result = new Invoice (); // GET JOURNAL { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("debjournal"); qb.Columns ( "dato", "forfald", "saldodkk", "momsberegnes", "moms", "transaktion" ); qb.AddWhere ("faktura = "+ invoice.ToString ()); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { result._transactionid = query.GetInt (qb.ColumnPos ("transaktion")); result._date = query.GetDateTime (qb.ColumnPos ("dato")); result._duedate = query.GetDateTime (qb.ColumnPos ("forfald")); result._total = query.GetDecimal (qb.ColumnPos ("saldodkk")); result._subtotal = query.GetDecimal (qb.ColumnPos ("momsberegnes")); result._vat = query.GetDecimal (qb.ColumnPos ("moms")); } } query.Dispose (); query = null; qb = null; } // GET ORDKARTARKIV { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("ordkartarkiv"); qb.Columns ( "konto", "navn", "adresse1", "adresse2", "postby", "attention" ); qb.AddWhere ("fakturafxlgeseddel = "+ invoice.ToString ()); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { result._accountid = query.GetString (qb.ColumnPos ("konto")); result._name = query.GetString (qb.ColumnPos ("navn")); result._address1 = query.GetString (qb.ColumnPos ("adresse1")); result._address2 = query.GetString (qb.ColumnPos ("adresse2")); result._zipcode = query.GetString (qb.ColumnPos ("postby")); result._city = query.GetString (qb.ColumnPos ("postby")); result._attention = query.GetString (qb.ColumnPos ("attention")); } } query.Dispose (); query = null; qb = null; } // GET DEBPOST { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("debpost"); qb.Columns ( "posttype" ); qb.AddWhere ("bilag = "+ invoice.ToString ()); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { if (query.NextRow ()) { if (query.GetInt (qb.ColumnPos ("posttype")) == 1) { result._type = Enums.InvoiceType.Invoice; } else if (query.GetInt (qb.ColumnPos ("posttype")) == 2) { result._type = Enums.InvoiceType.InvoiceCredit; } } } query.Dispose (); query = null; qb = null; } // GET ORDLINEARKIV { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table ("ordliniearkiv"); qb.Columns ( "linienr", "varenummer", "antal", "enhed", "pris", "rabat", "belxb", "tekst", "lxbenummer" ); qb.AddWhere ("transaktion = "+ result._transactionid); qb.OrderBy ("linienr", QueryBuilderOrder.Accending); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { while (query.NextRow ()) { InvoiceLine line = new InvoiceLine (); line._linenumber = query.GetDecimal (qb.ColumnPos ("linienr")); line._partnumber = query.GetString (qb.ColumnPos ("varenummer")); line._amount = query.GetDecimal (qb.ColumnPos ("antal")); line._price = query.GetDecimal (qb.ColumnPos ("pris")); line._unit = query.GetString (qb.ColumnPos ("enhed")); line._discount = query.GetDecimal (qb.ColumnPos ("rabat")); line._total = query.GetDecimal (qb.ColumnPos ("belxb")); line._text = query.GetString (qb.ColumnPos ("tekst")); line._sequenceno = query.GetInt (qb.ColumnPos ("lxbenummer")); // GET NOTAT { QueryBuilder qb2 = new QueryBuilder (QueryBuilderType.Select); qb2.Table ("notat"); qb2.Columns ( "tekst" ); qb2.AddWhere ("notatrecid = "+ line._sequenceno.ToString ()); Query query2 = Runtime.DBConnection.Query (qb2.QueryString); if (query2.Success) { if (query2.NextRow ()) { line._note = query2.GetString (qb2.ColumnPos ("tekst")); } } query2.Dispose (); query2 = null; qb2 = null; } result._lines.Add (line); } } query.Dispose (); query = null; qb = null; } return result; }
public static List<Location> List() { List<Location> result = new List<Location> (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select); qb.Table (DatabaseTableName); qb.Columns ("id"); qb.OrderBy ("createtimestamp", QueryBuilderOrder.Accending); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.Success) { while (query.NextRow ()) { try { result.Add (Load (query.GetGuid (qb.ColumnPos ("id")))); } catch {} } } query.Dispose (); query = null; qb = null; return result; }