public ActionResult Update(int userid, string username, string password, int stationid) { BLStation blstation = new BLStation(); var usermodel = new UserModel() { StationID = stationid, UserName = username, Password = password, UserID = userid }; new BLUser().UpdateUser(usermodel); return RedirectToAction("Details", new { id = userid }); }
public UserModel GetUser(int userid) { UserModel user = null; try { string strSQL = @" select useraccount.*,station.stationname from useraccount left join station on station.id=useraccount.stationid where useraccount.id=@userid"; SqlParameter[] parms = new SqlParameter[]{ new SqlParameter("@userid",SqlDbType.Int), }; parms[0].Value = userid; using (var rdr = SqlHelper.ExecuteReader(SqlHelper.SQLConnectString, CommandType.Text, strSQL, parms)) { if (rdr.Read()) { user=new UserModel() { StationID = Convert.ToInt32(rdr["StationID"]), StationName = rdr.IsDBNull("StationName") ? "收费科" : Convert.ToString(rdr["StationName"]), UserID = Convert.ToInt32(rdr["ID"]), UserName = Convert.ToString(rdr["UserName"]), Role=Convert.ToInt32(rdr["Role"]), Password=Convert.ToString(rdr["password"]) }; } } } catch { throw; } return user; }
public void UpdateUser(UserModel user) { try { string strSQL = @" update useraccount set password=@password, username=@username, stationid=@stationid where id=@userid "; SqlParameter[] parms = new SqlParameter[]{ new SqlParameter("@userid",SqlDbType.Int), new SqlParameter("@password",SqlDbType.NVarChar,1024), new SqlParameter("@username",SqlDbType.NVarChar,1024), new SqlParameter("@stationid",SqlDbType.Int) }; parms[0].Value = user.UserID; parms[1].Value = user.Password; parms[2].Value = user.UserName; parms[3].Value = user.StationID; SqlHelper.ExecuteNonQuery(SqlHelper.SQLConnectString, CommandType.Text, strSQL, parms); } catch (Exception ex) { throw; } }
public void UpdateUser(UserModel user) { daUser.UpdateUser(user); }