Beispiel #1
0
        // 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;
            }
        }
Beispiel #2
0
        // 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 && !this.cbContact.Checked)
                {
                    msg = "Error: No Selections";
                    return;
                }

                #endregion



                #region Smart Cards
                {
                    // the eject variable is set to true if magnetic encoding is not selected
                    //  and neither Front or Back is selected

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

                    // Determines which smart card sample code to run

                    if (this.cbContact.Checked)
                    {
                        contact = new SampleCodeCONTACT();
                        string _contactlessReader = "";
                        string _contactReader     = "";
                        string errorMsg           = "";

                        WinSCard.GetPCSCReaders(out _contactlessReader, out _contactReader, out errorMsg);
                        if (_contactReader != null && _contactReader.Length > 0)
                        {
                            contact.ContactEncode(this.cboPrn.Text, _contactReader, Convert.ToInt16(eject), out msg);
                            if (msg == "")
                            {
                                this.lblStatus.Text = "CONTACT : No Errors";
                            }
                            else
                            {
                                this.lblStatus.Text = msg;
                            }
                        }
                        else
                        {
                            this.lblStatus.Text = "Error: No Contact Reader found";
                        }
                    }
                }

                #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";
                }

                #endregion

                #region Printing

                // 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
        }