Exemple #1
0
        // method for getting data for the details of the selected order and displaying oder's details
        private void DisplayOrderDetails(int orderId)
        {
            // to display the order details table:
            List <OrderDetails> ordDtl = new List <OrderDetails>();

            try
            {
                ordDtl = OrderDetailsDB.GetOrderDetails(orderId);
                orderDetailsDataGridView.DataSource = ordDtl;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }

            // to display total order:
            try
            {
                txtTotal.Text = OrderDetailsDB.CalOrdTotal(orderId).ToString("C");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
            }
        }
Exemple #2
0
        /// <summary>
        /// Place the data in the form
        /// </summary>
        private void RefreshDetails()
        {
            try
            {
                details = OrderDetailsDB.GetOrderDetails(CurrentOrder.OrderID); // get the details associated with this order from the database
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading order details: " + ex.Message, ex.GetType().ToString());
            }

            // add each of the order fields to the text boxes
            txtOrderID.Text = CurrentOrder.OrderID.ToString();
            txtCustID.Text  = CurrentOrder.CustomerID.ToString();

            //if the date is null, use an empty string. otherwise convert to date-only format
            txtOrderDate.Text   = (CurrentOrder.OrderDate == null)? "" : ((DateTime)CurrentOrder.OrderDate).ToString("MM/dd/yyyy");
            txtShippedDate.Text = (CurrentOrder.ShippedDate == null) ? "" : ((DateTime)CurrentOrder.ShippedDate).ToString("MM/dd/yyyy");
            txtReqDate.Text     = (CurrentOrder.RequiredDate == null) ? "" : ((DateTime)CurrentOrder.RequiredDate).ToString("MM/dd/yyyy");

            txtOrderTotal.Text = (from d in details select d.ItemTotal).Sum().ToString("c"); // order total must be the sum of all item totals

            dgvDetails.DataSource = details;                                                 // feed the order details to the data grid
            dgvDetails.Columns[2].DefaultCellStyle.Format = "c";                             // unit price to display as currency
            dgvDetails.Columns[5].DefaultCellStyle.Format = "c";                             // item total to display as currency
            dgvDetails.Columns[4].DefaultCellStyle.Format = "p";                             // discount to display as a percentage

            dgvDetails.Columns[0].Visible = false;                                           // we don't need the order ID, we already know what it is
        }
Exemple #3
0
        private void cmbOrderID_SelectedIndexChanged(object sender, EventArgs e)//select ORDERID and dispaly all of info related to it
        {
            order1 = new Order();
            List <OrderDetail> orderDetails = new List <OrderDetail>();

            order1 = OrdersDB.GetOrder(Convert.ToInt32(cmbOrderID.Text));//get specific ORDER recorder and return it to order1
            //need display method

            OrderDisplay();                                                   //display order info
            orderDetails = OrderDetailsDB.GetRelativeDetails(order1.OrderID); //get related orderdetails info from TABLE order details
            dgvOrderDetail.DataSource = orderDetails;                         //set gridviewer datasource equals to orderdetails and display it
            if (orderDetails.Count > 0)                                       //there are relative details
            {
                //call summary of  total charges from order details in TABLE ORDER DETAILS
                txtTotalCharge.Text = OrderDetailsDB.GetTotalCharge(order1.OrderID).ToString("c");
            }
            else
            {
                txtTotalCharge.Text = null;
            }
        }