public void OnGet() { Site = _siteService.GetModelAsync(m => m.Guid == "78756a6c-50c8-47a5-b898-5d6d24a20327").Result.data; var adminGuid = User.Identities.First(u => u.IsAuthenticated).FindFirst(ClaimTypes.Sid).Value; Admin = _adminService.GetModelAsync(m => m.Guid == adminGuid).Result.data; }
public object Add(SysAdmin SysAdmin, List <string> PId) { //验证是否重复 SysAdmin Old = Entity.SysAdmin.FirstOrDefault(n => n.UserName == SysAdmin.UserName); if (Old != null) { ViewBag.ErrorMsg = "“登录帐户”已存在,请重新输入!"; return(View("Error")); } string Str = string.Empty; if (PId != null) { foreach (var p in PId) { if (p != string.Empty) { Str += "," + p; } } Str += ","; } SysAdmin.PowerID = Str; SysAdmin.AgentId = BasicAgent.Id; SysAdmin.LoginTimes = 0; SysAdmin.AddTime = DateTime.Now; SysAdmin.PassWord = SysAdmin.PassWord.GetAdminMD5(); //Lin 20160318 升级成多级代理商模式,去掉 SysAdmin.PayGet = 0;//SysAdmin.PayGet / 100; Entity.SysAdmin.AddObject(SysAdmin); Entity.SaveChanges(); BaseRedirect(); return(true); }
public SysAdmin Login(SysAdmin obj) { string sql = "select adminName from Sys_Admin where adminName= '{0}' and adminPwd = '{1}'"; sql = string.Format(sql, obj.adminName, obj.adminPwd); SqlDataReader dr = SQLHelper.GetReader(sql); try { if (dr.Read()) { obj.adminName = dr["adminName"].ToString(); dr.Close(); } else { obj = null; } } catch (Exception ex) { throw new Exception("应用程序数据库连接出现问题" + ex.Message); } return(obj); }
public void Check(string fieldId, string fieldValue, string extraData) { switch (extraData) { case "SysAdmin": //管理员登录帐户 SysAdmin SysAdmin = Entity.SysAdmin.FirstOrDefault(n => n.UserName == fieldValue); if (SysAdmin == null) { Response.Write("[\"UserName\",true]"); } else { Response.Write("[\"UserName\",false]"); } break; case "Users": //会员登录帐户 Users Users = Entity.Users.FirstOrDefault(n => n.UserName == fieldValue); if (Users == null) { Response.Write("[\"UName\",true]"); } else { Response.Write("[\"UName\",false]"); } break; } }
private void btnLogin_Click(object sender, EventArgs e) { //选中匿名登录,直接匿名身份登录,否则,判断用户名和密码是否正确 if (this.checkBox1.Checked == false) { #region 数据验证 if (this.txtLoginId.Text.Trim().Length == 0) { MessageBox.Show("请填写用户名!", "登录提示"); this.txtLoginId.Focus(); return; } if (!DataValidate.IsInteger(this.txtLoginId.Text.Trim())) { MessageBox.Show("用户名必须为正整数!", "登录提示"); this.txtLoginId.Focus(); return; } if (this.txtLoginPwd.Text.Trim().Length == 0) { MessageBox.Show("请填写密码!", "登录提示"); this.txtLoginPwd.Focus(); return; } #endregion //封装对象 SysAdmin objAdmin = new SysAdmin() { LoginId = Convert.ToInt32(this.txtLoginId.Text.Trim()), LoginPwd = this.txtLoginPwd.Text.Trim() }; try { //调用登陆数据库方法,进行账号验证 objAdmin = objAdminService.AdminLogin(objAdmin); if (objAdmin == null) { MessageBox.Show("用户名或密码不正确!", "登录提示"); return; } else { this.DialogResult = DialogResult.OK; this.Close(); } } catch (Exception ex) { MessageBox.Show("登陆异常,原因:" + ex.Message, "登录提示"); return; } } else { this.DialogResult = DialogResult.OK; } }
public SysAdmin GetAdmin() { SysAdmin user = null; string Str = System.Web.HttpContext.Current.Request.Cookies.GetAgent(); if (Str.IsNullOrEmpty()) { return(user); } string neiw = System.Configuration.ConfigurationManager.AppSettings["key"]; string[] UArr = LokFuEncode.LokFuAuthcodeDecode(Str, neiw).Split('|'); if (UArr.Length == 3) { int Id = Int32.Parse(UArr[0]); string UName = UArr[1]; string DTStr = UArr[2]; user = Entity.SysAdmin.Where(n => n.UserName == UName && n.Id == Id).FirstOrDefault(); if (user != null) { DateTime now = (DateTime)user.LastTime; if (DTStr == now.ToString("yyyy-MM-dd HH:mm")) { return(user); } else { user = null; } } } return(user); }
private bool CheckLogin(SysAdmin admin) { //从数据库中验证登录信息... return(true);//将来自己添加业务逻辑,登录账号不对,则返回false }
/// <summary> /// Creating experiment tree from experiment directory :) /// </summary> /// <param name="rootPath">Absolute path to the root experiment folder</param> /// <param name="selectedPath">Relative (including root) path to the selected experiment</param> /// <param name="loadedPath">Relative (including root) path to the loaded experiment</param> public static Experiment Load(string rootPath, string selectedPath, string loadedPath) { var exp = new Experiment(); exp.Path = rootPath; var expDataFileName = Directory.GetFiles(rootPath, "*" + ExperimentData.EXPERIMENT_DATA_POSTFIX).FirstOrDefault(); if (!string.IsNullOrWhiteSpace(expDataFileName)) { exp.Data = ExperimentData.Load(expDataFileName); } exp.Number = SysAdmin.ExtractExperimentNumberFromPath(rootPath); string selectedRoot = SysAdmin.GetRootDirectory(selectedPath); exp.IsOpen = selectedRoot.EndsWith(string.Format(@"#{0}\", exp.Number)); string loadedRoot = SysAdmin.GetRootDirectory(loadedPath); exp.IsLoaded = loadedRoot.EndsWith(string.Format(@"#{0}\", exp.Number)); string s1 = (selectedPath.Contains(selectedRoot) && !string.IsNullOrWhiteSpace(selectedRoot)) ? selectedPath.Replace(selectedRoot, "") : string.Empty; string s2 = (loadedPath.Contains(loadedRoot) && !string.IsNullOrWhiteSpace(loadedRoot)) ? loadedPath.Replace(loadedRoot, "") : string.Empty; exp.BuildTree(rootPath, s1, s2); return(exp); }
/// <summary> /// 是否存在用户 /// </summary> /// <returns></returns> public Model.SysAdmin isExits(SysAdmin model) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AdminName, LoginId, LoginPwd, roleID from t_Admin"); strSql.Append(" where LoginId=@user"); strSql.Append(" and LoginPwd=@pwd"); SqlParameter[] parameter = { new SqlParameter("@user", SqlDbType.VarChar, 50), new SqlParameter("@pwd", SqlDbType.NVarChar, 50) }; parameter[0].Value = model.LoginId; parameter[1].Value = model.LoginPwd; Model.SysAdmin model1 = new SysAdmin(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameter); if (ds.Tables[0].Rows.Count > 0) { model.LoginId = parameter[0].Value.ToString(); model.LoginPwd = parameter[1].Value.ToString(); model.roleID = Convert.ToInt32(ds.Tables[0].Rows[0][3]); model.AdminName = ds.Tables[0].Rows[0][0].ToString(); } else { model = null; } return(model); }
/// <summary> /// Creates a new experiment folder, /// copy files to it from model dir. /// and marks it as loaded and selected in the project file /// </summary> public void CreateExperiment(Experiment.ExperimentData expData) { // get max experiment number int max = SysAdmin.GetMaxDirNumber(manager.GetRootExperimentPath(modelName)); ++max; // create new experiment folder string s = manager.GetLoadedExperimentAbsolutePath(modelName); string experimentPath = string.Format("{0}#{1}", s, max); if (max == 0) { experimentPath = string.Format("{0}{1}#{2}", s, modelName, max); } var di = Directory.CreateDirectory(string.Format("{0}\\{1}{2}", experimentPath, modelName, Model.MODEL_DIR_POSTFIX)); // copy main model folder to the new model folder s = manager.GetModelDir(modelName); SysAdmin.CopyDirectory(s, di.FullName); // create experiment data file in the experiment folder s = string.Format("{0}\\{1}{2}", experimentPath, modelName, Experiment.ExperimentData.EXPERIMENT_DATA_POSTFIX); expData.Save(s); // mark experiment as loaded manager.MarkExperimentAsLoaded(modelName, experimentPath); manager.MarkExperimentAsSelected(modelName, experimentPath); }
/// <summary> /// 在本地以序列化方式保存登录信息 /// </summary> /// <param name="sysAdmin"></param> public void SaveLoginInfo(SysAdmin sysAdmin) { FileStream fs = new FileStream("sysAdmins.sys", FileMode.Create); BinaryFormatter bf = new BinaryFormatter(); bf.Serialize(fs, sysAdmin); fs.Close(); }
private void btnModifyPwd_Click(object sender, EventArgs e) { //验证 if (this.txtPrimPwd.Text.Trim().Length == 0) { MessageBox.Show("请输入原密码!", "提示信息"); this.txtPrimPwd.Focus(); return; } //判断密码是否一致 if (this.txtPrimPwd.Text.Trim() != Program.objCurrentAdmin.LoginPwd) { MessageBox.Show("请输入正确的原密码", "提示信息"); this.txtPrimPwd.Focus(); this.txtPrimPwd.SelectAll(); return; } //判断新密码的长度 if (this.txtNewPwd.Text.Trim().Length < 6) { MessageBox.Show("新密码长度不能少于6位", "提示信息"); this.txtNewPwd.Focus(); this.txtNewPwd.SelectAll(); return; } //判断两次输入是否一致 if (this.txtRefirmPwd.Text.Trim().Length == 0) { MessageBox.Show("请再次输入新密码", "提示信息"); this.txtRefirmPwd.Focus(); return; } if (this.txtRefirmPwd.Text.Trim() != this.txtNewPwd.Text.Trim()) { MessageBox.Show("两次输入密码不一致", "提示信息"); this.txtRefirmPwd.Focus(); this.txtRefirmPwd.SelectAll(); return; } try { SysAdmin objAdmin = new SysAdmin() { LoginId = Program.objCurrentAdmin.LoginId, LoginPwd = this.txtNewPwd.Text.Trim() }; if (new SysAdminService().ModifyPwd(objAdmin) == 1) { MessageBox.Show("密码修改成功!", "提示信息"); Program.objCurrentAdmin.LoginPwd = this.txtNewPwd.Text.Trim(); this.Close(); } } catch (Exception) { throw; } }
/// <summary> /// 从本地读取登录信息 /// </summary> /// <returns></returns> public SysAdmin ReadLoginInfo() { FileStream fs = new FileStream("sysAdmins.sys", FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); SysAdmin sysAmin = (SysAdmin)bf.Deserialize(fs); fs.Close(); return(sysAmin); }
/// <summary> /// 用户登录 /// </summary> /// <param name="sysadmin"></param> /// <returns></returns> public SysAdmin Login(SysAdmin sysadmin) { using (IDbConnection coon = SqlHelper.GetConnection()) { string sql = "select AdminId, AdminName, LoginPwd, StatusId, RoleId from SysAdmin where AdminId=@AdminId and LoginPwd=@LoginPwd"; return(coon.QueryFirstOrDefault <SysAdmin>(sql, sysadmin)); } }
public SysAdmin Login(SysAdmin obj) { obj = new SysAdminDAL().Login(obj); if (obj != null) { HttpContext.Current.Session["CurrentAdmin"] = obj; } return(obj); }
private void BtnModify_Click(object sender, EventArgs e) { if (this.txtOldPwd.Text.Trim().Length == 0) { MessageBox.Show("请输入原密码", "提示信息"); this.txtOldPwd.Focus(); return; } if (this.txtNewPwd.Text.Trim().Length == 0) { MessageBox.Show("请输入新密码", "提示信息"); this.txtNewPwd.Focus(); return; } if (this.txtNewPwdConfirm.Text.Trim().Length == 0) { MessageBox.Show("请确认密码", "提示信息"); this.txtNewPwdConfirm.Focus(); return; } if (this.txtNewPwd.Text.Trim() != this.txtNewPwdConfirm.Text.Trim()) { MessageBox.Show("两次输入的新密码不一致", "提示信息"); return; } if (this.txtOldPwd.Text.Trim() != Program.currentAdmin.LoginPwd) { MessageBox.Show("原密码不正确"); this.txtOldPwd.SelectAll(); this.txtOldPwd.Focus(); return; } SysAdmin objAdmin = new SysAdmin() { AdminId = Program.currentAdmin.AdminId, LoginPwd = this.txtNewPwd.Text.Trim() }; try { int result = objAdminManager.ModifyPwd(objAdmin); if (result == 1) { Program.currentAdmin.LoginPwd = objAdmin.LoginPwd; MessageBox.Show("修改成功", "提示信息"); this.Close(); } else { MessageBox.Show("未能正确修改,请检查信息是否存在", "修改失败"); } } catch (Exception ex) { MessageBox.Show("发生异常:" + ex.Message, "修改失败"); } }
/// <summary> /// 更新管理员登录时间 /// </summary> /// <param name="admin">管理员对象</param> public void UpdateLoginTime(SysAdmin admin) { if (admin != null) { admin.LastLoginTime = DateTime.Now; db.Entry(admin).State = EntityState.Modified; db.SaveChanges(); } }
public SysAdmin Login(SysAdmin obj) { obj = new SysAdminDAL().Login(obj); if (obj != null) { //FormsAuthentication.SetAuthCookie(obj.adminName, true); } return(obj); }
public async Task <ActionResult> DeleteConfirmed(int id) { SysAdmin sysAdmin = await db.SysAdmins.FindAsync(id); db.SysAdmins.Remove(sysAdmin); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
private void btnAdd_Click(object sender, EventArgs e) { #region 验证数据 if (this.txtLoginId.Text.Trim().Length == 0) { MessageBox.Show("登录名不能为空!"); this.txtLoginId.Focus(); return; } string id = this.txtLoginId.Text.Trim(); string Sid = id.Substring(0, 2); if (!Sid.Equals("ZH")) { MessageBox.Show("请输入以'ZH'开头的六位登录名,如:ZH0000"); this.txtLoginId.Focus(); return; } if (objAdminService.LoginIdIsExited(this.txtLoginId.Text.Trim())) { MessageBox.Show("登录名已经存在,请重新输入!"); this.txtLoginId.Focus(); return; } if (this.txtLoginPwd.Text.Trim().Length == 0) { MessageBox.Show("登录密码不能为空!"); this.txtLoginId.Focus(); return; } #endregion #region 封装管理员用户对象 SysAdmin objAdmins = new SysAdmin() { LoginId = this.txtLoginId.Text.Trim(), LoginPwd = this.txtLoginPwd.Text.Trim(), AdminName = this.txtAdminName.Text.Trim() }; #endregion #region 调用后台方法添加对象 try { if (1 == objAdminService.AddAdmins(objAdmins)) { MessageBox.Show("管理员用户添加成功!"); this.txtLoginId.Text = ""; this.txtLoginPwd.Text = ""; this.txtAdminName.Text = ""; } ; } catch (Exception ex) { MessageBox.Show(ex.Message); } #endregion }
public int ModifyPwd(SysAdmin objAdmin) { string sql = "update Admins set LoginPwd = @LoginPwd where LoginId = @LoginId"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@LoginPwd", objAdmin.LoginPwd), new SqlParameter("@LoginId", objAdmin.LoginId) }; return(SQLHelper.Update(sql, param, false)); }
/// <summary> /// Admin用户登录 /// </summary> /// <param name="objAdmin"></param> /// <returns></returns> public SysAdmin AdminLogin(SysAdmin objAdmin) { objAdmin = sysAdminService.GetAdminName(objAdmin); if (objAdmin != null) { //保存登录信息 HttpContext.Current.Session["currentAdmin"] = objAdmin; } return(objAdmin); }
/// <summary> /// 根据登录账号和密码登录 /// </summary> /// <param name="objAdmin"></param> /// <returns></returns> public SysAdmin AdminLogin(SysAdmin objAdmin) { objAdmin = objAdminService.AdminLogin(objAdmin); if (objAdmin != null) { //将登录对象保存Session HttpContext.Current.Session["CurrentAdmin"] = objAdmin; } return(objAdmin); }
public static int ChangePwd(SysAdmin user, string newPwd) { string sql = "update Admins set LoginPwd = @newpwd where LoginId=@LoginId"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("newpwd", newPwd), new SqlParameter("LoginId", user.LoginId) }; return(SQLServerHelper.update(sql, param, false)); }
public void InfoSave(SysAdmin SysAdmin, string PassWord1) { SysAdmin baseSysAdmin = Entity.SysAdmin.FirstOrDefault(n => n.Id == AdminUser.Id); SysAdmin.PassWord = baseSysAdmin.PassWord; //保证密码不被修改 SysAdmin.PowerID = baseSysAdmin.PowerID; //保证权限不被自己修改 baseSysAdmin = Request.ConvertRequestToModel <SysAdmin>(baseSysAdmin, SysAdmin); Entity.SaveChanges(); BaseRedirect(); }
public ActionResult Edit(SysAgent SysAgent) { if (SysAgent.Id != 0) { SysAgent = Entity.SysAgent.FirstOrDefault(n => n.Id == SysAgent.Id); } if (SysAgent == null) { ViewBag.ErrorMsg = AgentLanguage.Empty; return(View("Error")); } if (!SysAgent.Id.IsNullOrEmpty()) { if (!IsBelongToAgent(SysAgent.Id)) { ViewBag.ErrorMsg = AgentLanguage.Surmount; return(View("Error")); } } ViewBag.SysAgent = SysAgent; if (Request.UrlReferrer != null) { Session["Url"] = Request.UrlReferrer.ToString(); } SysAdmin sysAdmin = null; if (SysAgent.AdminId != 0) { sysAdmin = Entity.SysAdmin.FirstOrNew(n => n.Id == SysAgent.AdminId); } ViewBag.SysAdmin = sysAdmin; var Contract = new List <Attach>(); var Certificate = new List <Attach>(); var IDCard_Front = new Attach(); var IDCard_Hand = new Attach(); var IDCard_Reverse = new Attach(); if (SysAgent.Id != 0) { var attachs = Entity.Attach.Where(o => o.AgentId == SysAgent.Id && o.State == 1).ToList(); Contract = attachs.Where(o => o.AType == (byte)AttachType.Contract).ToList(); Certificate = attachs.Where(o => o.AType == (byte)AttachType.Certificate).ToList(); IDCard_Front = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Front); IDCard_Hand = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Hand); IDCard_Reverse = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Reverse); } this.ViewBag.Contract = Contract; this.ViewBag.Certificate = Certificate; this.ViewBag.IDCard_Front = IDCard_Front; this.ViewBag.IDCard_Hand = IDCard_Hand; this.ViewBag.IDCard_Reverse = IDCard_Reverse; ViewBag.MySysAgentMoney = this.checkPower("MySysAgent", "MoneySave"); return(View()); }
public JsonResult GetCode(string Tel, byte CType) { if (Tel.IsNullOrEmpty()) { return(Json(new { code = 1, msg = "手机号不能为空" })); } if (CType != 5) { return(Json(new { code = 1, msg = " 非法操作" })); } //验证是否重复 SysAdmin Old = Entity.SysAdmin.FirstOrDefault(n => n.UserName == Tel); if (Old != null) { return(Json(new { code = 1, msg = "“联系手机号”已在系统中存在,无法开通管理员!" })); } if (Entity.UserBlackList.FirstOrDefault(UBL => UBL.CardNumber == Tel && UBL.State == 1) != null) { return(Json(new { code = 1, msg = "暂不支持您的手机号入网!" })); } SysSet ss = new SysSet(); ss.SMSEnd = BasicSet.SMSEnd; ss.SMSActives = BasicSet.SMSActives; DateTime Today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //失效之前获取验证码 IList <SMSCode> List = Entity.SMSCode.Where(n => n.UId == BasicAgent.Id && n.Mobile == Tel && n.CType == CType && n.State == 1).ToList(); foreach (var p in List) { p.State = 0; } Entity.SaveChanges(); //生成验证码 string Code = Utils.RandomSMSCode(6); SMSCode SSC = new SMSCode(); SSC.CType = CType; SSC.UId = BasicAgent.Id; SSC.Mobile = Tel; SSC.Code = Code; SSC.AddTime = DateTime.Now; SSC.State = 1; Entity.SMSCode.AddObject(SSC); Entity.SaveChanges(); var topAgent = BasicAgent.GetTopAgent(this.Entity); //发送验证码 SSC.SendSMS(ss, topAgent, Entity); return(Json(new { code = 2, msg = "ok" })); }
public void Delete(SysAdmin SysAdmin, string InfoList, int?IsDel) { if (string.IsNullOrEmpty(InfoList)) { InfoList = SysAdmin.Id.ToString(); } int Ret = Entity.MoveToDeleteEntity <SysAdmin>(InfoList, IsDel, AdminUser.UserName); Entity.SaveChanges(); Response.Write(Ret); }
public void ChangeStatus(SysAdmin SysAdmin, string InfoList, string Clomn, string Value) { if (string.IsNullOrEmpty(InfoList)) { InfoList = SysAdmin.Id.ToString(); } int Ret = Entity.ChangeEntity <SysAdmin>(InfoList, Clomn, Value); Entity.SaveChanges(); Response.Write(Ret); }
public async Task <ActionResult> Edit([Bind(Include = "Id,AdminName,Password")] SysAdmin sysAdmin) { if (ModelState.IsValid) { db.Entry(sysAdmin).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(sysAdmin)); }