protected void Update_Click(object sender, EventArgs e) { UserTable user = new UserTable(); user.UserID = Int32.Parse(UserID.Text); user.Password = Pass.Text; user.Country = Country.Text; user.Gender = Gender.Text; Status.Text = "User Updated"; }
public static bool InsertUser(String userID, String password, String country, String gender) { try { var context = new ShipmentEntities3(); UserTable user1 = new UserTable(); user1.UserID = Int32.Parse(userID); user1.Password = password; user1.Country = country; user1.Gender = gender; context.UserTables.Add(user1); context.SaveChanges(); context.Dispose(); return true; } catch (Exception e) { return false; } }
public static bool UpdateUser(UserTable userTable) { var context = new ShipmentEntities3(); var query = from user in context.UserTables where user.UserID == userTable.UserID select user; foreach (UserTable user in query) { user.Password = userTable.Password; user.Country = userTable.Country; user.Gender = userTable.Gender; } try { context.SaveChanges(); return true; } catch (Exception e) { return false; } }