Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        public void AddLine(string ProductId, string Text, DateTime PeriodBegin, DateTime PeriodEnd, string Unit, decimal Amount, decimal Price, decimal Total, string Notes)
        {
            OrderLine line = new OrderLine (this);

            line.ProductId = ProductId;
            line.Sort = this._orderlines.Count;
            line.Text = Text;
            line.PeriodBegin = PeriodBegin;
            line.PeriodEnd = PeriodEnd;
            line.Unit = Unit;
            line.Amount = Amount;
            line.Price = Price;
            line.Total = Total;
            line.Notes = Notes;

            this._orderlines.Add (line);
        }