Subversion Repository Public Repository

ChrisCompleteCodeTrunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Action_Tire_Payment_Processor
{
    public partial class SettingsForm : Form
    {
        public SettingsForm()
        {
            InitializeComponent();
            tbServer.Text = Settings.GetOption("DBSERVER");
            tbDatabase.Text = Settings.GetOption("DBNAME");
            tbUsername.Text = Settings.GetOption("DBUSER");
            tbPassword.Text = Settings.GetOption("DBPASSWORD");
            tbStoreID.Text = Settings.GetOption("STORE");
            tbPrinterIP.Text = Settings.GetOption("PRINTERIP");
            tbAdminPassword.Text = Settings.GetOption("ADMINPASSWORD");
            
            bool windows = false;
            bool local = false;
            bool gifty = false;

            bool.TryParse(Settings.GetOption("DBWINDOWS"), out windows);
            bool.TryParse(Settings.GetOption("USEDEFAULTPRINTER"), out local);
            bool.TryParse(Settings.GetOption("GIFTREGISTRATION"), out gifty);

            cbLocalDefaultPrinter.Checked = local;
            cbWindowsAuth.Checked = windows;
            cbEnableGiftCard.Checked = gifty;
        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void cbWindowsAuth_CheckedChanged(object sender, EventArgs e)
        {
            gbWindowsAuth.Enabled = !cbWindowsAuth.Checked;
        }

        private void btnTestDB_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnectionStringBuilder csb = new SqlConnectionStringBuilder();
                csb.DataSource = tbServer.Text;
                csb.IntegratedSecurity = cbWindowsAuth.Checked;
                csb.UserID = tbUsername.Text;
                csb.Password = tbPassword.Text;
                csb.InitialCatalog = tbDatabase.Text;
                Database.ConnectionString = csb.ConnectionString;
                Database.sql.Open();
                Database.Close();
                MessageBox.Show("Database Connection OK");
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            Settings.SetOption("DBSERVER", tbServer.Text);
            Settings.SetOption("DBNAME", tbDatabase.Text);
            Settings.SetOption("DBUSER", tbUsername.Text);
            Settings.SetOption("DBPASSWORD", tbPassword.Text);
            Settings.SetOption("STORE", tbStoreID.Text);
            Settings.SetOption("PRINTERIP", tbPrinterIP.Text);
            Settings.SetOption("ADMINPASSWORD", tbAdminPassword.Text);
            Settings.SetOption("DBWINDOWS", cbWindowsAuth.Checked.ToString().ToLower());
            Settings.SetOption("USEDEFAULTPRINTER", cbLocalDefaultPrinter.Checked.ToString().ToLower());
            Settings.SetOption("GIFTREGISTRATION", cbEnableGiftCard.Checked.ToString().ToLower());
            Database.Init();
            this.Close();
        }

    }
}

Commits for ChrisCompleteCodeTrunk/ATTP/Action Tire Payment Processor/SettingsForm.cs

Diff revisions: vs.
Revision Author Commited Message
1 BBDSCHRIS picture BBDSCHRIS Wed 22 Aug, 2018 20:08:03 +0000