public void Save() { // If OrderLine is new, we need to fill in alot of initial data. // TEMP1 if (this._temp1) { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Insert); qb.Table ("ordlinie"); qb.Columns ( "dataset", "lxbenummer", "sidstrettet", "nummer", "linienr", "varenummer", "lokation", "antal", "pris", "rabat", "belxb", "tekst", "enhed", "moms", "levernu", "oprettet", "levering", "bekrxftet", "konto", "serienummer", "leveret", "faktureret", "leveretdkk", "transaktion", "kostpris", "sletstatistik", "sletafgift", "liniestatus", "lagerstatus", "medarbejder", "samlerefid", "ordreref", "handelskode", "antalfysisk", "fjernlistekode", "prisenhed" ); qb.Values ( "DAT", // datasaet int.Parse (this._id), // lxbenummer String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet this._orderid.PadLeft (10, ' '), // nummer this._sort, // linienr this._productid, // varenummer string.Empty, // lokation this._amount, // antal this._price, // pris 0, // rabat this._total, // belxb this._text, // tekst this._unit, // enhed "U25", // moms 1, // levernu String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // oprettet String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // levering String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // bekrxftet string.Empty, // konto string.Empty, // serienummer 0, // leveret 0, // faktureret 0, // leveretdkk 0, // transaktion 0, // kostpris 0, // sletstatistik string.Empty, // sletafgift 2, // liniestatus 2, // lagerstatus string.Empty, // medarbejder 0, // samlerefid string.Empty, // ordreref string.Empty, // handelskode 0, // antalfysisk 0, // fjernlistekode 1 // prisenhed ); Query query = Runtime.DBConnection.Query (qb.QueryString); Console.WriteLine (qb.QueryString); if (query.AffectedRows == 0) { // Exception: OrderLineSave throw new Exception (string.Format (Strings.Exception.OrderLineSave, this._id)); } query.Dispose (); query = null; qb = null; // TEMP1 this._temp1 = false; } // If OrderLine is not new, just update the fields needed. else { this._updatetimestamp = SNDK.Date.CurrentDateTimeToTimestamp (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Update); qb.Table ("ordlinie"); qb.Columns ( "sidstrettet", "varenummer", "linienr", "antal", "pris", "belxb", "tekst", "enhed" ); qb.Values ( String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet this._productid, // varenummer this._sort, // linienr this._amount, // antal this._price, // pris this._total, // belxb this._text, // tekst this._unit // enhed ); qb.AddWhere ("lxbenummer like '%"+ this._id +"'"); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: OrderLineSave throw new Exception (string.Format (Strings.Exception.OrderLineSave, this._id)); } query.Dispose (); query = null; qb = null; } // Save notes. if (this._notes != string.Empty) { // Remove old notes. { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Delete); qb.Table ("notat"); qb.AddWhere ("notatrecid = '"+ this._id +"'"); Query query = Runtime.DBConnection.Query (qb.QueryString); query.Dispose (); query = null; qb = null; } // Write new notes. { int lineno = 0; foreach (string note in this._notes.Split ("\n".ToCharArray (), StringSplitOptions.RemoveEmptyEntries)) { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Insert); qb.Table ("notat"); qb.Columns ( "dataset", "lxbenummer", "sidstrettet", "notatfileid", "notatrecid", "linienummer", "tekst", "dato" ); qb.Values ( "DAT", // datasaet Helpers.NewSequenceNumber (), // lxbenummer String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet "128", // notatfileid this._id, // notatrecid lineno*2, // linienummer note, // tekst String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)) // dato ); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: OrderLineSave // throw new Exception (string.Format (Strings.Exception.OrderLineSave, this._id)); } query.Dispose (); query = null; qb = null; } } } // if (trim($line['note']) != ""){ // $split = explode("\n", $line['note']); // $o = 1; // foreach($split as $part){ // mssql_query("INSERT INTO notat VALUES ('DAT', '".$this->get_lxbenummer()."', '".strftime("%Y-%m-%d")." 00:00:00.000', 128, ".$LXBE.", ".($o*2).", '".$part."', '".strftime("%Y-%m-%d")." 00:00:00.000')"); // $o++; // } // } }
public static void Set(string Url, string XmlResponse) { QueryBuilder qb; qb = new QueryBuilder (QueryBuilderType.Insert); qb.Table (DatabaseTableName); qb.Columns ("id", "createtimestamp", "url", "xmlresponse"); qb.Values (Guid.NewGuid (), SNDK.Date.CurrentDateTimeToTimestamp (), Url, XmlResponse); Query query = DbConnection.Query (qb.QueryString); query.Dispose(); query = null; qb = null; Flush (); }
public void Save() { // TODO: This should be fixed. int gebyrfm = 0; if (this._debitor.Url == string.Empty || this._debitor.Url == "") { gebyrfm = 30; } // If Order has not yet been saved, we need to insert a new record. // TEMP2 if (this._temp2) { int sequencenumber = C5.Helpers.NewSequenceNumber (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Insert); qb.Table ("ordkart"); qb.Columns ( "dataset", "lxbenummer", "sidstrettet", "lxs", "nummer", "sxgenavn", "oprettet", "leveres", "konto", "navn", "adresse1", "adresse2", "postby", "land", "attention", "telefon", "telefax", "fakturakonto", "gruppe", "fastrabat", "prisgruppe", "rabatgruppe", "kasserabat", "valuta", "sprog", "betaling", "levering", "spxrret", "sxlger", "moms", "beholdning", "afdeling", "gironummer", "momsnummer", "billede", "levering1", "levering2", "levering3", "levering4", "levland", "deresref", "vorref", "ordre", "momsberegnes", "momsberegnet", "rabat", "afgiftfm", "gebyrfm", "afrunding", "momsbelxb", "afgiftem", "gebyrem", "fakturatotal", "liniemoms", "transaktion", "sletstatistik", "slettransport", "godkendt", "lagerstatus", "fakturafxlgeseddel", "fakturafxlgeseddeldato", "kontant", "listekode", "linierabat", "varebelxb", "momsgrundlag", "handelskode", "transkode", "enummer", "email", "levemail", "betalingsid" ); qb.Values ( "DAT", // dataset sequencenumber, // lxbenummer String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet 0, // lxs this._id.PadLeft (10, ' '), // nummer "Webordre #"+ this._id, // sxgenavn String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // oprettet String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // leveres this._debitor.Id.PadLeft (10, ' '), // konto this._debitor.Name, // navn this._debitor.Address1, // address1 this._debitor.Address2, // address2 this._debitor.PostCode +" "+ this._debitor.City, // postby this._debitor.Country, // land this._debitor.Attention, // attention this._debitor.Phone, // telefon this._debitor.Fax, // telefax this._debitor.Id.PadLeft (10, ' '), // fakturakonto string.Empty, // gruppe 0, // fastrabat "Salg", // prisgruppe string.Empty, // rabatgruppe string.Empty, // kasserabat "DKK", // valuta 0, // sprog this._debitor.CreditPolicy.Id, // betaling string.Empty, // levering 0, // spxrret string.Empty, //sxlger this._debitor.VatCode.Id, // moms 0, // beholdning string.Empty, // afdeling string.Empty, // gironummer this._debitor.VatNo, // momsnummer string.Empty, // billede string.Empty, // levering1 string.Empty, // levering2 string.Empty, // levering3 string.Empty, // levering4 string.Empty, // levland string.Empty, // deresref string.Empty, // vorref string.Empty, // ordre 0, // momsberegnes 0, // momsberegnet 0, // rabat 0, // afgiftfm gebyrfm, // gebyrfm 0, // afrunding 0, // momsbelxb 0, // afgiftem 0, // gebyrem 0, // fakturatotal 0, // liniemoms 0, // transaktion 0, // sletstatestik 0, // slettransport 1, // godkendt 2, // lagerstatus string.Empty, // fakturafxlgeseddel String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._createtimestamp)), // fakturafxlgeseddeldato 0, // kontant 0, // listekode 0, // linierabat 0, // varebelxb 0, // momsgrundlag string.Empty, // handelskode string.Empty, // transkode string.Empty, // enummer this._debitor.Email, // email string.Empty, // levmail string.Empty // betalingstid ); Console.WriteLine (qb.QueryString); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: OrderSave throw new Exception (string.Format (Strings.Exception.OrderSave, this._id)); } query.Dispose (); query = null; qb = null; // TEMP2 this._temp2 = false; } // If OrderLine has allready been saved before we only need to update the record. else { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Update); qb.Table ("ordkart"); qb.Columns ( "sidstrettet", "konto", "navn", "adresse1", "adresse2", "postby", "land", "attention", "telefon", "telefax", "email", "fakturakonto", "betaling", "momsnummer", "moms", "gebyrfm" ); qb.Values ( String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet this._debitor.Id.PadLeft (10, ' '), // konto this._debitor.Name, // navn this._debitor.Address1, // address1 this._debitor.Address2, // address2 this._debitor.PostCode +" "+ this._debitor.City, // postby this._debitor.Country, // land this._debitor.Attention, // attention this._debitor.Phone, // telefon this._debitor.Fax, // telefax this._debitor.Email, // email this._debitor.Id.PadLeft (10, ' '), // fakturakonto this._debitor.CreditPolicy, // betaling this._debitor.VatNo, // momsnummer this._debitor.VatCode, // moms gebyrfm // gebyrfm ); qb.AddWhere ("nummer like '%"+ this._id +"'"); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: OrderSave throw new Exception (string.Format (Strings.Exception.OrderSave, this._id)); } query.Dispose (); query = null; qb = null; } // Save orderlines added. foreach (OrderLine line in this._orderlines) { line.Save (); } // Delete orderlines removed. // TEMP1 foreach (string orderlineid in this._temp1.Split (";".ToCharArray (), StringSplitOptions.RemoveEmptyEntries)) { try { OrderLine.Delete (orderlineid); } catch { // This will catch deletion of orderlines not yet saved. } } }
public void Save() { // If Debitor has not yet been saved, we need to insert a new record. // TEMP1 if (this._temp1) { int sequencenumber = C5.Helpers.NewSequenceNumber (); QueryBuilder qb = new QueryBuilder (QueryBuilderType.Insert); qb.Table ("debkart"); qb.Columns ( "dataset", "lxbenummer", "sidstrettet", "lxs", "konto", "navn", "adresse1", "adresse2", "postby", "land", "attention", "telefon", "telefax", "fakturakonto", "gruppe", "fastrabat", "godkendt", "prisgruppe", "rabatgruppe", "kasserabat", "billede", "valuta", "sprog", "betaling", "levering", "spxrret", "sxlger", "moms", "sletstatistik", "gironummer", "momsnummer", "rente", "afdeling", "rykkerkode", "engangskunde", "beholdning", "ediadresse", "saldo", "saldo30", "saldo60", "saldo90", "saldo120", "saldoover120", "forfalden", "beregnet", "saldomax", "saldodkk", "sxgenavn", "slettransport", "kontant", "indbetalmxde", "ordregruppe", "projektgruppe", "handelskode", "transkode", "email", "url", "mobil", "kraknr" ); qb.Values ( "DAT", // dataset sequencenumber, // lxbenummer String.Format ("{0:yyyy-MM-dd} 00:00:00.000", SNDK.Date.TimestampToDateTime (this._updatetimestamp)), // sidstrettet 0, // lxs this._id.PadLeft (10, ' '), // konto this._name, // navn this._address1, // adresse1 this._address2, // address2 this._postcode +" "+ this._city, // postby this._country, // land this._attention, // attention this._phone, // telefon this._fax, // fax string.Empty, // fakturakonto string.Empty, // gruppe 0, // fastrabat 0, // godkendt string.Empty, // prisgruppe string.Empty, // rabatgruppe string.Empty, // kasserabat string.Empty, // billede "DKK", // valuta 0, // sprog this._creditpolicyid, // betaling string.Empty, // levering 0, // spxrret string.Empty, // sxlger this._vatcodeid, // moms 0, // sletstatistik string.Empty, // gironummer this._vatno, // momsnummer string.Empty, // rente string.Empty, // afdeling 0, // rykkerkode 0, // engangskunde 0, // beholdning string.Empty, // ediadresse 0, // saldo 0, // saldo30 0, // saldo60 0, // saldo90 0, // saldo120 0, // saldoover120 0, // forfalden "1900-01-01 00:00:00.000", // beregnet 0, // saldomax 0, // saldodkk string.Empty, // sxgenavn 0, // slettransport 0, // kontant string.Empty, // indbetalmxde string.Empty, // ordregruppe 0, // projektgruppe 0, // handelskode string.Empty, // transkode this._email, // email string.Empty, // url string.Empty, // mobil string.Empty // kraknr ); Console.WriteLine (qb.QueryString); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: DebitorSave throw new Exception (string.Format (Strings.Exception.DebitorSave, this._id)); } query.Dispose (); query = null; qb = null; // TEMP1 this._temp1 = false; } // If OrderLine has allready been saved before we only need to update the record. else { QueryBuilder qb = new QueryBuilder (QueryBuilderType.Update); qb.Table ("debkart"); qb.Columns ( "navn", "adresse1", "adresse2", "postby", "land", "attention", "telefon", "telefax", "email", "url", "betaling", "momsnummer", "moms" ); qb.Values ( this._name, // navn this._address1, // adresse1 this._address2, // address2 this._postcode +" "+ this._city, // postby this._country, // land this._attention, // attention this._phone, // telefon this._fax, // fax this._email, // email this._url, // url this._creditpolicyid, // betaling this._vatno, // momsnummer this._vatcodeid // moms ); qb.AddWhere ("konto like '%"+ this._id +"'"); Query query = Runtime.DBConnection.Query (qb.QueryString); if (query.AffectedRows == 0) { // Exception: DebitorSave throw new Exception (string.Format (Strings.Exception.DebitorSave, this._id)); } query.Dispose (); query = null; qb = null; } }