Example #1
0
        private void AddOrder()
        {
            if (cart.GetElements().Count <= 0)
            {
                return;
            }

            entities.Order order = new entities.Order(0, DateTime.Now.ToString(), cart.GetTotal(), selectedCashierId, selectedClientId, selectedDiscountId);

            foreach (entities.Product product in cart.GetElements())
            {
                entities.OrderElement orderElement = new entities.OrderElement(0, product.GetId(), product.GetName(), product.GetPrice(), product.GetCartCount(), "");

                order.AddElement(orderElement);
            }

            bool ok = true;

            if (Properties.Settings.Default.fiscal)
            {
                byte paymentType;

                if (paymentType0.Checked)
                {
                    paymentType = 0;
                }
                else
                {
                    paymentType = 1;
                }

                ok = FiscalRegister(GetCashierName(), paymentType);
            }

            if (ok)
            {
                cart.Clear();

                if (Properties.Settings.Default.online)
                {
                    int dvizhOrderId = dataExchanger.SendOrder(order);
                    if (dvizhOrderId > 0)
                    {
                        order.SetDvizhId(dvizhOrderId);
                    }
                }

                orders.AddWithSql(order);

                RenderCart();
                ClearClient();
                ClearDiscount();

                paymentType0.Select();
            }

            barCodeBox.Focus();
            barCodeBox.Select();
        }
Example #2
0
        private void canceSelectedElement_Click(object sender, EventArgs e)
        {
            int index = elementsListGridView.CurrentCell.RowIndex;

            entities.OrderElement orderElement = elementsProvider[index];

            orderElement.SetCancelAt(DateTime.Now.ToLongDateString());
            orders.CancelElement(orderElement);

            if (Properties.Settings.Default.fiscal)
            {
                fiscal.SetCashier(cashierName);
                fiscal.Annulate(orderElement);
            }

            elementsListGridView.Update();
            elementsListGridView.Focus();
        }