public ActionResult Profiles() { string username = (string)Session["username"]; Models.UserProfileModel user = Respository.Users.GetUsers(username); return(View(user)); }
// 获取用户信息 public static Models.UserProfileModel GetUsers(string username) { SqlParameter[] sqlParameters = new SqlParameter[] { new SqlParameter("@Username", username) }; string sql = "select * from users where username = @Username"; SqlDataReader sqlData = SqlHelper.ExecuteTable(sql, sqlParameters); if (sqlData != null && sqlData.Read()) { Models.UserProfileModel user = new Models.UserProfileModel { Username = sqlData.GetString(0), Passwd = sqlData.GetString(1), Email = sqlData.GetString(2), Level = sqlData.GetInt32(3), Address = sqlData.IsDBNull(4) ? null: sqlData.GetString(4), Birthday = sqlData.IsDBNull(5) ? DateTime.Now : sqlData.GetDateTime(5), PhoneNumber = sqlData.IsDBNull(6) ? null : sqlData.GetString(6), RegisterTime = sqlData.GetDateTime(7), QQNumber = sqlData.IsDBNull(8) ? 0 : sqlData.GetInt32(8) }; sqlData.Close(); return(user); } return(null); }
private bool SaveUser(Models.UserProfileModel model) { //if (Validated_StudentInfo(model)) //{ string strConnection = ConfigurationManager.ConnectionStrings["UsedConnection"].ConnectionString; using (var conn = new SqlConnection(strConnection)) using (var cmd = conn.CreateCommand()) { conn.Open(); cmd.CommandText = "INSERT INTO U_Users (UserName, Password, Name, Designation, Email, RoleID, ProvinceID, ZoneID, DevisionID, SchoolID, CreateUser) " + "VALUES(@UserName, @Password, @Name, @Designation, @Email, @RoleID, @ProvinceID, @ZoneID, @DevisionID, @SchoolID, @CreateUser) "; cmd.Parameters.AddWithValue("@UserName", model.UserName); cmd.Parameters.AddWithValue("@Password", model.Password); cmd.Parameters.AddWithValue("@Name", model.Name); cmd.Parameters.AddWithValue("@Designation", model.Designation); cmd.Parameters.AddWithValue("@Email", model.Email); cmd.Parameters.AddWithValue("@RoleID", model.RoleID); cmd.Parameters.AddWithValue("@ProvinceID", model.ProvinceID); cmd.Parameters.AddWithValue("@ZoneID", model.ZoneID); cmd.Parameters.AddWithValue("@DevisionID", (model.DevisionID == null?"":model.DevisionID)); cmd.Parameters.AddWithValue("@SchoolID", (model.SchoolID == null?"":model.SchoolID)); cmd.Parameters.AddWithValue("@CreateUser", Session["UserName"].ToString()); cmd.ExecuteNonQuery(); } return(true); }
public ActionResult UserProfile(Models.UserProfileModel model) { if (ModelState.IsValid) { if (model.RoleID == 3 && (model.ZoneID == null || model.ProvinceID == null)) { ModelState.AddModelError("", "Please specify Zone and Province."); } if (model.RoleID == 4 && (model.ZoneID == null || model.ProvinceID == null || model.DevisionID == null)) { ModelState.AddModelError("", "Please specify Zone and Province and Devision."); } if (IsUserExisting(model.UserName)) { ModelState.AddModelError("", "Username already exists. Please try again with a different username."); } if (ModelState.IsValid) { if (SaveUser(model)) { return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("", "Error in Saving."); } } } else { if (model.Password != model.ConfirmPassword) { ModelState.AddModelError("", "Please check the password again and confirm."); } else { // If we got this far, something failed, redisplay form ModelState.AddModelError("", "Please fill the required fields."); } } HomeController homeCtrl = new HomeController(); ViewBag.Roles = GetRoles(Convert.ToInt32(Session["LoginRoleID"])); ViewBag.Provinces = homeCtrl.GetProvinces(); ViewBag.Zones = GetZonesByProvice(model.ProvinceID); ViewBag.Devisions = GetDevisonsByZone(model.ProvinceID, model.ZoneID); ViewBag.Schools = GetSchoolsByDevison(model.ProvinceID, model.ZoneID, model.DevisionID); return(View(model)); }
public ActionResult UserProfile() { Models.UserProfileModel usrProf = new Models.UserProfileModel(); HomeController homeCtrl = new HomeController(); ViewBag.Provinces = homeCtrl.GetProvinces(); ViewBag.Zones = homeCtrl.GetZones(); ViewBag.Devisions = homeCtrl.GetDevisions(usrProf.DevisionID); ViewBag.Roles = GetRoles(Convert.ToInt32(Session["LoginRoleID"])); ViewBag.Schools = homeCtrl.GetSchools(); return(View(usrProf)); }
// 更新用户信息 public static bool UpdateUsers(Models.UserProfileModel profileModel) { SqlParameter[] sqlParameter = new SqlParameter[] { new SqlParameter("@Username", profileModel.Username), new SqlParameter("@Passwd", profileModel.Passwd), new SqlParameter("@Email", profileModel.Email), new SqlParameter("@Level", profileModel.Level), new SqlParameter("@Address", profileModel.Address), new SqlParameter("@Birthday", profileModel.Birthday), new SqlParameter("@PhoneNumber", profileModel.PhoneNumber), new SqlParameter("@RegisterTime", profileModel.RegisterTime), new SqlParameter("@QQNumber", profileModel.QQNumber), }; string sql = "update users set passwd=@Passwd,email=@Email,level=@Level,address=@Address,birthday=@Birthday,phone_number=@PhoneNumber,register_time=@RegisterTime,qq_number=@QQNumber where username = @Username"; return(1 == (int)SqlHelper.ExecuteNoQuery(sql, sqlParameter)); }
public PlayVideoResourcePage() { InitializeComponent(); Task.Run(async() => { if (Device.RuntimePlatform == Device.iOS) { Constants.ShowNewPlayerForSplashScreen = true; } if (Constants.ShowNewPlayerForSplashScreen == true) { await Task.Delay(new TimeSpan(0, 0, 4)); } Xamarin.Essentials.MainThread.BeginInvokeOnMainThread(() => { if (Settings.IsRemember && Settings.Email != string.Empty && Settings.Password != string.Empty) { Models.UserProfileModel result = new Models.UserProfileModel(); result = new Models.UserProfileModel { Email = Settings.Email, LabID = Settings.LabId, UserID = Settings.UserID, UserPass = Settings.Password, Role = Settings.Role, Name = Settings.Name, Phone = Settings.Phone }; Constants.UserProfile = result; App.Current.MainPage = new NavigationPage(new HomeView()); } else { App.Current.MainPage = new NavigationPage(new LoginPage()); } return; }); }); }
private async void LoginCommandAsync(object obj) { await PermissionUtils.CheckPermissions(Plugin.Permissions.Abstractions.Permission.Storage); await PermissionUtils.CheckPermissions(Plugin.Permissions.Abstractions.Permission.Location); var loader = await MaterialDialog.Instance.LoadingDialogAsync("Signing In"); Models.UserProfileModel result = new Models.UserProfileModel(); if (Settings.IsRemember && Settings.Email != string.Empty && Settings.Password != string.Empty) { //result = await AuthServices.Login(Settings.Email, Settings.Password); result = new Models.UserProfileModel { Email = Settings.Email, LabID = Settings.LabId, UserID = Settings.UserID, UserPass = Settings.Password, Role = Settings.Role, Name = Settings.Name, Phone = Settings.Phone }; Constants.UserProfile = result; App.Current.MainPage = new NavigationPage(new HomeView()); } else { if (String.IsNullOrEmpty(Username) || String.IsNullOrEmpty(Password)) { await MaterialDialog.Instance.AlertAsync("Please fill both the fields to continue"); return; } result = await AuthServices.Login(Username, Password); } if (result.Success) { Constants.UserProfile = result; if (RememberChecked) { Settings.Email = !String.IsNullOrEmpty(Constants.UserProfile.Email) ? Constants.UserProfile.Email : Constants.UserProfile.UserID; Settings.Password = Constants.UserProfile.UserPass; Settings.Role = result.Role; Settings.LabId = result.LabID; Settings.Name = result.Name; Settings.Phone = result.Phone; Settings.UserID = result.UserID; Settings.IsRemember = true; } var tokenResult = await FirebaseTokenService.InsertFirebaseToken(result.LabID, result.Role, Settings.FirebaseToken, App.IsAndroid, DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff")); if (tokenResult.Success) { if (String.IsNullOrEmpty(Constants.UserProfile.Email)) { //await PushAsync(new SignUpPage()); await this.Navigation.PushAsync(new SignUpPage(), false); //App.Current.MainPage = new NavigationPage(new SignUpPage()); } else { App.Current.MainPage = new NavigationPage(new HomeView()); } } else { await UserDialogs.Instance.AlertAsync(tokenResult.Message); } } else { await MaterialDialog.Instance.AlertAsync(result.Message); } await loader.DismissAsync(); }