From ef35773c8e86cda562745424e32aa53225606c4d Mon Sep 17 00:00:00 2001 From: Jake Visser Date: Wed, 12 Jul 2017 22:33:36 -0700 Subject: [PATCH] loops to 48 --- qcbadge/CreateDB.sql | 4 ++-- qcbadge/Helpers/Sql.cs | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/qcbadge/CreateDB.sql b/qcbadge/CreateDB.sql index fea1ab5..5011fbc 100644 --- a/qcbadge/CreateDB.sql +++ b/qcbadge/CreateDB.sql @@ -60,9 +60,9 @@ CREATE TABLE [dbo].[qcbadge]( [45] [bit] DEFAULT 0 NOT NULL, [46] [bit] DEFAULT 0 NOT NULL, [47] [bit] DEFAULT 0 NOT NULL, - [48] [bit] DEFAULT 0 NOT NULL, - [49] [bit] DEFAULT 0 NOT NULL, + [curr] [int] DEFAULT NULL, [lastseen] [datetime] NULL + PRIMARY KEY CLUSTERED ( [badgeid] ASC diff --git a/qcbadge/Helpers/Sql.cs b/qcbadge/Helpers/Sql.cs index 8a2ca9b..aff68a7 100644 --- a/qcbadge/Helpers/Sql.cs +++ b/qcbadge/Helpers/Sql.cs @@ -18,9 +18,9 @@ namespace qcbadge.Helpers public bool[] selectGlobalView() { //System.Diagnostics.Debug.WriteLine("Got to selectGlobalView"); - bool[] rtn = new bool[50]; + bool[] rtn = new bool[48]; - for (int i = 0; i < 50; i++) + for (int i = 0; i < 48; i++) { //System.Diagnostics.Debug.WriteLine("Into loop " + i); @@ -75,9 +75,9 @@ namespace qcbadge.Helpers public bool[] selectIndervidualView(int badgeid) { - bool[] rtn = new bool[50]; + bool[] rtn = new bool[48]; - for (int i = 0; i < 50; i++) + for (int i = 0; i < 48; i++) { //System.Diagnostics.Debug.WriteLine("Into loop " + i); @@ -130,5 +130,39 @@ namespace qcbadge.Helpers return rtn; } + public void updateBadge(String code, string email, string custcode, string paycode, string qrcode) + { + + try + { + SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); + builder.DataSource = DataSource; + builder.UserID = UserID; + builder.Password = Password; + builder.InitialCatalog = db; + + using (SqlConnection connection = new SqlConnection(builder.ConnectionString)) + { + connection.Open(); + StringBuilder sb = new StringBuilder(); + sb.Append("UPDATE " + table + " SET codeused = 1, email = '" + email + "', custcode = '" + custcode + "', paycode = '" + paycode + "', qrcode = '" + qrcode + "', datepayed = CURRENT_TIMESTAMP WHERE [requestcode] = '" + code + "';"); + String sql = sb.ToString(); + using (SqlCommand command = new SqlCommand(sql, connection)) + { + + int rowsAffected = command.ExecuteNonQuery(); + + } + } + } + catch (SqlException e) + { + Console.WriteLine(e.ToString()); + } + + + + } + } }