Beispiel #1
0
        /// <summary>
        /// Carlos Arzu
        /// Created: 2019/01/30
        ///
        /// Input from the user when creating a new order.
        /// </summary>
        public bool InputUser()
        {
            bool result = false;

            SpecialOrderID.IsEnabled = false;
            try
            {
                if (TestDataOrder())
                {
                    _completespecialOrder = new CompleteSpecialOrder()
                    {
                        //User input for new order form

                        EmployeeID  = Int32.Parse(InputEmployeeID.Text),
                        Description = InputDescription.Text,
                        DateOrdered = DateTime.Parse(InputDateOrdered.Text),
                        Supplier    = InputSupplierID.Text,
                        //Authorized = InputAuthorized.Text
                    };

                    result = true;
                }
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("Processor Usage" + ex.Message);
            }
            return(result);
        }
        /// <summary>
        /// Carlos Arzu
        /// Created: 2019/02/28
        ///
        /// Creates the new Supplier order, with the data provided by user.
        /// </summary
        public int InsertSpecialOrder(CompleteSpecialOrder newSpecialOrder)
        {
            _order.Add(newSpecialOrder);


            return(1);
        }
Beispiel #3
0
 /// <summary>
 /// Carlos Arzu
 /// Created: 2019/01/30
 ///
 /// The Second Constructor.
 /// Set the the order selected in a new window, with read only
 /// data, with the option to edit.
 /// </summary>
 public AddSpecialOrder(CompleteSpecialOrder selected)
 {
     InitializeComponent();
     _selected           = selected;
     AddItemBtn.Content  = "Add Items";
     btnAddOrder.Content = "Edit";
     setReadOnly();
     setDetails();
 }
        /// <summary author="Carlos Arzu" created="2019/02/06">
        /// Called for updating the new input from the user, to the order in the DB.
        /// </summary>
        public bool EditSpecialOrder(CompleteSpecialOrder Order, CompleteSpecialOrder Ordernew)
        {
            bool result = false;

            try
            {
                result = (1 == specialOrderAccessor.UpdateOrder(Order, Ordernew));
            }
            catch (Exception ex)
            {
                ExceptionLogManager.getInstance().LogException(ex);
                throw ex;
            }
            return(result);
        }
        /// <summary author="Carlos Arzu" created="2019/04/05">
        /// Called for updating the new input from the user, to the special order line in the DB.
        /// </summary>
        public int retrieveSpecialOrderID(CompleteSpecialOrder selected)
        {
            int result = 0;

            try
            {
                result = specialOrderAccessor.retrieveSpecialOrderIDbyDetails(selected);
            }
            catch (Exception ex)
            {
                ExceptionLogManager.getInstance().LogException(ex);
                throw ex;
            }
            return(result);
        }
 /// <summary>
 /// Author: Kevin Broskow
 /// Created : 3/25/2019
 /// Real constructor for the window being opened on a special order being recieved
 ///
 /// </summary>
 public OrderRecieving(CompleteSpecialOrder specialOrder)
 {
     _specialOrder = specialOrder;
     try
     {
         specialOrderLines        = _specialManager.RetrieveOrderLinesByID(_specialOrder.SpecialOrderID);
         originalSpecialOrderLine = _specialManager.RetrieveOrderLinesByID(_specialOrder.SpecialOrderID);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message);
     }
     InitializeComponent();
     this.lblRecieving.Content   += _specialOrder.SpecialOrderID.ToString();
     this.btnSubmit.Content       = "Complete";
     dgOrderRecieving.ItemsSource = specialOrderLines;
 }
        /// <summary author="Carlos Arzu" created="2019/02/06">
        /// Has the information of a new Order, and will create it in our DB.
        /// </summary>
        public bool CreateSpecialOrder(CompleteSpecialOrder SpecialOrder)
        {
            bool result = false;

            try
            {
                if (!SpecialOrder.isValid())
                {
                    throw new ArgumentException("Data entered for this order is invalid\n " +
                                                SpecialOrder.ToString());
                }

                result = (1 == specialOrderAccessor.InsertSpecialOrder(SpecialOrder));
            }
            catch (Exception ex)
            {
                ExceptionLogManager.getInstance().LogException(ex);
                throw ex;
            }
            return(result);
        }
        public void TestCreateSupplierOrderInvalidDescriptionNull()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = null,
                DateOrdered    = DateTime.Now,
                Supplier       = "Leap"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "You get nothing",
                Description = null,
                OrderQty    = 40,
                QtyReceived = 0
            };

            _supplierOrderManager.CreateSpecialOrder(order);
        }
        public void TestDateValid()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = "Mighty tests",
                DateOrdered    = DateTime.Now.AddDays(-1),
                Supplier       = "Too much"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Paviment",
                Description = createStringLength(1001),
                OrderQty    = 10,
                QtyReceived = -10
            };

            _supplierOrderManager.CreateSpecialOrder(order);
            _supplierOrderManager.CreateSpecialOrderLine(orderline);
        }
        public void AddItemOrderLineTestInValidQtyReceived()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = "Mighty tests",
                DateOrdered    = DateTime.Now,
                Supplier       = "SuperMax"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Pole",
                Description = createStringLength(1001),
                OrderQty    = 10,
                QtyReceived = -10
            };

            _supplierOrderManager.CreateSpecialOrder(order);
            _supplierOrderManager.CreateSpecialOrderLine(orderline);
        }
        public void TestCreateSupplierOrderInvalidDescriptionLength()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = createStringLength(1001),
                DateOrdered    = DateTime.Now,
                Supplier       = "Fish n Dip"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Paint",
                Description = createStringLength(1001),
                OrderQty    = 40,
                QtyReceived = 0
            };

            _supplierOrderManager.CreateSpecialOrder(order);
            _supplierOrderManager.CreateSpecialOrderLine(orderline);
        }
        public void TestCreateSupplierOrderInvalidDescriptionBlank()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = "",
                DateOrdered    = DateTime.Now,
                Supplier       = "ShopFever"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Job",
                Description = "",
                OrderQty    = 40,
                QtyReceived = 0
            };

            _supplierOrderManager.CreateSpecialOrder(order);
            _supplierOrderManager.CreateSpecialOrderLine(orderline);
        }
        // <summary>
        /// Carlos Arzu
        /// Created: 2019/01/31
        ///
        /// Retrieves the ItemId needed for every form.
        /// </summary
        public int retrieveSpecialOrderIDbyDetails(CompleteSpecialOrder selected)
        {
            List <int> ID  = new List <int>();
            int        max = 0;

            try
            {
                var conn = DBConnection.GetDbConnection();

                conn.Open();
                var cmd = new SqlCommand("sp_retrieve_last_specialOrderID_created", conn);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@EmployeeID", selected.EmployeeID);
                cmd.Parameters.AddWithValue("@Description", selected.Description);
                cmd.Parameters.AddWithValue("@DateOrdered", selected.DateOrdered);
                cmd.Parameters.AddWithValue("@Supplier", selected.Supplier);

                var reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ID.Add(reader.GetInt32(0));
                    }
                }


                conn.Close();

                max = ID.Max();
            }
            catch (Exception)
            {
                throw;
            }

            return(max);
        }
        public void AddItemOrderLineTestInValidOrderQty()
        {
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = createStringLength(1001),
                DateOrdered    = DateTime.Now,
                Supplier       = "Rigga meter"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Paint",
                Description = createStringLength(1001),
                OrderQty    = -1,
                QtyReceived = 0
            };


            _supplierOrderManager.CreateSpecialOrder(order);
            _supplierOrderManager.CreateSpecialOrderLine(orderline);
        }
        public void TestCreateSupplierOrderWithAllValidInputs()
        {
            //arrange
            CompleteSpecialOrder order = new CompleteSpecialOrder()
            {
                SpecialOrderID = 100008,
                EmployeeID     = 100005,
                Description    = "Escape Pod for Groom",
                DateOrdered    = DateTime.Now,
                Supplier       = "Backscratcher"
            };

            SpecialOrderLine orderline = new SpecialOrderLine()
            {
                NameID      = "Short Relief",
                Description = "Darts to sleep the Bride",
                OrderQty    = 40,
                QtyReceived = 0
            };


            //Act
            _supplierOrderManager.CreateSpecialOrder(order);

            //Assert
            _compsupplierOrder = _supplierOrderManager.retrieveAllOrders();
            _supplierOrderLine = _supplierOrderManager.RetrieveOrderLinesByID(order.SpecialOrderID);

            Assert.IsNotNull(_compsupplierOrder.Find(o => o.SpecialOrderID == order.SpecialOrderID &&
                                                     o.EmployeeID == order.EmployeeID && o.Description == order.Description &&
                                                     o.DateOrdered == order.DateOrdered &&
                                                     o.Supplier == order.Supplier));

            /*Assert.IsNotNull(_supplierOrderLine.Find(l => l.NameID == orderline.NameID
             * && l.Description == orderline.Description && l.OrderQty == orderline.OrderQty
             * && l.QtyReceived == orderline.QtyReceived));*/
        }
        /// <summary>
        /// Carlos Arzu
        /// Created: 2019/01/31
        ///
        /// Creates the new Special order, with the data provided by user.
        /// </summary
        public int InsertSpecialOrder(CompleteSpecialOrder newSpecialOrder)
        {
            int row = 0;

            try
            {
                var conn = DBConnection.GetDbConnection();
                conn.Open();
                var cmd1 = new SqlCommand("sp_create_specialOrder", conn);
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.Parameters.AddWithValue("@EmployeeID", newSpecialOrder.EmployeeID);
                cmd1.Parameters.AddWithValue("@Description", newSpecialOrder.Description);
                cmd1.Parameters.AddWithValue("@DateOrdered", newSpecialOrder.DateOrdered);
                cmd1.Parameters.AddWithValue("@Supplier", newSpecialOrder.Supplier);
                row += cmd1.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception)
            {
                throw;
            }

            return(row);
        }
        /// <summary>
        /// Carlos Arzu
        /// Created: 2019/01/31
        ///
        /// With the input user provided for updating, the order will be updated.
        /// </summary
        public int UpdateOrder(CompleteSpecialOrder Order, CompleteSpecialOrder Ordernew)
        {
            int rows = 0;

            var conn    = DBConnection.GetDbConnection();
            var cmdText = "sp_update_SpecialOrder";
            var cmd     = new SqlCommand(cmdText, conn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@SpecialOrderID", Order.SpecialOrderID);

            cmd.Parameters.AddWithValue("@EmployeeID", Ordernew.EmployeeID);
            cmd.Parameters.AddWithValue("@Description", Ordernew.Description);
            cmd.Parameters.AddWithValue("@Supplier", Ordernew.Supplier);

            cmd.Parameters.AddWithValue("@OldEmployeeID", Order.EmployeeID);
            cmd.Parameters.AddWithValue("@OldDescription", Order.Description);
            cmd.Parameters.AddWithValue("@OldSupplier", Order.Supplier);


            try
            {
                conn.Open();
                rows = cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
            return(rows);
        }
 public bool isValid(CompleteSpecialOrder SpecialOrder)
 {
     return(true);
 }
 // <summary>
 /// Carlos Arzu
 /// Created: 2019/01/31
 ///
 /// Retrieves the ItemId needed for every form.
 /// </summary
 public int retrieveSpecialOrderIDbyDetails(CompleteSpecialOrder selected)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Carlos Arzu
        /// Created: 2019/02/28
        ///
        /// Update the new Special order, with the data provided by user.
        /// </summary
        public int UpdateOrder(CompleteSpecialOrder Order, CompleteSpecialOrder Ordernew)
        {
            int iterator = 1;

            return(iterator);
        }