private void RechargeButton_Click(object sender, EventArgs e) { if (RechargeTextBox.Text != "") { float addmoney = float.Parse(RechargeTextBox.Text); var response = AccountsControllerShould.UpdateMoneyAccountController(new RechargeObject(currmoney + addmoney), id); if (response.IsSuccess.ToString() == "False") { MessageBox.Show("Recharge failed!\nUser Id is wrong!", "Error"); } else { RechargeTextBox.Text = ""; currmoney += addmoney; SoDuText.Text = "Money: VND" + Math.Round(currmoney, 2); MessageBox.Show($"Recharge success!\nYour account has VND {Math.Round(currmoney, 2)}!", "Success"); } } else { MessageBox.Show("Money have not entered yet!", "Error"); } }
public Register(string id, string pass, MyHome home) { InitializeComponent(); this.BackColor = Color.FromArgb(42, 46, 51); LOGO.Image = Properties.Resources.steam_logo; txtID.BackColor = Color.FromArgb(42, 46, 51); txtPass.BackColor = Color.FromArgb(42, 46, 51); txtRe.BackColor = Color.FromArgb(42, 46, 51); txtMail.BackColor = Color.FromArgb(42, 46, 51); txtFullname.BackColor = Color.FromArgb(42, 46, 51); txtPhone.BackColor = Color.FromArgb(42, 46, 51); this.idCheckChange = true; this.idChange = id; this.myHome = home; this.Text = "Change Account"; this.button1.Text = "UPDATE"; this.txtPass.Text = pass; this.txtRe.Text = pass; //get account by id var resultGet = AccountsControllerShould.GetUserByIdController(this.idChange); txtFullname.Text = resultGet.FullName; txtID.Text = resultGet.UserName; txtMail.Text = resultGet.Email; txtPhone.Text = resultGet.PhoneNumber; //this.txtPass.Text = "" }
public Profile(GameStore.DTOs.PayloadBody input, MyHome home) { user = input; InitializeComponent(); panel1.BackColor = Color.FromArgb(42, 46, 51); avatar.Image = Properties.Resources.gta5; listGame.BackColor = Color.FromArgb(42, 46, 51); listGame.SmallImageList = imageList1; LoadPurchased(); currmoney = AccountsControllerShould.GetUserByIdController(id).Money; SoDuText.Text = "Money: VND" + Math.Round(currmoney, 2).ToString(); this.myHome = home; }
private void btn_buy_Click(object sender, EventArgs e) { var response = AccountsControllerShould.UserBuyGameController(new BuyGameObject(this.currGame.Id.ToString()), this.id); if (response == "iduserwrong") { MessageBox.Show("User Id is wrong!", "Error"); } else if (response == "notenoughmoney") { DialogResult result = MessageBox.Show("Your account don't have enough money to buy this game!\nDo you want to recharge!", "Error", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Profile.SetUser(User, id); Profile a = new Profile(User, this); a.Show(); this.Enabled = false; } else if (result == DialogResult.No) { } } else if (response == "youhavepurchase") { MessageBox.Show("This game already exists in your game library!\n" + "You should buy another game!", "Error"); } else { MessageBox.Show("Buy game success!\nThe game was moved to the library!", "Success"); User.Money -= currGame.Price; //add and re-show listgame in lib user_game.Add(this.currGame); this.showListGame(); this.panel2.Visible = false; //tiền đã đc api auto chuyển cho publisher //trở về store mua tiếp setStorepanelVisible(true); setGameDetailpanelVisible(false); currGame = null; } }
private void testNapTienUser() { //nhớ validate chỉ nhập đc số thập phân. // kiểm tra nếu tiền < 0 thì báo lỗi //tiền nhập vào + tiền có sẵn của user => đưa xuống update tiền, api ko cộng dồn đc. float money = 100.5F; // tiền nhập vào từ txtMoney.Text var response = AccountsControllerShould.UpdateMoneyAccountController(new RechargeObject(money + User.Money), this.id); if (response.IsSuccess.ToString() == "False") { MessageBox.Show("Recharge failed!\nUser Id is wrong!", "Error"); } else { MessageBox.Show($"Recharge success!\nYour account has ${response.Payload.Money}!", "Success"); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtFreecode.Text)) { MessageBox.Show("You should enter free code!", "Error"); } else { var response = AccountsControllerShould.PostEnterFreeCodeAccountController(new FreeCode(txtFreecode.Text), id); var rs = response.IsSuccess.ToString(); var mess = response.Message; if (rs == "False") { if (mess.Equals("Object reference not set to an instance of an object.")) { txtFreecode.Text = ""; MessageBox.Show("Free code is wrong!", "Error"); } else { txtFreecode.Text = ""; MessageBox.Show("Free code used!\nYou already have this game!", "Error"); } } else { MessageBox.Show("Get game success!"); for (int i = 0; i < myHome.lib_game.Count(); i++) { if (myHome.lib_game.ElementAt(i).Id.ToString() == response.Payload.gameId) { myHome.user_game.Add(myHome.lib_game.ElementAt(i)); break; } } myHome.showListGame(); myHome.setLibpanelVisible(true); myHome.setStorepanelVisible(false); this.Close(); } } }
public void LoadDatabase(string UserId) { GameResponse = GameControllerShould.GetAllGamesController(); User = AccountsControllerShould.GetUserByIdController(UserId); GameSaleResponse = GameControllerShould.GetAllGamesSaleController(); List <GameDTOs> gameDTOs = GameResponse.Payload; foreach (GameDTOs a in gameDTOs) { GameObject temp1 = toGameObject(a); lib_game.Add(temp1); } foreach (TitleGame a in User.Games) { Response <GameDTOs> temp = GameControllerShould.GetGameByIdController(a.Id.ToString()); GameObject gameobj = toGameObject(temp.Payload); user_game.Add(gameobj); } //foreach (TitleGame a in User.WishGames) //{ // Response<GameDTOs> temp = GameControllerShould.GetGameByIdController(a.Id.ToString()); // GameObject gameobj = toGameObject(temp.Payload); // user_wishgame.Add(gameobj); //} foreach (GameDTOs a in GameSaleResponse.Payload) { GameObject gameobj = toGameObject(a); sale_game.Add(gameobj); } if (sale_game.Count() < 4) { for (int i = 0; i < 4; i++) { sale_game.Add(lib_game.ElementAt(i)); } } }
private void btn_AddWishList_Click(object sender, EventArgs e) { TitleGame wishgame = new TitleGame(); Response <GameDTOs> temp = GameControllerShould.GetGameByIdController(currGame.Id.ToString()); //if (user_wishgame != null) //{ // foreach(GameObject a in user_wishgame) // { // if (temp.Payload.Id == a.Id) // { // MessageBox.Show("Game already exist in wishlist", "Error"); // return; // } // } //} //user_wishgame.Add(toGameObject(temp.Payload)); wishgame.Id = temp.Payload.Id; wishgame.ImageGames = temp.Payload.ImageGames; wishgame.Name = temp.Payload.Name; wishgame.ReleaseDate = temp.Payload.PurchaseDate; //User.Password = currPass; //var response = AccountsControllerShould.UpdateAccountController(User, this.id); var response = AccountsControllerShould.PostAccountLikeGameController(new BuyGameObject(this.currGame.Id.ToString()), this.id); if (response == "False") { MessageBox.Show("Fail or Duplicate game to add to wishlist", "Error"); } else { User.WishGames.Add(wishgame); MessageBox.Show("Wish list updated", "Success"); } }
private void button1_Click(object sender, EventArgs e) { Regex reg = new Regex(@"^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$", RegexOptions.IgnoreCase); //register if (!idCheckChange) { if (txtFullname.Text.Length == 0) { txtWarningFullName.Visible = true; MessageBox.Show("Full name is required!"); } else if (txtID.Text.Length == 0) //usernam { txtWarningName.Visible = true; MessageBox.Show("User name is required!"); } else if (!reg.IsMatch(this.txtMail.Text)) { txtWarningMail.Visible = true; MessageBox.Show("Mail not yet entered or wrong format!"); } else if (this.txtPass.Text.Length < 8) { txtWarningPass.Visible = true; MessageBox.Show("Password not yet entered or wrong format!"); } else if (!this.txtPass.Text.Equals(this.txtRe.Text)) { txtWarningRePass.Visible = true; MessageBox.Show("Passwords not match!"); } else if (txtPhone.Text.Length == 0) { txtWarningPhone.Visible = true; MessageBox.Show("Phone number is required!"); } else //register account { string result = AccountsControllerShould.PostNewAccountController( new RegisterObject(txtMail.Text, txtPass.Text, "defaulthobbies", txtFullname.Text, txtPhone.Text, txtID.Text)); if (result == "true") //rs = isSuccess { MessageBox.Show("Register success!"); this.Close(); } else //rs = failed msg { if (result == "user") { MessageBox.Show("User name already exists!", "Error"); } else { MessageBox.Show("Email already exists!", "Error"); } } } } //change account, received id else { if (txtFullname.Text.Length == 0) { txtWarningFullName.Visible = true; MessageBox.Show("Full name is required!"); } else if (txtID.Text.Length == 0) //usernam { txtWarningName.Visible = true; MessageBox.Show("User name is required!"); } else if (!reg.IsMatch(this.txtMail.Text)) { txtWarningMail.Visible = true; MessageBox.Show("Mail not yet entered or wrong format!"); } else if (this.txtPass.Text.Length < 8) { txtWarningPass.Visible = true; MessageBox.Show("Password not yet entered or wrong format!"); } else if (!this.txtPass.Text.Equals(this.txtRe.Text)) { txtWarningRePass.Visible = true; MessageBox.Show("Passwords not match!"); } else if (txtPhone.Text.Length == 0) { txtWarningPhone.Visible = true; MessageBox.Show("Phone number is required!"); } else //change begining { var response = AccountsControllerShould.UpdateAccountController( new RegisterObject(txtMail.Text, txtPass.Text, "defaulthobbies", txtFullname.Text, txtPhone.Text, txtID.Text), this.idChange); var rs = response.IsSuccess.ToString(); if (rs == "False" && response.Message.Equals("Username exited on db")) { MessageBox.Show("User name already exists!", "Error"); } if (rs == "False" && response.Message.Equals(" Email exited on db")) { MessageBox.Show("Email already exists!", "Error"); } if (rs == "True") //rs = isSuccess { txtFullname.Text = response.Payload.FullName; txtID.Text = response.Payload.UserName; txtMail.Text = response.Payload.Email; txtPhone.Text = response.Payload.PhoneNumber; MessageBox.Show("Update success!"); this.Close(); } } } }