public OrdersForm(services.Fiscal setFiscal, string setCashierName = "Unknow") { fiscal = setFiscal; cashierName = setCashierName; InitializeComponent(); orders = new repositories.Order(db); dataMapper = new services.DataMapper(db); dataMapper.FillOrders(orders); foreach (entities.Order order in orders.GetList()) { ordersProvider.Add(order); } ordersListGridView.DataSource = ordersProvider; if (orders.GetList().Count() > 0) { orderElementsBox.Visible = true; entities.Order order = orders.GetList()[0]; elementsProvider = new tools.OrderElementProvider(); foreach (entities.OrderElement orderElement in order.GetElements()) { elementsProvider.Add(orderElement); } elementsListGridView.DataSource = elementsProvider; } }
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(); }
private void ordersListGridView_CellClick(object sender, DataGridViewCellEventArgs e) { orderElementsBox.Visible = true; int index = ordersListGridView.CurrentCell.RowIndex; entities.Order order = orders.GetList()[index]; elementsProvider = new tools.OrderElementProvider(); foreach (entities.OrderElement orderElement in order.GetElements()) { elementsProvider.Add(orderElement); } elementsListGridView.DataSource = elementsProvider; }