Helcim Logo Support & Tutorials

© Copyright 2006-2018 Helcim Inc.

All Rights Reserved.

POS Hybrid Integration » C# »

C# App Sample


// INCLUDE CLASS
using Helcim_Semi_Integrated;

namespace ExampleOfForm {

    public partial class Form1 : Form {

        // CREATE CLASS AND SETTINGS FORM
        hcmTerminal hcmTest;
        fmSettings settingsForm;

        public Form1() {

            InitializeComponent();

            // CREATE SETTINGS FORM
            settingsForm = new fmSettings();
        }

        private void btnProcess_Click(object sender, EventArgs e) {

            // INIT CLASS
            hcmTest = new hcmTerminal();

            // SAVE SETTINGS
            hcmTest.terminalIp = settingsForm.txtIp.Text;
            hcmTest.terminalPort = int.Parse(settingsForm.txtPort.Text);
             
            switch ((string)cmbType.SelectedItem) {

                case "Purchase":
                    hcmTest.amount = int.Parse(txtAmount.Text);
                    hcmTest.clerkId = int.Parse(txtClerkId.Text);
                    hcmTest.invoiceNumber = int.Parse(txtInvNum.Text);
                    hcmTest.hcmPurchase();
                    break;
                case "Refund":
                    hcmTest.amount = int.Parse(txtAmount.Text);
                    hcmTest.clerkId = int.Parse(txtClerkId.Text);
                    hcmTest.invoiceNumber = int.Parse(txtInvNum.Text);
                    hcmTest.hcmRefund();
                    break;
                case "Void":
                    hcmTest.amount = int.Parse(txtAmount.Text);
                    hcmTest.clerkId = int.Parse(txtClerkId.Text);
                    hcmTest.invoiceNumber = int.Parse(txtInvNum.Text);
                    hcmTest.hcmVoid();
                    break;
                case "PreAuth":
                    hcmTest.amount = int.Parse(txtAmount.Text);
                    hcmTest.clerkId = int.Parse(txtClerkId.Text);
                    hcmTest.invoiceNumber = int.Parse(txtInvNum.Text);
                    hcmTest.hcmPreAuth();
                    break;
                case "Capture":
                    hcmTest.amount = int.Parse(txtAmount.Text);
                    hcmTest.clerkId = int.Parse(txtClerkId.Text);
                    hcmTest.invoiceNumber = int.Parse(txtInvNum.Text);
                    hcmTest.hcmCapture();
                    break;
                case "Settle":
                    hcmTest.hcmSettle();
                    break;
                case "Re-Print":
                    hcmTest.hcmRePrint();
                    break;
            }

            // START TIMER FOR LOG
            logTimer.Enabled = true;

        }


        private void btnTestCon_Click(object sender, EventArgs e) {

            // TEST CONNECTION
            hcmTest.hcmTestConnection();

        }


        private void logTimer_Tick(object sender, EventArgs e) {

            // MAKE SURE THERE IS LOG TO GET
            if (hcmTest.connectionLog.Length > 1) {

                // GET LOG
                ls1.Text += hcmTest.connectionLog;

                if (hcmTest.connectionLog.Contains("Ended Connection")) {

                    // END TIMER
                    logTimer.Enabled = false;
                    logTimer.Stop();
                                 
                }

                // CLEAR LOG
                hcmTest.connectionLog = "";

                // CHECK FOR RESPONSE MESSAGE
                if (hcmTest.responseMessage != null) {

                    // DISPLAY
                    ls1.Text += "\r\n" + hcmTest.responseMessage;
                }
            }

        }

        private void settingsTT_Click(object sender, EventArgs e) {

            // OPEN SETTINGS FORM
            settingsForm.ShowDialog();
     
        }
    }
}