Exemplo n.º 1
0
        public OrderItem GetOrderItem()
        {
            try
            {

                OrderItem oi = new OrderItem();
                oi.Description = txtDescription.Text;
                oi.IsTaxed = cbTaxable.Checked;
                oi.ItemName = cboItems.Text;
                oi.ItemID = cboItems.SelectedValue.ToString();
                if(txtPrice.Text != "")
                    oi.Price = Double.Parse(txtPrice.Text);

                if(txtQuantity.Text != "")
                    oi.Quantity = double.Parse(txtQuantity.Text);

                if(txtTotal.Text != "")
                    oi.Total = double.Parse(txtTotal.Text);

                return oi;
            }
            catch (Exception ex)
            {
                throw new Exception("Error with order item, description is '" + txtDescription.Text + "'.");
            }
        }
Exemplo n.º 2
0
        public List<OrderItem> GetItemsFromDisk()
        {
            List<OrderItem> items = new List<OrderItem>();

            var xItems = _xDocSettings.Root.Element("SalesItems");
            if (xItems == null)
                return items;

            foreach (var item in xItems.Elements("Item"))
            {
                var orderItem = new OrderItem();

                orderItem.Account = item.Attribute("Account").Value;
                orderItem.Description = item.Attribute("Description").Value;
                orderItem.ItemName = item.Attribute("Name").Value;
                orderItem.ItemID = item.Attribute("Id").Value;

                items.Add(orderItem);
            }

            return items;
        }
Exemplo n.º 3
0
        Order XmlToOrder(XElement xOrder)
        {
            Order o = new Order();

            double grandTotal;
            double subTotal;
            double taxes;
            DateTime orderDate;

            if (xOrder.Attribute("Notes") != null)
                o.Notes = xOrder.Attribute("Notes").Value;

            if (double.TryParse(xOrder.Attribute("GrandTotal").Value, out grandTotal))
                o.GrandTotal = grandTotal;

            if (double.TryParse(xOrder.Attribute("SubTotal").Value, out subTotal))
                o.SubTotal = subTotal;

            if (double.TryParse(xOrder.Attribute("Taxes").Value, out taxes))
                o.Taxes = taxes;

            if (DateTime.TryParse(xOrder.Attribute("OrderDate").Value, out orderDate))
                o.OrderDate = orderDate;

            try
            {
                o.PaymentMethod = _util.ParseEnum<Enums.PaymentMethod>(xOrder.Attribute("PaymentMethod").Value);
            }
            catch (Exception)
            {
                o.PaymentMethod = Enums.PaymentMethod.NotSelected;
            }

            var xOrderItems = xOrder.Elements("OrderItem");

            foreach (var xOrderItem in xOrderItems)
            {

                OrderItem oi = new OrderItem();
                oi.Account = xOrderItem.Element("Account").Value;
                oi.Description = xOrderItem.Element("Description").Value;
                oi.ItemName = xOrderItem.Element("ItemName").Value;
                oi.ItemID = xOrderItem.Element("ItemID").Value;

                double price;
                if (double.TryParse(xOrderItem.Element("Price").Value, out price))
                    oi.Price = price;

                double quantity;
                if (double.TryParse(xOrderItem.Element("Quantity").Value, out quantity))
                    oi.Quantity = quantity;

                double total;
                if (double.TryParse(xOrderItem.Element("Total").Value, out total))
                    oi.Total = total;

                bool taxed = false;
                if (bool.TryParse(xOrderItem.Element("IsTaxed").Value, out taxed))
                    oi.IsTaxed = taxed;

                o.OrderItems.Add(oi);
            }
            return o;
        }
Exemplo n.º 4
0
        List<OrderItem> GetServiceItems()
        {
            List<OrderItem> result = new List<OrderItem>();

            try
            {
                IMsgSetRequest msgSetRequest = _qbSession.CreateMsgSetRequest("US", 8, 0);

                msgSetRequest.ClearRequests();
                msgSetRequest.Attributes.OnError = ENRqOnError.roeContinue;

                IItemServiceQuery itemServiceQuery = msgSetRequest.AppendItemServiceQueryRq();

                itemServiceQuery.ORListQuery.ListFilter.ActiveStatus.SetValue(ENActiveStatus.asAll);
                itemServiceQuery.ORListQuery.ListFilter.MaxReturned.SetValue(100);

                IMsgSetResponse msgSetResponse = _qbSession.DoRequests(msgSetRequest);
                if (((msgSetResponse == null) || (msgSetResponse.ResponseList == null)) || (msgSetResponse.ResponseList.Count <= 0))
                {

                    throw new Exception();
                }
                IResponseList responseList = msgSetResponse.ResponseList;
                if (responseList.Count != 1)
                {
                    throw new Exception();
                }
                IResponse response = responseList.GetAt(0);
                if (response == null)
                {
                    throw new Exception();
                }
                if (response.StatusCode != 0)
                {
                    _logger.Log("GetServiceItems status code was " + response.StatusCode.ToString());
                }
                if (response.Type == null)
                {
                    throw new Exception();
                }
                if (response.Detail == null)
                {
                    throw new Exception();
                }
                if (response.Detail.Type == null)
                {
                    throw new Exception();
                }

                if (!(response.Detail is IItemServiceRetList))
                {
                    throw new Exception();
                }

                var itemServiceRetList = (IItemServiceRetList)response.Detail;

                for (int i = 0; i < itemServiceRetList.Count; i++)
                {
                    OrderItem or = new OrderItem();

                    var itemServiceRet = itemServiceRetList.GetAt(i);

                    or.ItemName = itemServiceRet.FullName.GetValue();
                    try
                    {
                        or.Description = itemServiceRet.ORSalesPurchase.SalesOrPurchase.Desc.GetValue();
                    }
                    catch (Exception)
                    {
                        or.Description = "";
                    }
                    or.ItemID = itemServiceRet.ListID.GetValue();
                    or.Account = itemServiceRet.ORSalesPurchase.SalesOrPurchase.AccountRef.FullName.GetValue();
                    or.Price = (double)itemServiceRet.ORSalesPurchase.SalesOrPurchase.ORPrice.Price.GetValue();
                    result.Add(or);
                }

            }
            catch (Exception ex)
            {

                _logger.LogException("Error in GetServiceItems.", ex);
            }
            return result;
        }
Exemplo n.º 5
0
 public void SetOrderItem(OrderItem oi)
 {
     cboItems.SelectedValue = oi.ItemID;
     txtDescription.Text = oi.Description;
     txtPrice.Text = oi.Price.ToString();
     txtQuantity.Text = oi.Quantity.ToString();
     txtTotal.Text = oi.Total.ToString();
     cbTaxable.Checked = oi.IsTaxed;
 }