Пример #1
0
        private void btnAddOrder_Click(object sender, RoutedEventArgs e)
        {
            object selectedObject = lbSelectCustomerList.SelectedItem;
            if (selectedObject == null)
            {
                MessageBox.Show(this, "Geen klant geselecteerd!", "Onvoldoende gegevens", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            Customer customer = (Customer)selectedObject;
            DateTime dateTimeOrdered = DateTime.Now;
            DateTime dateTimePickup = dpPickupDate.SelectedDate.GetValueOrDefault(DateTime.Now);
            dateTimePickup = dateTimePickup.AddHours(timeHours);
            dateTimePickup = dateTimePickup.AddMinutes(timeMinutes);
            Employee employee = new Employee("iedereen", 1);
            string description = tbDescription.Text;

            Order order = new Order(customer, dateTimeOrdered, dateTimePickup, employee, description);
            if (access.AddOrder(order))
            {
                MessageBox.Show(this, "Order succesvol toegevoegd!", "Succes", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                MessageBox.Show(this, "Order kon niet toegevoegd worden!", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
 public Order(Customer customer, DateTime dateTimeOrdered, DateTime dateTimePickup, Employee employee, string description, int internalID)
 {
     this.customer = customer;
     this.dateTimeOrdered = dateTimeOrdered;
     this.dateTimePickup = dateTimePickup;
     this.employee = employee;
     this.description = description;
     this.internalID = internalID;
 }
Пример #3
0
 public Order(Customer customer, DateTime dateTimeOrdered, DateTime dateTimePickup, Employee employee, string description, Order_Entry[] order_entries)
 {
     this.customer = customer;
     this.dateTimeOrdered = dateTimeOrdered;
     this.dateTimePickup = dateTimePickup;
     this.employee = employee;
     this.description = description;
     this.order_entries = order_entries;
     this.internalID = -1;
 }
Пример #4
0
 public bool GetOrdersByEmployee(Employee employee, out Order[] orders)
 {
     try
     {
         using (IDbConnection connection = MySQLDAOFactory.GetDatabase().CreateOpenConnection())
         {
             string query = "SELECT * FROM " + MySQLDAOFactory.DatabaseName + ".order WHERE order.employee_id = '" + employee.internalID.ToString() + "'";
             using (IDbCommand command = MySQLDAOFactory.GetDatabase().CreateCommand(query, connection))
             {
                 using (IDataReader reader = command.ExecuteReader())
                 {
                     List<Order> ordersList = new List<Order>();
                     while (reader.Read())
                     {
                         DateTime ordered_datetime;
                         DateTime pickup_datetime;
                         if (DateTime.TryParseExact(reader["ordered_datetime"].ToString(), dateFormatReading, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.AssumeLocal, out ordered_datetime) &&
                             DateTime.TryParseExact(reader["pickup_datetime"].ToString(), dateFormatReading, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.AssumeLocal, out pickup_datetime))
                         {
                             Order o = new Order(
                                 new Customer("", "", "", "", "", "", Convert.ToInt32(reader["customerid"])),
                                 ordered_datetime,
                                 pickup_datetime,
                                 employee,
                                 reader["description"].ToString(),
                                 Convert.ToInt32(reader["idorder"])
                                 );
                             ordersList.Add(o);
                         }
                         else
                         {
                             throw new Exception("Couldn't cast to datetime!");
                         }
                     }
                     orders = ordersList.ToArray();
                     if (orders.Length > 0)
                     {
                         return true;
                     }
                     return false;
                 }
             }
         }
     }
     catch (MySqlException ex)
     {
         throw new DatabaseException(ex.Message, ex);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #5
0
 public bool GetOrdersByEmployee(Employee employee, out Order[] orders)
 {
     OrderDAO dao = daoFactory.GetOrderDAO();
     try
     {
         return dao.GetOrdersByEmployee(employee, out orders);
     }
     catch (DatabaseException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }