Esempio n. 1
0
    // order history
    // this updates the food list gridview to show the food items that are part of the selected row in the order history
    protected void OnSelectedIndexChanged(Object sender, EventArgs e)
    {
        int orderID = Convert.ToInt32(OrderGridView.SelectedRow.Cells[0].Text);

        DataTable     dt         = new DataTable();
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["OrderistaConnectionString"].ConnectionString);

        try
        {
            connection.Open();
            SqlCommand cmd = new SqlCommand("SELECT MenuItemName, Quantity, Price, Subtotal FROM Order_Items WHERE OrderID = @orderID");
            cmd.Parameters.AddWithValue("@orderID", orderID);
            cmd.Connection = connection;
            SqlDataAdapter sqlData = new SqlDataAdapter(cmd);

            //Populate the grid view
            sqlData.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                OrderItemDetailsView.DataSource = dt;
                OrderItemDetailsView.DataBind();
            }
        }
        catch (SqlException ex)
        {
            string msg = "Fetch Error: ";
            msg += ex.Message;
            throw new Exception(msg);
        }
        finally
        {
            connection.Close();
        }
    } // OnSelectedIndexChanged
Esempio n. 2
0
        private void OrdersGridView_DoubleClick(object sender, EventArgs e)
        {
            Guid?selectedOrderId = GetGridViewCurrentRowId();

            if (!selectedOrderId.HasValue)
            {
                return;
            }

            OrderItemDetailsView orderItemView = new OrderItemDetailsView(selectedOrderId.Value);
            DialogResult         dialogResult  = orderItemView.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
            }
        }