Exemple #1
0
        public MainForm()
        {
            InitializeComponent();

            // set default values
            hostIp = 100;
            isHostLocalhost = false;
            comPort = 4;
            isPrinterEnabled = true;
            isLockEnabled = true;
            mode = CashpointMode.Auto;

            try
            {
                // read registry for application directory
                string path = Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\MV Oeschelbronn\\Kasse", "Path", "").ToString();
                if (string.IsNullOrEmpty(path))
                {
                    MessageBox.Show("Pfad der Kassenanwendung konnte nicht ermittelt werden.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(0);
                }

                this.path = path;
                txtPath.Text = path;
                LoadConfig();
                UpdateUI();
            }
            catch(Exception ex)
            {
                MessageBox.Show("Fehler beim Start der Anwendung: " + ex.ToString(), "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
Exemple #2
0
        private void LoadConfig()
        {
            if (!File.Exists(path + CONFIG_FILE_PATH))
            {
                MessageBox.Show("Konfigurationsdatei konnte nicht geladen werden.", "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }

            try
            {
                foreach (string s in File.ReadLines(path + CONFIG_FILE_PATH))
                {
                    string value = s.Split('=')[1].ToLower();
                    switch (s.Split('=')[0].ToLower())
                    {
                        case "server":
                            if (value == "localhost")
                                isHostLocalhost = true;
                            else
                                hostIp = Convert.ToInt32(value.Split('.')[3]);
                            break;
                        case "lockport":
                            comPort = Convert.ToInt32(value.Replace("com", ""));
                            break;
                        case "printer":
                            isPrinterEnabled = value == "true";
                            break;
                        case "nolock":
                            isLockEnabled = value == "false"; // NOLOCK=FALSE
                            break;
                        case "mode":
                            if (value == "lock")
                                mode = CashpointMode.Lock;
                            else if (value == "pin")
                                mode = CashpointMode.Pin;
                            break;
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("Konfigurationsdatei konnte nicht gelesen werden: " + ex.Message, "Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
Exemple #3
0
        private void btnMode_Click(object sender, EventArgs e)
        {
            switch (mode)
            {
                case CashpointMode.Auto:
                    mode = CashpointMode.Lock;
                    break;
                case CashpointMode.Lock:
                    mode = CashpointMode.Pin;
                    break;
                case CashpointMode.Pin:
                    mode = CashpointMode.Auto;
                    break;
            }

            UpdateUI();
        }