Beispiel #1
0
        /// <summary>
        /// This method gets the list of orders that have not been accepted yet
        ///
        /// Test Case:  Req-9
        /// </summary>
        /// <returns>List of orders not yet accepted by vendor/basket</returns>
        public List <CustOrder> DisplayAvailableOrders()
        {
            List <CustOrder> orderList = new List <CustOrder>();

            using (SqlConnection conn = new SqlConnection(defaultConnection))
            {
                string query = "select co.order_id, co.customer_id, co.location_id, co.total_price, co.basket_id, " +
                               "co.expected_delivery_time, co.actual_delivery_time, co.submit_ts, co.vendor_accepted_ts, " +
                               "co.delivered_ts, co.order_notes, co.feedback_stars, co.feedback_notes, co.vendor_notes " +
                               "from cust_order co " +
                               "where co.vendor_accepted_ts is null";

                using (SqlCommand myCmd = new SqlCommand(query, conn))
                {
                    SqlDataReader dr = null;
                    conn.Open();
                    dr = myCmd.ExecuteReader();

                    while (dr.Read())
                    {
                        CustOrder cust_order = new CustOrder();

                        if (util.IsNumeric(dr["order_id"].ToString().Trim()))
                        {
                            cust_order.order_id = int.Parse(dr["order_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["customer_id"].ToString().Trim()))
                        {
                            cust_order.customer_id = int.Parse(dr["customer_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["location_id"].ToString().Trim()))
                        {
                            cust_order.location_id = int.Parse(dr["location_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["total_price"].ToString().Trim()))
                        {
                            cust_order.total_price = decimal.Parse(dr["total_price"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["basket_id"].ToString().Trim()))
                        {
                            cust_order.basket_id = int.Parse(dr["basket_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["expected_delivery_time"].ToString().Trim()))
                        {
                            cust_order.expected_delivery_time = int.Parse(dr["expected_delivery_time"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["actual_delivery_time"].ToString().Trim()))
                        {
                            cust_order.actual_delivery_time = int.Parse(dr["actual_delivery_time"].ToString().Trim());
                        }
                        if (util.IsDate(dr["submit_ts"].ToString().Trim()))
                        {
                            cust_order.submit_ts = DateTime.Parse(dr["submit_ts"].ToString().Trim());
                        }
                        if (util.IsDate(dr["vendor_accepted_ts"].ToString().Trim()))
                        {
                            cust_order.vendor_accepted_ts = DateTime.Parse(dr["vendor_accepted_ts"].ToString().Trim());
                        }
                        if (util.IsDate(dr["delivered_ts"].ToString().Trim()))
                        {
                            cust_order.delivered_ts = DateTime.Parse(dr["delivered_ts"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["feedback_stars"].ToString().Trim()))
                        {
                            cust_order.feedback_stars = int.Parse(dr["feedback_stars"].ToString().Trim());
                        }
                        cust_order.order_notes    = dr["order_notes"].ToString().Trim();
                        cust_order.feedback_notes = dr["feedback_notes"].ToString().Trim();
                        cust_order.vendor_notes   = dr["vendor_notes"].ToString().Trim();

                        cust_order.order_items = GetOrderItems(cust_order.order_id);

                        orderList.Add(cust_order);
                    }
                    return(orderList);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method retrieves the cust order including the order items from the database for the specific order
        ///
        /// Test Case:   Req-8
        /// </summary>
        /// <param name="order_id">identifier for the specific order</param>
        /// <returns>CustOrder object</returns>
        public CustOrder GetOrder(int order_id)
        {
            using (SqlConnection conn = new SqlConnection(defaultConnection))
            {
                /*   string query = "select co.order_id, co.customer_id, co.location_id, co.total_price, co.basket_id, " +
                 *                "co.expected_delivery_time, co.actual_delivery_time, co.submit_ts, co.vendor_accepted_ts, " +
                 *                "co.delivered_ts, co.order_notes, co.feedback_stars, co.feedback_notes, co.vendor_notes " +
                 *                "from cust_order co " +
                 *                "where order_id = @order_id";
                 */
                string query = "select co.order_id, co.customer_id, co.location_id, l.bay, l.row_no, l.seat_no, co.total_price, co.basket_id, " +
                               "co.expected_delivery_time, co.actual_delivery_time, co.submit_ts, co.vendor_accepted_ts, " +
                               "co.delivered_ts, co.order_notes, co.feedback_stars, co.feedback_notes, co.vendor_notes " +
                               "from cust_order co inner join  Location l on co.location_id	= l.location_id " +
                               "where order_id = @order_id";

                using (SqlCommand myCmd = new SqlCommand(query, conn))
                {
                    SqlDataReader dr = null;
                    conn.Open();
                    myCmd.Parameters.AddWithValue("@order_id", order_id);
                    dr = myCmd.ExecuteReader();

                    CustOrder cust_order = new CustOrder();

                    while (dr.Read())
                    {
                        if (util.IsNumeric(dr["order_id"].ToString().Trim()))
                        {
                            cust_order.order_id = int.Parse(dr["order_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["customer_id"].ToString().Trim()))
                        {
                            cust_order.customer_id = int.Parse(dr["customer_id"].ToString().Trim());
                            cust_order.customer    = GetCustomerName(int.Parse(dr["customer_id"].ToString().Trim()));
                        }
                        if (util.IsNumeric(dr["location_id"].ToString().Trim()))
                        {
                            cust_order.location_id = int.Parse(dr["location_id"].ToString().Trim());
                        }
                        cust_order.bay     = dr["bay"].ToString().Trim();
                        cust_order.row_no  = dr["row_no"].ToString().Trim();
                        cust_order.seat_no = dr["seat_no"].ToString().Trim();
                        if (util.IsNumeric(dr["total_price"].ToString().Trim()))
                        {
                            cust_order.total_price = decimal.Parse(dr["total_price"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["basket_id"].ToString().Trim()))
                        {
                            cust_order.basket_id = int.Parse(dr["basket_id"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["expected_delivery_time"].ToString().Trim()))
                        {
                            cust_order.expected_delivery_time = int.Parse(dr["expected_delivery_time"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["actual_delivery_time"].ToString().Trim()))
                        {
                            cust_order.actual_delivery_time = int.Parse(dr["actual_delivery_time"].ToString().Trim());
                        }
                        if (util.IsDate(dr["submit_ts"].ToString().Trim()))
                        {
                            cust_order.submit_ts = DateTime.Parse(dr["submit_ts"].ToString().Trim());
                        }
                        if (util.IsDate(dr["vendor_accepted_ts"].ToString().Trim()))
                        {
                            cust_order.vendor_accepted_ts = DateTime.Parse(dr["vendor_accepted_ts"].ToString().Trim());
                        }
                        if (util.IsDate(dr["delivered_ts"].ToString().Trim()))
                        {
                            cust_order.delivered_ts = DateTime.Parse(dr["delivered_ts"].ToString().Trim());
                        }
                        if (util.IsNumeric(dr["feedback_stars"].ToString().Trim()))
                        {
                            cust_order.feedback_stars = int.Parse(dr["feedback_stars"].ToString().Trim());
                        }
                        cust_order.order_notes    = dr["order_notes"].ToString().Trim();
                        cust_order.feedback_notes = dr["feedback_notes"].ToString().Trim();
                        cust_order.vendor_notes   = dr["vendor_notes"].ToString().Trim();

                        cust_order.order_items = GetOrderItems(cust_order.order_id);
                    }
                    return(cust_order);
                }
            }
        }