public async Task <IActionResult> login(LoginViewModel model) { if (ModelState.IsValid) { AdminInfo user = await _AccountService.LoginAsync(model.UserName, model.Password); if (user != null) { AuthenticationProperties props = new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(1)), AllowRefresh = true }; await HttpContext.SignInAsync(user.Id.ToString(), user.LoginName, props, new Claim(JwtClaimTypes.Role, "admin")); return(Redirect(model.ReturnUrl ?? "/")); } else { View(model.ReturnUrl); } } return(View(model.ReturnUrl)); }
private string GenerateAdminJsonWebToken(AdminInfo admininfo) { var securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["Jwt:Key"])); var credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(JwtRegisteredClaimNames.Sid, admininfo.Id), new Claim(JwtRegisteredClaimNames.UniqueName, admininfo.Username), new Claim(JwtRegisteredClaimNames.GivenName, admininfo.FirstName), new Claim(JwtRegisteredClaimNames.FamilyName, admininfo.LastName), new Claim(JwtRegisteredClaimNames.Acr, admininfo.Initials), new Claim(JwtRegisteredClaimNames.Email, admininfo.EmailAddress), new Claim(JwtRegisteredClaimNames.Typ, admininfo.Role), new Claim(JwtRegisteredClaimNames.Iat, admininfo.IsRegistered.ToString()), new Claim(JwtRegisteredClaimNames.Prn, admininfo.IsBlocked.ToString()), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var token = new JwtSecurityToken( issuer: configuration["Jwt:Issuer"], audience: configuration["Jwt:Issuer"], claims, expires: DateTime.Now.AddMinutes(60), signingCredentials: credentials); var encodedToken = new JwtSecurityTokenHandler().WriteToken(token); return(encodedToken); }
/// <summary> /// 修改管理员信息 /// </summary> /// <param name="mod"></param> /// <exception cref="MySqlException">更新失败</exception> public void AdminModifyInfo(AdminInfoModel mod) { AdminInfoModel info; try { info = GetAdminInfo(mod.ID); } catch (Exception ex) { throw ex; } info.UpdateInfo(mod); var newInfo = new AdminInfo().UpdateInfo(info); try { DbContext.DBstatic.Updateable(newInfo).IgnoreColumns(true, ignoreAllDefaultValue: true) .ExecuteCommand(); } catch (MySqlException ex) { Console.WriteLine(ex.ToString()); //throw ex; } }
// POST api/<controller> public Hashtable Post([FromBody] int areaid, [FromBody] string name, [FromBody] string user_number) { int admin = UserInfo.GetUserIdFromCookie(HttpContext.Current); Hashtable ht = new Hashtable(); AdminInfo ai = new AdminInfo(); if (ai.HasGroupUserName(name)) { ht.Add("state", false); ht.Add("reason", "管理员已存在"); } else { try { ht.Add("state", ai.ChangeGroupAdmin(areaid, name, null, user_number, admin)); } catch (Exception e) { ht.Add("state", false); ht.Add("reason", e.Message); } } return(ht); }
private void Login_Click(object sender, EventArgs e) { string strAccount = tbAccount.Text; string strPassword = tbPassword.Text; if (strPassword == "Password") { strPassword = string.Empty; } if (strAccount == "Account" || strAccount.Length == 0) { MessageBox.Show("帐号不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (strAccount.ToUpper() != "ADMIN") { if (strPassword.Length == 0) { MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } IAdminInfoService adminInfoService = BLL.Container.Container.Resolve <IAdminInfoService>(); AdminInfo adminInfo = adminInfoService.Query(strAccount, strPassword); if (adminInfo == null) { MessageBox.Show("帐号或密码错误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Tag = adminInfo; this.DialogResult = DialogResult.OK; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { GroupID.DataSource = AdminGroupBLL.ReadList(); GroupID.DataTextField = "Name"; GroupID.DataValueField = "ID"; GroupID.DataBind(); int tempAdminID = RequestHelper.GetQueryString <int>("ID"); if (tempAdminID != int.MinValue) { CheckAdminPower("ReadAdmin", PowerCheckType.Single); pageAdmin = AdminBLL.Read(tempAdminID); if (pageAdmin.Id == 1 || pageAdmin.Name.ToLower() == "admin") { Email.Enabled = false; GroupID.Enabled = false; Status.Enabled = false; } GroupID.Text = pageAdmin.GroupId.ToString(); Name.Text = pageAdmin.Name; Name.Enabled = false; Email.Text = pageAdmin.Email; NoteBook.Text = pageAdmin.NoteBook; Add.Visible = false; AddStatus.Visible = true; Status.Text = pageAdmin.Status.ToString(); } } }
public JsonResult AdminInfoAdd(AdminInfo model) { ResultInfo info = new ResultInfo(); var flag = false; if (model.Id <= 0) { if (AdminInfoDBOperate.CheckUserName(model.UserName)) { info.Message = "用户名已存在"; return(Json(info)); } model.PassWord = CommonMethod.PasswordMD5(model.PassWord); flag = AdminInfoDBOperate.AddAdminInfo(model); info.IsSuccess = flag; if (flag) { info.Message = "保存成功"; } } else { flag = AdminInfoDBOperate.ModifyAdminInfo(model); info.IsSuccess = flag; if (flag) { info.Message = "保存成功"; } } return(Json(info)); }
private void SetAdminInfo(string adminId) { AdminInfo adminInfos = _adminInfoManager.GetAllInfo(adminId) ?? new AdminInfo(); Name = adminInfos.AdminName; Photo = Convert.ToString(adminInfos.Photo); }
public static bool ModifyAdminInfo(AdminInfo model) { string sql = string.Format(@"update {0} set [UserName]=@UserName,[Name]=@Name,[CompanyId]=@CompanyId,[Mobile]=@Mobile,[Canceer]=@Canceer,[RoleId]=@RoleId where Id=@Id", TableName); return(DBAccess.ExecuteSqlWithEntity(sql, model)); }
protected void LoginValidate_ServerValidate(object source, ServerValidateEventArgs args) { string userNameRegex = @"^.+$"; if (!Regex.IsMatch(UserName.Text.ToString(), userNameRegex)) { throw new Exception(); } string passwordRegex = @"^.+$"; if (!Regex.IsMatch(UserName.Text.ToString(), passwordRegex)) { throw new Exception(); } AdminInfo admin = bllAdmin.FindByName(UserName.Text.ToString()); if (admin != null && Password.Text.ToString() == admin.Adm_Password) { args.IsValid = true; } else { args.IsValid = false; } }
public ClientManager() { LastReceivedAdminInfo = new AdminInfo(); ClientStatistics = new ClientStatistics(); bands = new EqualizerBand[] { new EqualizerBand { Bandwidth = 0.8f, Frequency = 100, Gain = -10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 200, Gain = -10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 400, Gain = -10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 800, Gain = -10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 1200, Gain = 10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 2400, Gain = 10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 4800, Gain = -10 }, new EqualizerBand { Bandwidth = 0.8f, Frequency = 9600, Gain = -10 }, }; }
public static bool AddAdminInfo(AdminInfo model) { model.Ip = CommonMethod.GetClientIP; string sql = string.Format("insert into {0}(UserName,PassWord,Name,CreateDate,IsDeleted,Ip,CompanyId,Mobile,Canceer,RoleId) values(@UserName,@PassWord,@Name,getdate(),0,@Ip,@CompanyId,@Mobile,@Canceer,@RoleId)", TableName); return(DBAccess.ExecuteSqlWithEntity(sql, model)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="mod">AdminInfo</param> /// <returns>受影响行数</returns> public int Update(AdminInfo mod) { using (DbConnection conn = db.CreateConnection()) { conn.Open(); using (DbTransaction tran = conn.BeginTransaction()) { try { using (DbCommand cmd = db.GetStoredProcCommand("SP_Admin_Update")) { db.AddInParameter(cmd, "@AdminID", DbType.Int32, mod.AdminID); db.AddInParameter(cmd, "@AdminName", DbType.String, mod.AdminName); db.AddInParameter(cmd, "@Password", DbType.String, mod.Password); db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); tran.Commit(); return db.ExecuteNonQuery(cmd); } } catch (Exception e) { tran.Rollback(); throw e; } finally { conn.Close(); } } } }
public Main(AdminInfo adminInfo) { m_AdminInfo = adminInfo; InitializeComponent(); this.Opacity = 0; }
public string login(string name, string pwd) { if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(pwd)) { return(JsonConvert.SerializeObject(new Msg() { status = 0, message = "账号或密码不能为空", action = "" })); } AdminInfo user = OW.BLL.DataManager.GetAdmin(name, pwd); if (user != null) { Session["user"] = user; Session["Username"] = user.AdminName; return(JsonConvert.SerializeObject(new Msg() { status = 1, message = "登录成功!", action = "/Home/Index" })); } else { return(JsonConvert.SerializeObject(new Msg() { status = 0, message = "账号或密码不能为空", action = "" })); } }
protected void Submit_Click(object sender, EventArgs e) { if (!Regex.IsMatch(AdminNickName.Text.ToString(), @"^.{2,10}$")) { throw new Exception(); } if (!Regex.IsMatch(AdminNickName.Text.ToString(), @"^\S*$")) { throw new Exception(); } if (!Regex.IsMatch(AdminEmail.Text.ToString(), @"^([a-zA-Z0-9]+[_|_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$")) { throw new Exception(); } if (!Regex.IsMatch(AdminPassword.Text.ToString(), @"^.{6,10}$")) { throw new Exception(); } if (!Regex.IsMatch(AdminPassword.Text.ToString(), @"^[^\^]+$")) { throw new Exception(); } AdminInfo admin = new AdminInfo(); admin.Adm_UserName = AdminNickName.Text.ToString(); admin.Adm_Email = AdminEmail.Text.ToString(); admin.Adm_Password = AdminPassword.Text.ToString(); admin.Adm_Role = "nomal"; admin.Adm_LastLogin = DateTime.Now; bllAdmin.Add(admin); Response.Redirect("~/User/UserList.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { //if (IsRefresh) //{ // Tools.Show(this.Page, "請勿重複新增!"); // return; //} if (adBLL.getDataByAccount(txtAccount.Text) != null) { AdminInfo Info = new AdminInfo(); Info.a_account = txtAccount.Text; Info.a_password = Tools.GetPassword(txtAccount.Text, txtPass.Text); Info.a_name = txtName.Text; Info.a_nickName = txtNickName.Text; Info.a_editDate = DateTime.Now; if (adBLL.Insert(Info) > 0) { Page.Controls.Add(Tools.Tomsg("新增成功")); Response.Redirect("List.aspx", true); } else { Page.Controls.Add(Tools.Tomsg("新增失敗")); } } else { Page.Controls.Add(Tools.Tomsg("已有相同帳號")); } }
public ActionResult Inbox(string Id) { if (Id == "" || Id == null) { return(RedirectToAction("Index")); } AdminInfo adminInfo = null; Utils utils = new Utils(); try { Id = Id.Trim().Replace(" ", "+"); adminInfo = JsonConvert.DeserializeObject <AdminInfo>(utils.DecryptStringAES(Id)); if (adminInfo == null) { return(RedirectToAction("Index")); } } catch (Exception e) { return(RedirectToAction("Index")); } Session["admin"] = adminInfo; return(View()); }
private void bt_register_Click(object sender, EventArgs e) { if (!tb_username.Text.Equals("") && !tb_pwd.Equals("") && !tb_repwd.Equals("")) { if (tb_pwd.Text.Equals(tb_repwd.Text)) { AdminInfo admin = new AdminInfo(); admin.UserName = tb_username.Text; admin.PassWord = tb_pwd.Text; bool isInsert = AdminInfoManage.InsertAdmin(admin); if (!isInsert) { MessageBox.Show("该用户已存在!请重新注册!"); } else { this.DialogResult = System.Windows.Forms.DialogResult.OK; MessageBox.Show("恭喜您成为新用户!"); } } else { MessageBox.Show("请保持密码一致!"); } } else { MessageBox.Show("请输入有效信息!"); } }
protected void LoginButton_Click(object sender, EventArgs e) { string a = adminIdTextBox.Text.Trim(); string b = passwordTextBox.Text.Trim(); if (!string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b)) { AdminInfo bAdminInfo = new AdminInfo(); bAdminInfo.AdminId = a; bAdminInfo.Passwords = b; string msg = _adminInfoManager.IsExist(a, b); if (msg == "success") { Session["adminId"] = bAdminInfo.AdminId; Response.Redirect("DashboardFirstForm.aspx"); InfoMessageLabel.Text = null; } else if (msg == "failed") { DisplayMessage("Invalid UserId Or Password! Try Again.", Color.Red); } } else { DisplayMessage("Empty Fields Are Required! Try Again.", Color.Red); } }
public async Task ValidateAsync(ResourceOwnerPasswordValidationContext context) { //根据context.UserName和context.Password与数据库的数据做校验,判断是否合法 if (!string.IsNullOrWhiteSpace(context.UserName) && !string.IsNullOrWhiteSpace(context.Password)) { AdminInfo user = await _adminUsers.LoginAsync(context.UserName, context.Password); if (user != null) { context.Result = new GrantValidationResult( subject: context.UserName, authenticationMethod: "custom", claims: new Claim[] { new Claim(JwtClaimTypes.Role, "admin") }, authTime: DateTime.Now.AddDays(1) ); } else { context.Result = new GrantValidationResult(TokenRequestErrors.InvalidRequest, "invalid custom credential"); } } else { //验证失败 context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant, "invalid custom credential"); } }
protected void btnLogin_Click(object sender, EventArgs e) { Database db = new Database(); db.AddParameter("@uname", txtUserName.Text); db.AddParameter("@password", txtPassword.Text); System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where (username=@uname or email=@uname) and (password=@password)"); if (dt.Rows.Count != 0) { if (cbRememberMe.Checked) { HttpCookie c = new HttpCookie("NCSSUserName", txtUserName.Text); c.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(c); c = new HttpCookie("NCSSPassword", txtPassword.Text); c.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(c); } else { HttpCookie c = new HttpCookie("NCSSUserName", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); c = new HttpCookie("NCSSPassword", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); } if (cbKeepMeLogin.Checked) { HttpCookie c = new HttpCookie("NCSSCMSKeepOnline", dt.Rows[0]["id"].ToString()); c.Expires = DateTime.Now.AddDays(20); Response.Cookies.Add(c); } else { HttpCookie c = new HttpCookie("NCSSCMSKeepOnline", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); } AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString()); Session["AdminInfo"] = admininfo; if (Request.QueryString["url"] == null) { Response.Redirect("default.aspx"); } else { Response.Redirect(Request.QueryString.ToString().Replace("url=", "").Replace("%2f", "").Replace("Admin", "").Replace("admin", "").Replace("%3f", "?").Replace("%3d", "=")); } } else { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> Error Login : Check Your Login Information And Try again "; } }
public JsonResult FinanceReportAdd(FinanceReport model) { ResultInfo info = new ResultInfo(); var flag = false; AdminInfo admin = CookieOperate.UserAdminCookie; model.CreateBy = admin.UserName; if (model.Id <= 0) { flag = FinanceReportDBOperate.AddFinanceReport(model); info.IsSuccess = flag; if (flag) { info.Message = "保存成功"; } } else { flag = FinanceReportDBOperate.ModifyFinanceReport(model); info.IsSuccess = flag; if (flag) { info.Message = "保存成功"; } } return(Json(info)); }
/// <summary> /// 修改Action方法 /// </summary> /// <param name="ai">存储当前要修改的数据</param> /// <returns>返回字符串用来判断执行结果</returns> public ActionResult Edit(AdminInfo admin) { SysLog log = new SysLog { Behavior = (Session["Admin"] as AdminInfo).UserName + "修改了" + admin.UserName + "的信息", FK_TypeID = 5, FK_AdminID = (Session["Admin"] as AdminInfo).AdminID, Parameters = "UserName", IP = Request.UserHostAddress, CheckInTime = DateTime.Now }; try { //更新实体 var data = db.AdminInfo.Find(admin.AdminID); data.UserName = admin.UserName; db.SaveChanges(); log.IsException = 0; log.Exception = string.Empty; db.SysLog.Add(log); db.SaveChanges(); return(Json(new AjaxResult { state = ResultType.success.ToString(), message = "修改成功" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { log.IsException = 1; log.Exception = ex.Message; db.SysLog.Add(log); db.SaveChanges(); return(Json(new AjaxResult { state = ResultType.error.ToString(), message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public int DelAdmin(int id) { AdminInfo admin = context.AdminInfo.ToList().Where(x => x.AdminId == 8).FirstOrDefault(); context.AdminInfo.Remove(admin); return(context.SaveChanges()); }
public AdminInfo Update(AdminInfo admin) { var prm = new SqlParameter[6]; prm[0] = new SqlParameter("@ID", admin.ID); prm[1] = new SqlParameter("@Username", admin.Username); prm[2] = new SqlParameter("@Password", Encrypt.MD5Admin(admin.Password)); prm[3] = new SqlParameter("@FullName", admin.FullName); prm[4] = new SqlParameter("@Status", admin.Status); prm[5] = new SqlParameter("@IsLogin", admin.IsLogin); try { DataHelper.ExecuteNonQuery(STORE_UPDATE, prm); //AdminInfo admin2 = (AdminInfo)System.Web.HttpContext.Current.Session[Constant.SessionNameAccountAdmin]; //if (admin2 != null) //{ // LogAdminInfo log = new LogAdminInfo(); // log.AdminName = admin2.Username; // log.CreateLog = DateTime.Now; // log.Action = 2; // log.Description = "Cập nhật quản trị viên hệ thống : " + admin2.Username; // insertLog(log); //} } catch (Exception ex) { Utility.LogEvent(ex); throw new Exception("Hiện tại server đang bận, xin vui lòng truy vấn lại sau."); } return(admin); }
protected void SubmitButton_Click(object sender, EventArgs E) { string oldPassword = StringHelper.Password(Password.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); string newPassword = StringHelper.Password(NewPassword.Text, (PasswordType)ShopConfig.ReadConfigInfo().PasswordType); AdminInfo admin = AdminBLL.Read(Cookies.Admin.GetAdminID(false)); if (admin.Password == oldPassword) { AdminBLL.ChangePassword(Cookies.Admin.GetAdminID(false), oldPassword, newPassword); AdminLogBLL.Add(ShopLanguage.ReadLanguage("ChangePassword")); Task.Run(() => { //安全码 ShopConfigInfo config = ShopConfig.ReadConfigInfo(); config.SecureKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); ShopConfig.UpdateConfigInfo(config); }); //清除现有cookie CookiesHelper.DeleteCookie(ShopConfig.ReadConfigInfo().AdminCookies); ScriptHelper.Alert(ShopLanguage.ReadLanguage("UpdateOK"), RequestHelper.RawUrl); } else { ScriptHelper.Alert(ShopLanguage.ReadLanguage("OldPasswordError"), RequestHelper.RawUrl); } }
protected void IsLogin() { //#if DEBUG//本地测试不用登陆 // if (!Request.IsAuthenticated) // { // SOSOshop.BLL.Administrators bll = new SOSOshop.BLL.Administrators(); // SOSOshop.Model.Administrators model = bll.GetModelByAdminName("admin"); // SOSOshop.Model.AdminInfo admin = new SOSOshop.Model.AdminInfo(); // if (model.Power.Equals(0)) // { // admin.AdminPowerType = "all"; // } // else // { // //非管理员权限,等待添加相关内容 // admin.AdminPowerType = ""; // } // admin.AdminId = model.AdminId; // admin.AdminName = model.Name; // admin.AdminRole = model.Role; // SOSOshop.BLL.AdministrorManager.Set(admin); // } //#endif if (!SOSOshop.BLL.AdministrorManager.CheckAdmin()) { Response.Redirect("/admin/index.aspx"); Response.End(); } AdminInfo adminModel = (AdminInfo)SOSOshop.BLL.AdministrorManager.Get(); this.UserId = adminModel.AdminId; this.UserName = adminModel.AdminName; }
public static string GetAdminLogin(string adminName, string adminPwd, string adminIP) { L_AdminInfo admininfo = new AdminInfo().LoginAdmin(adminName, adminPwd, adminIP); if (admininfo == null) { return("用户不存在"); } else { if (string.IsNullOrEmpty(admininfo.Message)) { HttpContext.Current.Session["shop8517Admin"] = admininfo.AdminID.ToString(); HttpCookie newcookie = new HttpCookie("shop8517Admin"); newcookie.Values["adminID"] = admininfo.AdminID.ToString(); newcookie.Values["adminName"] = admininfo.AdminName; newcookie.Values["adminType"] = admininfo.AdminType.ToString(); newcookie.Path = "/"; HttpContext.Current.Response.AppendCookie(newcookie); return(""); } else { return(admininfo.Message); } } }
protected void Page_Init(object sender, EventArgs e) { if (Request.Cookies["NCSSCMSKeepOnline"] != null) { int id; if (int.TryParse(Request.Cookies["NCSSCMSKeepOnline"].Value, out id)) { Database db = new Database(); db.AddParameter("@id", id); System.Data.DataTable dt = db.ExecuteDataTable("Select * from adminUsers where id=@id"); db.Dispose1(); if (dt.Rows.Count != 0) { AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString()); Session["AdminInfo"] = admininfo; } } } if (Session["AdminInfo"] == null) { Response.Redirect("Login.aspx?url=" + Request.RawUrl); } if (!Page.IsPostBack) { AdminInfo admininfo = (AdminInfo)Session["AdminInfo"]; HyperLink1.Text = "<span><i class=\"fa fa-smile-o\"></i> " + admininfo.Name + "!</span>"; HyperLink1.NavigateUrl = "../AdminOp.aspx?id=" + admininfo.Id + "&Op=Edit"; } }
private void RowDataBound(GridViewRowEventArgs e) { var x = e.Row.DataItemIndex; if (e.Row.DataItemIndex != -1) { e.Row.Cells[0].Text = (e.Row.DataItemIndex + 1).ToString(); var status = (CheckBox)e.Row.Cells[4].FindControl("StatusCheck"); if (((AdminInfo)Session[Constant.SessionNameAccountAdmin]).ID == int.Parse(grvView.DataKeys[e.Row.RowIndex].Value.ToString())) { status.Enabled = false; } e.Row.Cells[1].Text = "<a href=\"admin_add.aspx?ID=" + grvView.DataKeys[e.Row.RowIndex].Value + "\">" + e.Row.Cells[1].Text + "</a>"; var isLogin = (CheckBox)e.Row.Cells[3].FindControl("IsLogin"); int adminID = int.Parse(grvView.DataKeys[e.Row.RowIndex].Value.ToString()); AdminImpl obj = new AdminImpl(); AdminInfo item = obj.GetAdmin(obj.SelectOne(adminID))[0]; if (item.IsLogin == 1) { isLogin.Checked = true; } else { isLogin.Checked = false; } } }
protected void Page_Init(object sender, EventArgs e) { if (Request.Cookies["ASCMSKeepOnline"] != null) { int id; if (int.TryParse(Request.Cookies["ASCMSKeepOnline"].Value, out id)) { Database db = new Database(); db.AddParameter("@id", id); System.Data.DataTable dt = db.ExecuteDataTable("Select * from adminUsers where id=@id"); db.Dispose1(); if (dt.Rows.Count != 0) { AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString()); Session["AdminInfo"] = admininfo; } } } if (Session["AdminInfo"] == null) { Response.Redirect("Login.aspx?url=" + Request.RawUrl); } if (!Page.IsPostBack) { AdminInfo admininfo = (AdminInfo)Session["AdminInfo"]; HyperLink1.Text = "<span><i class=\"fa fa-smile-o\"></i> " + admininfo.Name + "!</span>"; HyperLink1.NavigateUrl = "../AdminOp.aspx?id="+admininfo.Id+"&Op=Edit"; } }
public WindowAuthetification(string connection, AuthType type, string currentAdmin=null, AdminInfo originalInfo=null) { InitializeComponent(); Connection = connection; TYPE_ = type; Father_ = currentAdmin; original = originalInfo; }
private void SerializeInternal(AdminInfo model, IDictionary<string, object> result) { result.Add("adminid", model.AdminID); result.Add("adminname", model.AdminName); result.Add("password", model.Password); result.Add("state", model.State); result.Add("isdeleted", model.IsDeleted); result.Add("sort", model.Sort); }
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text.Trim().Length > 0 && TextBox2.Text.Trim().Length > 0) { AdminInfo ad = new AdminInfo(); if (ad.admin_login(TextBox1.Text.ToString(), TextBox2.Text.ToString())) { Label1.Text = "Login Successfully"; Session["Username"] = TextBox1.Text; ; Response.Redirect("routes.aspx"); } else { Label1.Text = "Wrong Username / Password"; TextBox1.Text = ""; TextBox2.Text = ""; } } else Label1.Text = "Enter all the fields"; }
/// <summary> /// 更新管理员信息 /// </summary> /// <param name="adminInfo"></param> /// <returns></returns> public int UpdateAdmin(AdminInfo adminInfo) { int result = -1; if (null == adminInfo) { return result; } try { parms[0].Value = adminInfo.ID; parms[1].Value = adminInfo.AdminName; parms[2].Value = adminInfo.AdminPassword; result = DBUtility.MySqlHelper.ExecuteNonQuery(DBUtility.MySqlHelper.ConnectionString, CommandType.Text, Admin.SQL_UPDATE_ADMIN, parms); } catch (MySqlException se) { Console.WriteLine(se.Message); } return result; }
/// <summary> /// 根据名称得到管理员信息 /// </summary> /// <param name="adminName"></param> /// <returns></returns> public AdminInfo GetAdminByName(string adminName) { AdminInfo admin=null; try { MySqlParameter parm = new MySqlParameter(PARM_ADMIN_NAME,MySqlDbType.VarChar,16); parm.Value = adminName; using (MySqlDataReader rdr = DBUtility.MySqlHelper.ExecuteReader(DBUtility.MySqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_ADMIN_BY_NAME, parm)) { if (rdr.Read()) { admin = new AdminInfo(rdr.GetString(1), rdr.GetString(2)); } else admin = new AdminInfo(); } } catch (MySqlException se) { Console.WriteLine(se.Message); } return admin; }
protected void btnLogin_Click(object sender, EventArgs e) { Database db = new Database(); db.AddParameter("@uname", txtUserName.Text); db.AddParameter("@password", txtPassword.Text); System.Data.DataTable dt = db.ExecuteDataTable("Select * from AdminUsers where (username=@uname or email=@uname) and (password=@password)"); if (dt.Rows.Count != 0) { if(cbRememberMe.Checked) { HttpCookie c=new HttpCookie("ASUserName", txtUserName.Text); c.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(c); c = new HttpCookie("ASPassword", txtPassword.Text); c.Expires = DateTime.Now.AddYears(1); Response.Cookies.Add(c); } else { HttpCookie c = new HttpCookie("ASUserName", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); c = new HttpCookie("ASPassword", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); } if(cbKeepMeLogin.Checked) { HttpCookie c = new HttpCookie("ASCMSKeepOnline", dt.Rows[0]["id"].ToString()); c.Expires = DateTime.Now.AddDays(20); Response.Cookies.Add(c); } else { HttpCookie c = new HttpCookie("ASCMSKeepOnline", ""); c.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(c); } AdminInfo admininfo = new AdminInfo(dt.Rows[0]["id"].ToString(), dt.Rows[0]["name"].ToString(), dt.Rows[0]["username"].ToString(), dt.Rows[0]["password"].ToString(), dt.Rows[0]["email"].ToString(), dt.Rows[0]["permition"].ToString()); Session["AdminInfo"] = admininfo; if (Request.QueryString["url"] == null) { Response.Redirect("default.aspx"); } else { Response.Redirect(Request.QueryString["url"]); } } else { ErrorDiv.Visible = true; sp1.Visible = true; lblError.Text = "<i class=\"fa fa-exclamation-triangle fcRed\"></i> خطا في بيانات الدخول الرجاء التاكد من اسم المستخدم و كلمة المرور "; } }
/// <summary> /// 获得实体 /// </summary> /// <param name="keyValue">编号</param> /// <returns>AdminInfo</returns> public AdminInfo Get(int keyValue) { AdminInfo model = null; using (DbCommand cmd = db.GetStoredProcCommand("SP_GetRecord")) { db.AddInParameter(cmd, "@TableName", DbType.String, "Admin"); db.AddInParameter(cmd, "@KeyName", DbType.String, "AdminID"); db.AddInParameter(cmd, "@KeyValue", DbType.Int32, keyValue); using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0]) { if (dt.Rows.Count > 0) { model = new AdminInfo(); model.LoadFromDataRow(dt.Rows[0]); } } return model; } }
/// <summary> /// 根据分页获得数据列表 /// </summary> /// <param name="TbFields">返回字段</param> /// <param name="strWhere">查询条件</param> /// <param name="OrderField">排序字段</param> /// <param name="PageIndex">页码</param> /// <param name="PageSize">页尺寸</param> /// <param name="TotalCount">返回总记录数</param> /// <returns>IList<AdminInfo></returns> public IList<AdminInfo> Find(string tbFields, string strWhere, string orderField, int pageIndex, int pageSize, out int totalCount) { IList<AdminInfo> list = new List<AdminInfo>(); using (DbCommand cmd = db.GetStoredProcCommand("SP_SqlPagenation")) { db.AddInParameter(cmd, "@TbName", DbType.String, "Admin"); db.AddInParameter(cmd, "@TbFields", DbType.String, tbFields); db.AddInParameter(cmd, "@StrWhere", DbType.String, strWhere); db.AddInParameter(cmd, "@OrderField", DbType.String, orderField); db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageIndex); db.AddInParameter(cmd, "@PageSize", DbType.Int32, pageSize); db.AddOutParameter(cmd, "@Total", DbType.Int32, int.MaxValue); using (DataTable dt = db.ExecuteDataSet(cmd).Tables[0]) { if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { AdminInfo model = new AdminInfo(); model.LoadFromDataRow(dr); list.Add(model); } } } totalCount = (int)db.GetParameterValue(cmd, "@Total"); return list; } }
protected void setUsername() { aInfo = (AdminInfo)Session["_di09ADM"]; ((Label)Master.FindControl("lblUserName")).Text = aInfo.UserName; }
public object UpdateAdmin(AdminInfo adminInfo, List<RegionInfo> manageRegionList, List<RegionInfo> regionList) { AdminBLL adminBLL = new AdminBLL(); return adminBLL.UpdateAdminInfo(adminInfo, manageRegionList, regionList); }
public int UpdateAdmin(AdminInfo adminInfo) { return dal.UpdateAdmin(adminInfo); }
public users CheckLogin(string check) { try { if (UName != string.Empty && PWord != string.Empty) { if (check == "admin") { using (SqlCommand cmd = new SqlCommand("CheckLogin")) { cmd.Parameters.Add("@para", SqlDbType.VarChar).Value = "CHECKADMIN"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = UName; cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = PWord; DataTable dTable = getData(cmd); if (dTable.Rows.Count > 0) { if (Convert.ToBoolean(dTable.Rows[0]["IS_USER"])) { aInfo = new AdminInfo(); aInfo.UserName = dTable.Rows[0]["user_name"].ToString(); ProfilePage = "~/admin/home.aspx"; return users.Admin; } else { return users.Anonymous; } } else { return users.Anonymous; } } } else { using (SqlCommand cmd = new SqlCommand("CheckLogin")) { cmd.Parameters.Add("@para", SqlDbType.VarChar).Value = "CHECKUSER"; cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = UName; cmd.Parameters.Add("@password", SqlDbType.VarChar).Value = PWord; cmd.Parameters.Add("@online", SqlDbType.VarChar).Value = PWord; DataTable dTable = getData(cmd); if (dTable.Rows.Count > 0) { if (Convert.ToBoolean(dTable.Rows[0]["IS_USER"])) { uInfo = new userInfo(); uInfo.UserId = Convert.ToInt64(dTable.Rows[0]["user_id"]); string fName = dTable.Rows[0]["fname"].ToString(); string lName = dTable.Rows[0]["lname"].ToString(); uInfo.Email = dTable.Rows[0]["email"].ToString(); //if (fName == string.Empty) //{ // uInfo.UserName = string.Format("{0} {1}", fName, lName); //} //else //{ // uInfo.UserName = uInfo.UserName; //} uInfo.UserName = getUserName(fName, lName, uInfo.Email); uInfo.About = dTable.Rows[0]["about"].ToString(); ProfilePage = "~/home.aspx"; return users.User; } else { return users.Anonymous; } } else { return users.Anonymous; } } } } else { return users.Anonymous; } } catch (Exception ex) { return users.Anonymous; } }