private void pictureBox2_Click(object sender, EventArgs e) { string user = textBox1.Text; MyAccountInfo mainew = new MyAccountInfo(user); mainew.Show(); this.Close(); }
//---------------------------------------------------------------------------------------------------- public static MyAccountInfo GetInfo() { AjaxService.ASPdatabaseService.GetSetVal(); var user = ASPdatabaseNET.Users.UserSessionLogic.GetUserSession_ForClient().UserInfo; var rtn = new MyAccountInfo() { UserId = user.UserId, Username = user.Username, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email }; return(rtn); }
public ActionResult MyAccount(MyAccountInfo uInfo, HttpPostedFileBase UserImage) { if (ModelState.IsValid) { using (var uRepository = new UserRepository()) { uRepository.UpdateUser(uInfo, UserImage != null ? UserImage.InputStream : null, UserImage != null ? UserImage.FileName : null); ViewBag.AccountUpdateSuccess = true; // yes, do this - it forces the account to be retrieved from the database again, but keeps the viewbag entry return(MyAccount()); } } return(View(viewName: "NewMyAccount", model: uInfo)); }
//---------------------------------------------------------------------------------------------------- public static void ResetPassword(MyAccountInfo myAccountInfo, string passwordOld, string password1, string password2) { var user = ASPdatabaseNET.Users.UserSessionLogic.GetUserSession_ForClient().UserInfo; if (user.UserId != myAccountInfo.UserId) { throw new Exception("Invalid Request"); } UI.PageParts.Users.Backend.UsersLogic.ValidatePassword(password1); if (password1 != password2) { throw new Exception("'New Password' and 'Repeat New Password' do not match."); } UI.PageParts.Users.Backend.UsersLogic.SavePassword(user.UserId, passwordOld, password1); }
public static void BalanceChangedMethod2( MyAccountInfo oldAccountInfo, MyAccountInfo newAccountInfo) { if (CrunchUtilitiesPlugin.file != null && CrunchUtilitiesPlugin.file.EconomyChangesInLog) { if (MySession.Static.Factions.TryGetFactionById(newAccountInfo.OwnerIdentifier) != null && newAccountInfo.Log.Count() > 0) { long change; if (oldAccountInfo.Balance > newAccountInfo.Balance) { change = oldAccountInfo.Balance - newAccountInfo.Balance; log.Info("FACTIONLOG Faction balance decreased by " + MySession.Static.Factions.TryGetFactionById(newAccountInfo.OwnerIdentifier).Tag + " " + newAccountInfo.OwnerIdentifier + " amount: " + String.Format("{0:n0}", newAccountInfo.Log.Last().Amount) + " SC. by " + newAccountInfo.Log.Last().ChangeIdentifier + " New Total " + String.Format("{0:n0}", newAccountInfo.Balance)); } else { change = newAccountInfo.Balance - oldAccountInfo.Balance; log.Info("FACTIONLOG Faction balance increased by " + MySession.Static.Factions.TryGetFactionById(newAccountInfo.OwnerIdentifier).Tag + " " + newAccountInfo.OwnerIdentifier + " amount: " + String.Format("{0:n0}", newAccountInfo.Log.Last().Amount) + " SC. by " + newAccountInfo.Log.Last().ChangeIdentifier + " New Total " + String.Format("{0:n0}", newAccountInfo.Balance)); } } else { if (MySession.Static.Players.TryGetSteamId(oldAccountInfo.OwnerIdentifier) > 0) { long change; if (oldAccountInfo.Balance > newAccountInfo.Balance) { change = oldAccountInfo.Balance - newAccountInfo.Balance; log.Info("Player Balance decreased by: " + String.Format("{0:n0}", change) + " from " + String.Format("{0:n0}", oldAccountInfo.Balance) + " SC to " + String.Format("{0:n0}", newAccountInfo.Balance) + " SC. steam id: " + MySession.Static.Players.TryGetSteamId(oldAccountInfo.OwnerIdentifier) + " identity id: " + oldAccountInfo.OwnerIdentifier); } else { change = newAccountInfo.Balance - oldAccountInfo.Balance; log.Info("Player Balance increased by: " + String.Format("{0:n0}", change) + " from " + String.Format("{0:n0}", oldAccountInfo.Balance) + " SC to " + String.Format("{0:n0}", newAccountInfo.Balance) + " SC. steam id: " + MySession.Static.Players.TryGetSteamId(oldAccountInfo.OwnerIdentifier) + " identity id: " + oldAccountInfo.OwnerIdentifier); } } } } if (CrunchUtilitiesPlugin.file != null && CrunchUtilitiesPlugin.file.EcoChatMessages) { if (Sync.Players.TryGetPlayerId(newAccountInfo.OwnerIdentifier, out MyPlayer.PlayerId player)) { if (MySession.Static.Players.TryGetPlayerById(player, out MyPlayer pp)) { MySession.Static.Players.TryGetSteamId(newAccountInfo.OwnerIdentifier); // foreach (MyPlayer player in MySession.Static.Players.GetOnlinePlayers()) // { // if (player.Identity.IdentityId == identifierId) // { long change; if (oldAccountInfo.Balance > newAccountInfo.Balance) { change = oldAccountInfo.Balance - newAccountInfo.Balance; if (!CrunchUtilitiesPlugin.AlliancesInstalled) { Commands.SendMessage("CrunchEcon", "Balance decreased by: " + String.Format("{0:n0}", change) + " SC", Color.Red, (long)pp.Id.SteamId); } } else { change = newAccountInfo.Balance - oldAccountInfo.Balance; Commands.SendMessage("CrunchEcon", "Balance increased by: " + String.Format("{0:n0}", change) + " SC", Color.Cyan, (long)pp.Id.SteamId); } } } } }
private void btnAddFood_Click(object sender, EventArgs e) { string user = textBox1.Text; string queryAcc = @"SELECT TOP 1 * FROM Account"; SqlDataAdapter da = new SqlDataAdapter(queryAcc, connectionString); DataTable dt = new DataTable(); da.Fill(dt); string name = dt.Rows[0][1].ToString(); if (textBox2.Text != name) { if (textBox3.Text == "") { string modify = @"UPDATE Account SET DisplayName = @dname WHERE UserName = '******'"; SqlConnection con = new SqlConnection(connectionString); SqlCommand com = new SqlCommand(modify, con); con.Open(); com.Parameters.AddWithValue("@dname", textBox2.Text); com.ExecuteNonQuery(); con.Close(); MessageBox.Show("Thông tin đã được thay đổi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); MyAccountInfo mainew = new MyAccountInfo(user); mainew.Show(); } else { string modify = @"UPDATE Account SET Password = @pass WHERE UserName = '******'"; SqlConnection con = new SqlConnection(connectionString); SqlCommand com = new SqlCommand(modify, con); con.Open(); com.Parameters.AddWithValue("@pass", textBox3.Text); com.ExecuteNonQuery(); con.Close(); MessageBox.Show("Thông tin đã được thay đổi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); MyAccountInfo mainew = new MyAccountInfo(user); mainew.Show(); } } else { if (textBox3.Text == textBox4.Text && textBox3.Text != "") { string modify = @"UPDATE Account SET DisplayName = @dname, Password = @pass WHERE UserName = '******'"; SqlConnection con = new SqlConnection(connectionString); SqlCommand com = new SqlCommand(modify, con); con.Open(); com.Parameters.AddWithValue("@dname", textBox2.Text); com.Parameters.AddWithValue("@pass", textBox3.Text); com.ExecuteNonQuery(); con.Close(); MessageBox.Show("Thông tin đã được thay đổi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); MyAccountInfo mainew = new MyAccountInfo(user); mainew.Show(); } else { MessageBox.Show("Vui lòng kiểm tra lại mật khẩu.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
//---------------------------------------------------------------------------------------------------- public static void Save(MyAccountInfo myAccountInfo) { var user = ASPdatabaseNET.Users.UserSessionLogic.GetUserSession_ForClient().UserInfo; if (user.UserId != myAccountInfo.UserId) { throw new Exception("Invalid user info."); } if (String.IsNullOrEmpty(myAccountInfo.FirstName)) { throw new Exception("Please enter your first name."); } if (String.IsNullOrEmpty(myAccountInfo.LastName)) { throw new Exception("Please enter your last name."); } if (String.IsNullOrEmpty(myAccountInfo.Email) && myAccountInfo.Email.Length < 5 && !myAccountInfo.Email.Contains("@")) { throw new Exception("Please enter your email address."); } try { string sql = String.Format(@" update [{0}].[ASPdb_Users] set [FirstName] = @FirstName ,[LastName] = @LastName ,[Email] = @Email where [UserId] = @UserId ", Config.SystemProperties.AppSchema); using (DbConnectionCommand command = UniversalADO.OpenConnectionCommand(sql)) { command.AddParameter("@FirstName", myAccountInfo.FirstName); command.AddParameter("@LastName", myAccountInfo.LastName); command.AddParameter("@Email", myAccountInfo.Email); command.AddParameter("@UserId", myAccountInfo.UserId); command.ExecuteNonQuery(); } sql = String.Format("select * from [{0}].[ASPdb_Users] where [UserId] = @UserId", Config.SystemProperties.AppSchema); using (DbConnectionCommand command = UniversalADO.OpenConnectionCommand(sql)) { command.AddParameter("@UserId", myAccountInfo.UserId); using (DbReaderWrapper reader = command.ExecuteReaderWrapper()) { if (reader.Read()) { user.FirstName = reader.Get("FirstName", ""); user.LastName = reader.Get("LastName", ""); user.Email = reader.Get("Email", ""); } } } } catch (Exception exc) { ASPdb.Framework.Debug.RecordException(exc); throw new Exception("Error while trying to save account info."); } }
public static Boolean StorePatchMethod(MyStoreBlock __instance, long id, int amount, long targetEntityId, MyPlayer player, MyAccountInfo playerAccountInfo) { MyStoreItem storeItem = (MyStoreItem)null; bool proceed = false; foreach (MyStoreItem playerItem in __instance.PlayerItems) { MyCubeGrid grid = __instance.CubeGrid; if (FacUtils.GetFactionTag(FacUtils.GetOwner(grid)) != null && FacUtils.GetFactionTag(FacUtils.GetOwner(grid)).Length > 3 && TruckingPlugin.config.NPCGridContracts) { proceed = true; } if (!grid.Editable || !grid.DestructibleBlocks) { proceed = true; } if (__instance.DisplayNameText != null && __instance.DisplayNameText.ToLower().Contains("hauling contracts") && proceed) { if (playerItem.Id == id) { storeItem = playerItem; break; } } } //this does things if (storeItem != null && proceed) { if (MyBankingSystem.GetBalance(player.Identity.IdentityId) >= storeItem.PricePerUnit) { //if it cant generate a contract, return false if (!TruckingPlugin.GenerateContract(player.Id.SteamId, player.Identity.IdentityId)) { return(false); } else { //do the money transfers then return false so the item stays in the store MyBankingSystem.ChangeBalance(player.Identity.IdentityId, (storeItem.PricePerUnit * -1)); MyBankingSystem.ChangeBalance(__instance.OwnerId, storeItem.PricePerUnit); return(false); } } else { return(false); } } return(true); }