Skip to content

Commit 35e8517

Browse files
Fix/ole db error (#26)
* Fix OLE db Error, Correct the data type to avoid mismatch * Fix handling in 64 bit number * Update libraries, cleanup console warnings
1 parent 810c8e7 commit 35e8517

17 files changed

+236
-231
lines changed

App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<value>0</value>
3333
</setting>
3434
<setting name="version_release" serializeAs="String">
35-
<value>9</value>
35+
<value>11</value>
3636
</setting>
3737
<setting name="repository_name" serializeAs="String">
3838
<value>LottoDataManager</value>

Includes/Classes/Reports/DashboardReport.cs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -328,22 +328,19 @@ private List<DashboardReportItemSetup> GetLotteryBetsInQueue()
328328
LotteryDetails lotteryDetails = LotteryDataServices.LotteryDetails;
329329
foreach (Lottery lottery in LotteryDataServices.GetLotteries())
330330
{
331-
if(lotteryDetails.GameMode != lottery.GetGameMode())
331+
List<LotteryBet> lotteryBetList = LotteryDataServices.GetLotterybetsQueued(lottery.GetGameMode());
332+
if (lotteryBetList.Count <= 0) continue;
333+
foreach(LotteryBet bet in lotteryBetList)
332334
{
333-
List<LotteryBet> lotteryBetList = LotteryDataServices.GetLotterybetsQueued(lottery.GetGameMode());
334-
if (lotteryBetList.Count <= 0) continue;
335-
foreach(LotteryBet bet in lotteryBetList)
336-
{
337-
String key = DateTimeConverterUtils.ConvertToFormat(bet.GetTargetDrawDate(), DateTimeConverterUtils.STANDARD_DATE_FORMAT_WITH_DAYOFWEEK);
338-
String value = bet.GetGNUFormat();
339-
DashboardReportItemSetup dshSetup = GenModel(key, value);
340-
dshSetup.DashboardReportItemAction = DashboardReportItemActions.OPEN_LOTTERY_GAME;
341-
dshSetup.Tag = lottery.GetGameMode();
342-
dshSetup.GroupTaskLabel = ResourcesUtils.GetMessage("drpt_lot_bet_group_lbl_task");
343-
dshSetup.GroupKeyName = ResourcesUtils.GetMessage("drpt_lot_bet_group_lbl", lottery.GetDescription(), lotteryBetList.Count.ToString());
344-
dshSetup.ReportItemDecoration.IsHyperLink = true;
345-
itemsList.Add(dshSetup);
346-
}
335+
String key = DateTimeConverterUtils.ConvertToFormat(bet.GetTargetDrawDate(), DateTimeConverterUtils.STANDARD_DATE_FORMAT_WITH_DAYOFWEEK);
336+
String value = bet.GetGNUFormat();
337+
DashboardReportItemSetup dshSetup = GenModel(key, value);
338+
dshSetup.DashboardReportItemAction = DashboardReportItemActions.OPEN_LOTTERY_GAME;
339+
dshSetup.Tag = lottery.GetGameMode();
340+
dshSetup.GroupTaskLabel = ResourcesUtils.GetMessage("drpt_lot_bet_group_lbl_task");
341+
dshSetup.GroupKeyName = ResourcesUtils.GetMessage("drpt_lot_bet_group_lbl", lottery.GetDescription(), lotteryBetList.Count.ToString());
342+
dshSetup.ReportItemDecoration.IsHyperLink = true;
343+
itemsList.Add(dshSetup);
347344
}
348345
}
349346
return itemsList;

Includes/Classes/Reports/Templates/IndividualGameHTMLReportView.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ namespace LottoDataManager.Includes.Classes.Reports.Templates
1111
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "16.0.0.0")]
1212
public partial class IndividualGameHTMLReportView : IndividualGameHTMLReportViewBase
1313
{
14-
public virtual string TransformText() { return ""; }
1514

16-
public virtual void Initialize() { }
1715
}
1816

1917
#region Base class

Includes/Database/DAO/Impl/LotteryBetDaoImpl.cs

Lines changed: 69 additions & 67 deletions
Large diffs are not rendered by default.

