示例#1
0
 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);
     }
 }
示例#2
0
 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;
 }
示例#3
0
        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;
        }
示例#4
0
        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();
        }
示例#5
0
 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);
     }
 }
示例#6
0
 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
     };
 }
示例#7
0
 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;
 }
示例#8
0
 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;
 }
示例#9
0
        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();
        }
示例#10
0
        private void DeleteOrder(Order order)
        {
            try
            {
                data.CancelOrder(order);
                orderList.Remove(order);

                lbPreviewOrders.SelectedIndex = -1;
                lbPreviewOrders.ItemsSource = null;
                lbPreviewOrders.ItemsSource = orderList;
            }
            catch { }
        }
示例#11
0
 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();
     }
 }
示例#12
0
        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 { }
        }
示例#13
0
        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();
        }
示例#14
0
        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 { }
        }