private void WrongGuess() { MessageBox.Show("Unfortunately, your guess is wrong."); PointCardDataBaseControl.Updata("RemainLuckyDrawTimes", (PointCardDataBaseControl.remainLuckyDrawTimes - 1).ToString()); Close(); }
// It use to make it draggable. // #endregion private void TopUpToPlayer() { PlayerDataBaseControl.Load(); PointCardDataBaseControl.pointCardID = txtPointCardID.Text; PointCardDataBaseControl.Load(); int beforeGoldCoins = int.Parse(PlayerDataBaseControl.GetData("PlayerGoldCoins")); int newGoldCoins = beforeGoldCoins + PointCardDataBaseControl.goldCoins; PlayerDataBaseControl.Updata_PlayerGoldCoins(newGoldCoins); PointCardDataBaseControl.Updata_Status("Actived"); TopUpHistoryDataBaseControl.topUpDate = DateTime.Now.ToString("dd/MM/yyyy"); TopUpHistoryDataBaseControl.Insert(); MessageBox.Show("Top " + txtPointCardID.Text + " to " + PlayerDataBaseControl.playerAccountName + "(" + PlayerDataBaseControl.playerID + ")" + " Success.\n" + "\n" + "The Point Card retail value is " + PointCardDataBaseControl.retailValue + ".\n" + "The Point Card gold coins value is " + PointCardDataBaseControl.goldCoins + ".\n" + "\n" + "The PlayerGoldCoins of " + txtPlayerAccountName.Text + " from " + beforeGoldCoins + " to " + newGoldCoins + "."); txtPlayerID.Text = ""; txtPlayerAccountName.Text = ""; txtPointCardID.Text = ""; }
private void LuckDraw() { MessageBox.Show("You are correct!\nYou has a lucky draw."); randomNum = rnd.Next(1, 100); double mult = 1; if (randomNum <= 50) { mult = 1.1; MessageBox.Show("Chance of increasing 10 % of topped-up Virtual Gold Coins."); } else if (randomNum <= 50 + 30) { mult = 1.2; MessageBox.Show("Chance of increasing 20 % of topped-up Virtual Gold Coins."); } else if (randomNum <= 50 + 30 + 15) { mult = 1.5; MessageBox.Show("Chance of increasing 50 % of topped-up Virtual Gold Coins."); } else if (randomNum <= 50 + 30 + 15 + 5) { mult = 2; MessageBox.Show("Chance of increasing 100 % of topped-up Virtual Gold Coins."); } PlayerDataBaseControl.playerGoldCoins = (int)(PlayerDataBaseControl.playerGoldCoins * mult); PlayerDataBaseControl.Updata("PlayerGoldCoins", PlayerDataBaseControl.playerGoldCoins.ToString()); PointCardDataBaseControl.Updata("RemainLuckyDrawTimes", (PointCardDataBaseControl.remainLuckyDrawTimes - 1).ToString()); Close(); }
private void RefreshPage() { PointCardDataBaseControl.Load(); lblPointCardIDOutput.Text = PointCardDataBaseControl.pointCardID; lblRetailValueOutput.Text = PointCardDataBaseControl.retailValue.ToString(); lblGoldCoinsOutput.Text = PointCardDataBaseControl.goldCoins.ToString(); lblStatusOutput.Text = PointCardDataBaseControl.status; lblGenerationDateOutput.Text = PointCardDataBaseControl.generationDate; lblRemainLuckyDrawTimesOutput.Text = PointCardDataBaseControl.remainLuckyDrawTimes.ToString(); }
private void BtnTopUp_Click(object sender, EventArgs e) { if (PointCardDataBaseControl.status != "Actived") { tryTimes++; if (tryTimes == 4) { PointCardDataBaseControl.Updata_Status("Suspended"); MessageBox.Show("Too many password attempts, the point card has been frozen (Suspended)."); RefreshPage(); return; } } if (txtActivePassword.Text == "") { MessageBox.Show("Active Password can not be empty."); return; } if (!DataBaseControl.MatchingPointCardIDActivePwd_InPointCardTable(PointCardDataBaseControl.pointCardID, txtActivePassword.Text)) { MessageBox.Show("Active Password is Incorrect."); return; } if (PointCardDataBaseControl.status == "Actived") { MessageBox.Show("It Point Card have been Actived."); return; } if (PointCardDataBaseControl.status == "Suspended") { MessageBox.Show("It Point Card is Suspended, please contact the staff."); return; } int newGoldCoins = PlayerDataBaseControl.playerGoldCoins + PointCardDataBaseControl.goldCoins; PlayerDataBaseControl.Updata_PlayerGoldCoins(newGoldCoins); PointCardDataBaseControl.Updata_Status("Actived"); TopUpHistoryDataBaseControl.topUpDate = DateTime.Now.ToString("dd/MM/yyyy"); TopUpHistoryDataBaseControl.Insert(); MessageBox.Show("Top Up success."); txtActivePassword.Text = ""; RefreshPage(); }
private void PlayerProfile_ViewPointCardHistory_Load(object sender, EventArgs e) { TopUpHistoryDataBaseControl.Load(); lblPointCardHistory.Text = ""; for (int i = 0; i < TopUpHistoryDataBaseControl.dataTable.Rows.Count; i++) { lblPointCardHistory.Text += "PointCardID: " + TopUpHistoryDataBaseControl.PointCardIDs[i] + " "; lblPointCardHistory.Text += "RetailValue: " + PointCardDataBaseControl.GetData_ByColumn( "PointCardID", TopUpHistoryDataBaseControl.PointCardIDs[i], "RetailValue") + " "; lblPointCardHistory.Text += "TopUpDate: " + TopUpHistoryDataBaseControl.TopUpDates[i] + Environment.NewLine; } }
private void BtnChangeRemainLuckyDrawTimes_Click(object sender, EventArgs e) { PointCardDataBaseControl.Updata_RemainLuckyDrawTimes(int.Parse(txtRemainLuckyDrawTimes.Text)); Close(); }
private void BtnQuantityEnter_Click(object sender, EventArgs e) { if (txtQuantity.Text == "") { MessageBox.Show("Quantity can not be empty."); return; } if (txtRetailValue.Text == "") { MessageBox.Show("Retail Value can not be empty"); return; } int quantity; if (!int.TryParse(txtQuantity.Text, out quantity)) { MessageBox.Show("Quantity not a number."); return; } int retailValue; if (!int.TryParse(txtRetailValue.Text, out retailValue)) { MessageBox.Show("Retail Value not a number."); return; } if (quantity < 0) { MessageBox.Show("Quantity can not be negative"); return; } if (retailValue < 0) { MessageBox.Show("RetailValue can not be negative"); return; } if (quantity == 0) { MessageBox.Show("Quantity can not be Zero"); return; } if (retailValue == 0) { MessageBox.Show("RetailValue can not be Zero"); return; } PointCardDataBaseControl.retailValue = retailValue; if (retailValue >= 200) { PointCardDataBaseControl.goldCoins = 800; PointCardDataBaseControl.remainLuckyDrawTimes = 2; } else if (retailValue >= 100) { PointCardDataBaseControl.goldCoins = 350; PointCardDataBaseControl.remainLuckyDrawTimes = 1; } else { PointCardDataBaseControl.goldCoins = 150; PointCardDataBaseControl.remainLuckyDrawTimes = 0; } PointCardDataBaseControl.status = "Inactive"; PointCardDataBaseControl.generationDate = DateTime.Now.ToString("dd/MM/yyyy"); for (int i = 0; i < quantity; i++) { PointCardDataBaseControl.pointCardID = "V" + (SystemDataBaseControl.Get_PointCardNum() + 1 + i).ToString().PadLeft(7, '0'); PointCardDataBaseControl.activePwd = CreatePassword(8); PointCardDataBaseControl.Insert(); } MessageBox.Show("Point Cards create success."); txtQuantity.Text = ""; txtRetailValue.Text = ""; MessageBox.Show("The Range of Point Card ID is " + "V" + (SystemDataBaseControl.Get_PointCardNum() + 1).ToString().PadLeft(7, '0') + " to " + "V" + (SystemDataBaseControl.Get_PointCardNum() + quantity).ToString().PadLeft(7, '0')); SystemDataBaseControl.Updata_PointCardNum(SystemDataBaseControl.Get_PointCardNum() + quantity); }
private void BtnChangeStatus_Click(object sender, EventArgs e) { PointCardDataBaseControl.Updata_Status(txtStatus.Text); Close(); }
private void BtnChangeGoldCoins_Click(object sender, EventArgs e) { PointCardDataBaseControl.Updata_GoldCoins(int.Parse(txtGoldCoins.Text)); Close(); }
private void BtnChangeRetailValue_Click(object sender, EventArgs e) { PointCardDataBaseControl.Updata_RetailValue(int.Parse(txtRetailValue.Text)); Close(); }