/// <summary>
        /// Creator: Dalton Reierson
        /// Created: 2020/04/24
        /// Approver:
        /// Approver:
        ///
        /// selects all receiving records
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public ReceivingRecord RetrieveReceivingRecordByOrderID(int OrderID)
        {
            ReceivingRecord receivingRecord = new ReceivingRecord();

            try
            {
                receivingRecord = _receivingRecordAccessor.SelectReceivingRecordbyOrderID(OrderID);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Receiving Records not found");
            }

            return(receivingRecord);
        }
        /// <summary>
        /// Creator: Dalton Reierson
        /// Created: 2020/04/24
        /// Approver:
        /// Approver:
        ///
        /// Selects all receiving records
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public List <ReceivingRecord> SelectAllReceivingRecords()
        {
            List <ReceivingRecord> receivingRecords = new List <ReceivingRecord>();

            // Connection
            var conn = DBConnection.GetConnection();

            // Command Object
            var cmd = new SqlCommand("sp_select_all_receivingrecords");

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;

            // Parameter

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var receivingRecord = new ReceivingRecord();

                        receivingRecord.ReceivingRecordID  = reader.GetInt32(0);
                        receivingRecord.OrderID            = reader.GetInt32(1);
                        receivingRecord.ShipperID          = reader.GetString(2);
                        receivingRecord.ReceivingOrderDate = reader.GetDateTime(3);
                        receivingRecords.Add(receivingRecord);
                    }
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(receivingRecords);
        }
Ejemplo n.º 3
0
        public void SelectReceivingRecordByOrderID()
        {
            // Arrange
            ReceivingRecord receivingRecord = new ReceivingRecord();
            ReceivingRecord result          = new ReceivingRecord();

            receivingRecord.OrderID            = 100000;
            receivingRecord.ShipperID          = "100000";
            receivingRecord.ReceivingRecordID  = 100000;
            receivingRecord.ReceivingOrderDate = DateTime.Now;

            // Act
            result = _fakeReceivingRecordAccessor.SelectReceivingRecordbyOrderID(100000);

            // Assert
            Assert.AreEqual(receivingRecord, result);
        }
        /// <summary>
        /// Creator: Dalton Reierson
        /// Created: 2020/04/24
        /// Approver:
        /// Approver:
        ///
        /// Selects receiving records by orderID
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public ReceivingRecord SelectReceivingRecordbyOrderID(int OrderID)
        {
            ReceivingRecord receivingRecord = new ReceivingRecord();

            // Connection
            var conn = DBConnection.GetConnection();

            // Command Object
            var cmd = new SqlCommand("sp_select_receiving_record_by_orderID");

            cmd.Connection  = conn;
            cmd.CommandType = CommandType.StoredProcedure;

            // Parameter
            cmd.Parameters.AddWithValue("@OrderID", OrderID);

            try
            {
                conn.Open();
                var reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    receivingRecord.ReceivingRecordID  = reader.GetInt32(0);
                    receivingRecord.OrderID            = reader.GetInt32(1);
                    receivingRecord.ShipperID          = reader.GetString(2);
                    receivingRecord.ReceivingOrderDate = reader.GetDateTime(3);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }

            return(receivingRecord);
        }
        /// <summary>
        /// Creator: Dalton Reierson
        /// Created: 2020/04/23
        /// Approver:
        /// Approver:
        ///
        /// Method for selecting all receivingRecords matching the given orderID
        /// </summary>
        ///
        /// <remarks>
        /// Updated By:
        /// Updated:
        /// Update:
        /// </remarks>
        public ReceivingRecord SelectReceivingRecordbyOrderID(int OrderID)
        {
            ReceivingRecord        receivingRecord             = new ReceivingRecord();
            List <ReceivingRecord> receivingRecordList         = new List <ReceivingRecord>();
            List <ReceivingRecord> filteredReceivingRecordList = new List <ReceivingRecord>();


            // ReceivingRecords to filter out
            for (int i = 0; i < 4; i++)
            {
                receivingRecord.OrderID            = 100001;
                receivingRecord.ShipperID          = "100000";
                receivingRecord.ReceivingRecordID  = 100000;
                receivingRecord.ReceivingOrderDate = DateTime.Now;
                receivingRecordList.Add(receivingRecord);
            }

            // ReceivingRecord to select
            receivingRecord.OrderID            = 100000;
            receivingRecord.ShipperID          = "100000";
            receivingRecord.ReceivingRecordID  = 100000;
            receivingRecord.ReceivingOrderDate = DateTime.Now;
            receivingRecordList.Add(receivingRecord);

            // Filter
            var results = from ReceivingRecord in receivingRecordList
                          where receivingRecord.OrderID == 100000
                          select receivingRecord;

            // Add matching ReceivingRecords to new list
            foreach (ReceivingRecord i in results)
            {
                filteredReceivingRecordList.Add(i);
            }

            return(filteredReceivingRecordList[0]);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creator: Dalton Reierson
 /// Created: 2020/04/24
 /// Approver: Jesse Tomash
 /// Approver:
 ///
 /// Method to show data in datagrid
 /// </summary>
 ///
 /// <remarks>
 /// Updated By:
 /// Updated:
 /// Update:
 /// </remarks>
 private void PopulateDataGrid(Order order)
 {
     _receivingRecord        = _receivingRecordManager.RetrieveReceivingRecordByOrderID(_order.OrderID);
     dgOrderLine.ItemsSource = _orderLineManager.RetrieveOrderLineByReceivingRecordID(_receivingRecord.ReceivingRecordID);
 }