Includes/Database/DAO/Impl/LotteryDaoImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public Lottery GetLottery(GameMode gameCode)
3333
{
3434
command.CommandType = CommandType.Text;
3535
command.CommandText = "SELECT * FROM lottery WHERE game_cd = @game_cd AND active = true;";
36-
command.Parameters.AddWithValue("@game_cd", gameCode);
36+
command.Parameters.Add("@game_cd", OleDbType.Integer).Value = gameCode;
3737
command.Connection = conn;
3838
conn.Open();
3939

Includes/Database/DAO/Impl/LotteryDrawResultDaoImpl.cs

Lines changed: 45 additions & 58 deletions
Large diffs are not rendered by default.

Includes/Database/DAO/Impl/LotteryOutletDaoImpl.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public LotteryOutlet GetDefaultLotteryOutlet()
5656
{
5757
command.CommandType = CommandType.Text;
5858
command.CommandText = "SELECT * FROM lottery_outlet WHERE outlet_cd = @outlet_cd AND active = true ORDER BY description ASC";
59-
command.Parameters.AddWithValue("@outlet_cd", ResourcesUtils.LotteryOutletDefaultCode);
59+
command.Parameters.Add("@outlet_cd", OleDbType.Integer).Value = ResourcesUtils.LotteryOutletDefaultCode;
6060
command.Connection = conn;
6161
conn.Open();
6262

@@ -79,9 +79,9 @@ public void UpdateDescription(LotteryOutlet updatedModel)
7979
command.CommandType = CommandType.Text;
8080
command.CommandText = " UPDATE lottery_outlet SET description = @description " +
8181
" WHERE ID = @id AND outlet_cd = @outlet_cd AND active = true";
82-
command.Parameters.AddWithValue("@description", StringUtils.Truncate(updatedModel.GetDescription(), MAX_LEN_DESCRIPTION));
83-
command.Parameters.AddWithValue("@id", updatedModel.GetId());
84-
command.Parameters.AddWithValue("@outlet_cd", updatedModel.GetOutletCode());
82+
command.Parameters.Add("@description", OleDbType.Variant).Value = StringUtils.Truncate(updatedModel.GetDescription(), MAX_LEN_DESCRIPTION);
83+
command.Parameters.Add("@id", OleDbType.Integer).Value = updatedModel.GetId();
84+
command.Parameters.Add("@outlet_cd", OleDbType.Integer).Value = updatedModel.GetOutletCode();
8585
command.Connection = conn;
8686
conn.Open();
8787
OleDbTransaction transaction = conn.BeginTransaction();
@@ -105,7 +105,7 @@ public bool IsLotteryOutletUsed(int outletCd)
105105
command.CommandText = "SELECT count(ID) AS [total] FROM lottery_bet " +
106106
" WHERE outlet_cd = @outlet_cd " +
107107
" AND active = true ";
108-
command.Parameters.AddWithValue("@outlet_cd", outletCd);
108+
command.Parameters.Add("@outlet_cd", OleDbType.Integer).Value = outletCd;
109109
command.Connection = conn;
110110
conn.Open();
111111
using (OleDbDataReader reader = command.ExecuteReader())
@@ -135,9 +135,9 @@ public void RemoveOutlet(LotteryOutlet modelToRemove)
135135
command.CommandText = " UPDATE lottery_outlet SET active = false " +
136136
" WHERE ID = @id AND outlet_cd = @outlet_cd " +
137137
" AND description = @outlet_desc AND active = true ";
138-
command.Parameters.AddWithValue("@id", modelToRemove.GetId());
139-
command.Parameters.AddWithValue("@outlet_cd", modelToRemove.GetOutletCode());
140-
command.Parameters.AddWithValue("@outlet_desc", modelToRemove.GetDescription());
138+
command.Parameters.Add("@id", OleDbType.Integer).Value = modelToRemove.GetId();
139+
command.Parameters.Add("@outlet_cd", OleDbType.Integer).Value = modelToRemove.GetOutletCode();
140+
command.Parameters.Add("@outlet_desc", OleDbType.Variant).Value = modelToRemove.GetDescription();
141141
command.Connection = conn;
142142
conn.Open();
143143
OleDbTransaction transaction = conn.BeginTransaction();
@@ -161,7 +161,7 @@ public bool IsDescriptionExisting(String outletDescription)
161161
command.CommandText = "SELECT count(ID) AS [total] FROM lottery_outlet " +
162162
" WHERE description = @outletDescription " +
163163
" AND active = true ";
164-
command.Parameters.AddWithValue("@outletDescription", outletDescription);
164+
command.Parameters.Add("@outletDescription", OleDbType.Variant).Value = outletDescription;
165165
command.Connection = conn;
166166
conn.Open();
167167
using (OleDbDataReader reader = command.ExecuteReader())
@@ -195,8 +195,8 @@ public int InsertLotteryOutlet(String outletDescription)
195195
command.CommandType = CommandType.Text;
196196
command.CommandText = " INSERT INTO `lottery_outlet` (`outlet_cd`, `description`, `active`) " +
197197
" VALUES(@nextOutletCode, @outletDescription, true)";
198-
command.Parameters.AddWithValue("@nextOutletCode", nextOutletCode);
199-
command.Parameters.AddWithValue("@outletDescription", StringUtils.Truncate(outletDescription, MAX_LEN_DESCRIPTION));
198+
command.Parameters.Add("@nextOutletCode", OleDbType.Integer).Value = nextOutletCode;
199+
command.Parameters.Add("@outletDescription", OleDbType.Variant).Value = StringUtils.Truncate(outletDescription, MAX_LEN_DESCRIPTION);
200200

201201
command.Connection = conn;
202202
conn.Open();

Includes/Database/DAO/Impl/LotteryScheduleDaoImpl.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public LotterySchedule GetLotterySchedule(GameMode gameMode)
2828
{
2929
using(OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
3030
using(OleDbCommand command = new OleDbCommand("SELECT * FROM lottery_schedule WHERE game_cd = ? AND active = true", conn)) {
31-
command.Parameters.AddWithValue("game_cd", gameMode);
31+
command.Parameters.Add("game_cd", OleDbType.Integer).Value = gameMode;
3232
conn.Open();
3333
using (OleDbDataReader reader = command.ExecuteReader())
3434
{
@@ -48,8 +48,8 @@ public void RemoveLotterySchedule(LotterySchedule lsched)
4848
command.CommandType = CommandType.Text;
4949
command.CommandText = " UPDATE lottery_schedule SET active = false " +
5050
" WHERE ID = @id AND game_cd = @game_cd AND active = true";
51-
command.Parameters.AddWithValue("@id", lsched.GetID());
52-
command.Parameters.AddWithValue("@game_cd", (int) lsched.GetGameMode());
51+
command.Parameters.Add("@id", OleDbType.Integer).Value = lsched.GetID();
52+
command.Parameters.Add("@game_cd", OleDbType.Integer).Value = (int)lsched.GetGameMode();
5353
command.Connection = conn;
5454
conn.Open();
5555
OleDbTransaction transaction = conn.BeginTransaction();
@@ -74,14 +74,14 @@ public int InsertLotterySchedule(LotterySchedule lsched)
7474
" (`game_cd`, `active`, `mon`, `tues`, `wed`, `thurs`, `fri`, `sat`, `sun`) " +
7575
" VALUES " +
7676
" (@game_cd, true, @isMon, @isTue, @isWed, @isThu, @isFri, @isSat, @isSun) ";
77-
command.Parameters.AddWithValue("@game_cd", (int)lsched.GetGameMode());
78-
command.Parameters.AddWithValue("@isMon", lsched.IsMonday());
79-
command.Parameters.AddWithValue("@isTue", lsched.IsTuesday());
80-
command.Parameters.AddWithValue("@isWed", lsched.IsWednesday());
81-
command.Parameters.AddWithValue("@isThu", lsched.IsThursday());
82-
command.Parameters.AddWithValue("@isFri", lsched.IsFriday());
83-
command.Parameters.AddWithValue("@isSat", lsched.IsSaturday());
84-
command.Parameters.AddWithValue("@isSun", lsched.IsSunday());
77+
command.Parameters.Add("@game_cd", OleDbType.Integer).Value = (int)lsched.GetGameMode();
78+
command.Parameters.Add("@isMon", OleDbType.Boolean).Value = lsched.IsMonday();
79+
command.Parameters.Add("@isTue", OleDbType.Boolean).Value = lsched.IsTuesday();
80+
command.Parameters.Add("@isWed", OleDbType.Boolean).Value = lsched.IsWednesday();
81+
command.Parameters.Add("@isThu", OleDbType.Boolean).Value = lsched.IsThursday();
82+
command.Parameters.Add("@isFri", OleDbType.Boolean).Value = lsched.IsFriday();
83+
command.Parameters.Add("@isSat", OleDbType.Boolean).Value = lsched.IsSaturday();
84+
command.Parameters.Add("@isSun", OleDbType.Boolean).Value = lsched.IsSunday();
8585
command.Connection = conn;
8686
conn.Open();
8787
OleDbTransaction transaction = conn.BeginTransaction();

Includes/Database/DAO/Impl/LotterySequenceGenDaoImpl.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public LotterySequenceGenerator GetSeqGenerator(int seqGenId)
4848
using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
4949
using (OleDbCommand command = new OleDbCommand("SELECT * FROM lottery_seq_gen WHERE seqGenId = @seqGenId AND active = true", conn))
5050
{
51-
command.Parameters.AddWithValue("@seqGenId", seqGenId);
51+
command.Parameters.Add("@seqGenId", OleDbType.Integer).Value = seqGenId;
5252
conn.Open();
5353
using (OleDbDataReader reader = command.ExecuteReader())
5454
{
@@ -66,7 +66,7 @@ public LotterySequenceGenerator GetSeqGeneratorByCode(int seqGenCode)
6666
using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
6767
using (OleDbCommand command = new OleDbCommand("SELECT * FROM lottery_seq_gen WHERE seqgencd = @seqGenCode AND active = true", conn))
6868
{
69-
command.Parameters.AddWithValue("@seqGenCode", seqGenCode);
69+
command.Parameters.Add("@seqGenCode", OleDbType.Integer).Value = seqGenCode;
7070
conn.Open();
7171
using (OleDbDataReader reader = command.ExecuteReader())
7272
{
@@ -86,9 +86,9 @@ public void UpdateDescription(LotterySequenceGenerator updatedModel)
8686
command.CommandType = CommandType.Text;
8787
command.CommandText = " UPDATE lottery_seq_gen SET description= @description " +
8888
" WHERE ID = @id AND seqgencd = @seqgencd AND active = true";
89-
command.Parameters.AddWithValue("@description", StringUtils.Truncate(updatedModel.GetDescription(), MAX_LEN_DESCRIPTION));
90-
command.Parameters.AddWithValue("@id", updatedModel.GetID());
91-
command.Parameters.AddWithValue("@seqgencd", updatedModel.GetSeqGenCode());
89+
command.Parameters.Add("@description", OleDbType.Variant).Value = StringUtils.Truncate(updatedModel.GetDescription(), MAX_LEN_DESCRIPTION);
90+
command.Parameters.Add("@id", OleDbType.Integer).Value = updatedModel.GetID();
91+
command.Parameters.Add("@seqgencd", OleDbType.Integer).Value = updatedModel.GetSeqGenCode();
9292
command.Connection = conn;
9393
conn.Open();
9494
OleDbTransaction transaction = conn.BeginTransaction();
@@ -112,7 +112,7 @@ public bool IsDescriptionExisting(String seqGenDescription)
112112
command.CommandText = "SELECT count(ID) AS [total] FROM lottery_seq_gen " +
113113
" WHERE description = @description " +
114114
" AND active = true ";
115-
command.Parameters.AddWithValue("@description", seqGenDescription);
115+
command.Parameters.Add("@description", OleDbType.Variant).Value = seqGenDescription;
116116
command.Connection = conn;
117117
conn.Open();
118118
using (OleDbDataReader reader = command.ExecuteReader())
@@ -139,8 +139,8 @@ public int InsertSequenceGenerator(LotterySequenceGenerator seqGen)
139139
command.CommandText = " INSERT INTO `lottery_seq_gen` (`seqgencd`, `description`, `active`) VALUES(@seqgencd, @desc, true); ";
140140

141141
command.Connection = conn;
142-
command.Parameters.AddWithValue("@seqgencd", seqGen.GetSeqGenCode());
143-
command.Parameters.AddWithValue("@desc", seqGen.GetDescription());
142+
command.Parameters.Add("@seqgencd", OleDbType.Integer).Value = seqGen.GetSeqGenCode();
143+
command.Parameters.Add("@desc", OleDbType.Variant).Value = seqGen.GetDescription();
144144

145145
conn.Open();
146146
OleDbTransaction transaction = conn.BeginTransaction();

Includes/Database/DAO/Impl/LotteryTicketPanelDaoImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public LotteryTicketPanel GetLotteryTicketPanel(GameMode gameMode)
3131
using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource())
3232
using (OleDbCommand command = new OleDbCommand("SELECT * FROM lottery_ticket_panel WHERE game_cd = ? AND active = true;", conn))
3333
{
34-
command.Parameters.AddWithValue("game_cd", gameMode);
34+
command.Parameters.Add("game_cd", OleDbType.Integer).Value = gameMode;
3535
conn.Open();
3636
using (OleDbDataReader reader = command.ExecuteReader())
3737
{

0 commit comments

Comments
 (0)