Ejemplo n.º 1
0
    private void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            if (inFile == null)
            {
                MessageBox.Show("Select a file to print first", "Input File Name Error");
                return;
            }
            DialogResult result  = prdMyPrintDialog.ShowDialog();
            clsPrint     doPrint = new clsPrint(inFile);

            // If the result is OK then print the document.

            if (result == DialogResult.OK)
            {
                doPrint.Print();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error: " + ex.Message);
            return;
        }
    }
Ejemplo n.º 2
0
    private void btnPrint_Click(object sender, EventArgs e)
    {
        try
        {
            lblJobDone.Visible = false;     // Make sure "job done" message is hidden
            if (inFile == null)
            {
                MessageBox.Show("Select a file to print first", "Input File Name Error");
                return;
            }
            clsPrint     doPrint = new clsPrint(inFile);
            DialogResult result  = prdMyPrintDialog.ShowDialog();

            // If the result is OK then print the document.

            if (result == DialogResult.OK)
            {
                myBackgroundWorker.RunWorkerAsync(doPrint);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error: " + ex.Message);
            return;
        }
    }
Ejemplo n.º 3
0
    private void myBackgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
    {
        try
        {
            clsPrint myPrinterJob = e.Argument as clsPrint;
            // If you want to test this without wasting paper, uncomment the
            // next line and comment out the call to myPrinterJob.Print();
            Thread.Sleep(10000);
            //myPrinterJob.Print();   // Comment out this line to avoid prinnting

            e.Result = myPrinterJob;
        } catch (Exception ex) {
            MessageBox.Show("Error in DoWork: " + ex.Message);
        }
    }
Ejemplo n.º 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         HeaderInformation  = "";
         HeaderInformation += "Nom du scénario: " + mySce.ScenarioCode + "\n";
         HeaderInformation += "Season: " + clsSilex.GetNameSeason(mySea.SXSeasonID) + "\n";
         HeaderInformation += "Date: " + DateTime.Now.ToLongDateString() + "\n";
         clsPrint myPrint = new clsPrint(dgvResult, HeaderInformation);
         myPrint.PrintForm();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }