// Gets the versions of the SDK's DLLs
        //     if the version == "" then the supporting dll is not present ----------------------------------
        private void GetSDKVersions()
        {
            SampleCodeGraphics g;
            SampleCodeMag      p;

            try
            {
                g = new SampleCodeGraphics();
                _graphicsSDKVersion = g.GetSDKVersion();

                p = new SampleCodeMag();
                _prnSDKVersion = p.GetSDKVersion();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "GetSDKVersions threw exception");
            }
            finally
            {
                g = null;
                p = null;
            }
        }
        // Submit Button
        //     Starts the example code based on Form selections ---------------------------------------------

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            #region Variables

            bool   eject = false;
            string msg   = "";

            SampleCodeMag      mag = null;
            SampleCodeGraphics prn = null;

            #endregion

            #region Check Selections

            // Verifies that a printer has been selected
            try
            {
                if (cboPrn.SelectedIndex < 0)
                {
                    msg = "Error: A Printer has not been selected";
                    return;
                }

                // Verifies that at least one selection is made
                if (!this.cbBack.Checked && !this.cbFront.Checked && !this.cbMag.Checked)
                {
                    msg = "Error: No Selections";
                    return;
                }

                #endregion


                #region Magnetic Encoding

                if (cbMag.Checked)
                {
                    // the eject variable is set to true if neither Front or Back is selected

                    eject = (!this.cbBack.Checked && !this.cbFront.Checked);

                    // Encodes and Verifies all three Tracks

                    mag = new SampleCodeMag();
                    mag.PerformMagneticEncodeJob(this.cboPrn.Text, out msg);
                    if (msg != "")
                    {
                        return;
                    }
                    this.lblStatus.Text = "Magnetic Encoding : No Errors";
                }

                // If only magnetic encoding, eject the card
                if (!this.cbFront.Checked && !this.cbBack.Checked)
                {
                    int errValue = 0;

                    if (!RefreshConnectionToPrinter())
                    {
                        return;
                    }
                    int result = _thePrinterSDK.EjectCard(out errValue);
                    if (!CloseConnectionToPrinter())
                    {
                        return;
                    }

                    if ((result != 1) && (errValue != 0))
                    {
                        this.lblStatus.Text = "EjectCard failed. Error = " + Convert.ToString(errValue);
                    }
                }

                #endregion

                #region Printing

                else
                {
                    // Initialize the Print Side Class

                    prn = new SampleCodeGraphics();

                    // Determines the printing type

                    if (this.cbFront.Checked && !this.cbBack.Checked)
                    {
                        prn.PrintFrontSideOnly(this.cboPrn.Text, "Front Side Text", Application.StartupPath, out msg);
                        if (msg == "")
                        {
                            this.lblStatus.Text = "No Errors : Front Side Only Printing";
                        }
                    }
                    else if (this.cbFront.Checked && this.cbBack.Checked)
                    {
                        prn.PrintBothSides(this.cboPrn.Text, "Front Side Text", "Back Side Text", Application.StartupPath, out msg);
                        if (msg == "")
                        {
                            this.lblStatus.Text = "No Errors : Both Side Printing";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                MessageBox.Show(ex.ToString(), "btnSubmit_Click threw exception");
            }
            finally
            {
                if (msg != "")
                {
                    this.lblStatus.Text = msg;
                }

                mag = null;
                prn = null;
            }

            #endregion
        }