private void btnPrint_Click(object sender, RoutedEventArgs e)
 {
     AutoPrintPage printOrder = new AutoPrintPage();
     PrintDialog pdg = new PrintDialog();
     if (pdg.ShowDialog() == true)
     {
         Visual content = printOrder.GetContent(orderNo, tableNo, state,true);
         if (content != null)
         {
             pdg.PrintVisual(content, "Print Order #" + orderNo.ToString());
         }
     }
 }
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;
            DataRowView selectedRow = (DataRowView)btn.Tag;
            OrdersGridView.SelectedItem = selectedRow;
            Int64 orderNo = (Int64)selectedRow["OrderNo"];
            string tableNo = selectedRow["TableNo"].ToString();
            Byte state = (Byte)selectedRow["State"];

            AutoPrintPage printOrder = new AutoPrintPage();
            PrintDialog pdg = new PrintDialog();
            if (pdg.ShowDialog() == true)
            {
                Visual content = printOrder.GetContent(orderNo, tableNo, state,false);
                if (content != null)
                {
                    pdg.PrintVisual(content, "Print Order #"+orderNo.ToString());
                }

                string spName = "Update_OrderPrintState";
                object [] spParams = new object[1];
                spParams[0] = orderNo;
                try
                {
                    objSqlDatabase.ExecuteNonQuery( spName,spParams);
                    this.Cursor = Cursors.Wait;
                    FilterTextBox.Text = "";
                    LoadOrders();
                    this.Cursor = Cursors.Arrow;
                }
                catch (SqlException)
                { }
            }
        }