public void CancelOrder(Order order) { using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // delete record from table CancelOrder(connection, order); } }
public Order AcceptOrder(Order order) { Order acceptedOrder = null; using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // update record in table AcceptOrder(connection, order); // select record from table acceptedOrder = GetOrder(connection, order.Id); } return acceptedOrder; }
private List<Item> GetItems(OracleConnection connection, Order order) { List<Item> items = new List<Item>(); OracleCommand cmd = connection.CreateCommand(); cmd.CommandText = "select v.*, p.pocet from tis_vyrobek v, tis_polozka p" + " where p.vyrobek_id = v.vyrobek_id and p.zakazka_id = :1"; cmd.Parameters.Add(GetNumber(":1", order.Id)); OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { items.Add(new Item { OrderId = order.Id, Order = order, ProductId = reader.GetInt32(0), Product = GetProduct(reader.GetInt32(0), reader.GetString(1), reader.GetDouble(2), reader.GetDouble(3), reader.GetInt32(4)), Count = reader.GetInt32(5) }); } reader.Close(); cmd.Dispose(); return items; }
private void CancelOrder(OracleConnection connection, Order order) { OracleCommand cmd = connection.CreateCommand(); cmd.CommandText = "TIS.storno_zakazka"; cmd.CommandType = CommandType.StoredProcedure; OracleParameter par = cmd.Parameters.Add("p_zakazka_id", OracleType.Number); par.Value = order.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); }
public void SendOrder(Order order) { using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // update record in table SendOrder(connection, order); } }
public Item NewItem(Order order, Product product, int count) { using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // insert record to table InsertItem(connection, order, product, count); } return new Item { OrderId = order.Id, Order = order, ProductId = product.Id, Product = product, Count = count }; }
public double GetOrderTotalPrice(Order order) { double total = 0; using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // select record from table total = GetOrderTotalPrice(connection, order.Id); } return total; }
public List<Item> GetItems(Order order) { List<Item> itemList = null; using (OracleConnection connection = new OracleConnection(connectionString)) { if (connection.State != ConnectionState.Open) connection.Open(); // select records from table itemList = GetItems(connection, order); } return itemList; }
private void InsertItem(OracleConnection connection, Order order, Product product, int count) { OracleCommand cmd = connection.CreateCommand(); cmd.CommandText = "insert into tis_polozka (zakazka_id,vyrobek_id,pocet) values(:1,:2,:3)"; cmd.Parameters.Add(GetNumber(":1", order.Id)); cmd.Parameters.Add(GetNumber(":2", product.Id)); cmd.Parameters.Add(GetNumber(":3", count)); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); cmd.Dispose(); }
private void DeleteOrder(Order order) { try { data.CancelOrder(order); orderList.Remove(order); lbPreviewOrders.SelectedIndex = -1; lbPreviewOrders.ItemsSource = null; lbPreviewOrders.ItemsSource = orderList; } catch { } }
private void CustomerControl_IsVisibleChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e) { if (Visibility == Visibility.Visible) { tabs.SelectedIndex = 0; GetOrderList(); GetProductList(); newOrder = null; lbNewOrderItems.ItemsSource = null; EnableNewOrderButtons(); } }
private void btnNewOrder_Click(object sender, System.Windows.RoutedEventArgs e) { try { newOrder = data.NewOrder(customer); newOrderItemList = data.GetItems(newOrder); lbNewOrderItems.ItemsSource = newOrderItemList; bool found = false; foreach (Order order in orderList) if (order.Id == newOrder.Id) found = true; if (!found) { orderList.Add(newOrder); lbPreviewOrders.SelectedIndex = -1; lbPreviewOrders.ItemsSource = null; lbPreviewOrders.ItemsSource = orderList; } EnableNewOrderButtons(); } catch { } }
private void btnCancel1_Click(object sender, System.Windows.RoutedEventArgs e) { foreach (Order order in orderList) if (order.Id == newOrder.Id) { DeleteOrder(order); break; } newOrder = null; newOrderItemList = null; lbNewOrderItems.ItemsSource = null; EnableNewOrderButtons(); }
private void btnAccept_Click(object sender, System.Windows.RoutedEventArgs e) { try { Order acceptedOrder = data.AcceptOrder(newOrder); foreach (Order order in orderList) if (order.Id == newOrder.Id) { order.State = acceptedOrder.State; } newOrder = null; newOrderItemList = null; lbNewOrderItems.ItemsSource = null; lbPreviewOrders.SelectedIndex = -1; lbPreviewOrders.ItemsSource = null; lbPreviewOrders.ItemsSource = orderList; EnableNewOrderButtons(); } catch { } }