//添加 protected void btnOK_Click(object sender, EventArgs e) { //@ApplyUser, @Title, @BeginDate, @EndDate, @Reason, @ApproveUser, @ApplyDate, @ApproveDate, @Status, @Result, @Remark Model.Approve u = new Model.Approve(); Model.UserInfo user = (Model.UserInfo)Session["User"]; //将登陆时获取的用户信息Session重新调用 u.ApplyUser = user.UserID; //申请人ID u.Title = txtTitle.Text; //标题 u.BeginDate = Convert.ToDateTime(txtBeginTime.Text + " " + ddlBegin.Text); //开始时间 u.EndDate = Convert.ToDateTime(txtEndTime.Text + " " + ddlEnd.Text); //结束时间 u.Reason = txtLeaveReason.Text; //请假原因 u.ApplyDate = DateTime.Now; //申请时间 u.Status = 0; //请假单状态 DateTime beginTime = Convert.ToDateTime(u.BeginDate); DateTime endTime = Convert.ToDateTime(u.EndDate); if (beginTime > endTime) //判断起始时间,最终时间 输入的时候合理 { this.ClientScript.RegisterStartupScript(GetType(), "", "alert('请假的起始时间不能大于结束时间!');", true); } else { //将以上数据赋值 if (BLL.LeaveApplyBll.InsertAttendInfo(u)) { //添加成功 this.ClientScript.RegisterStartupScript(GetType(), "", "alert('恭喜您,添加成功!');window.parent.location='LeaveApply.aspx';", true); } //添加失败 else { this.ClientScript.RegisterStartupScript(GetType(), "", "alert('很遗憾,添加失败!');", true); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id; if (int.TryParse(context.Request["txtEditUserID"], out id)) { Model.UserInfo userInfo = new Model.UserInfo(); userInfo.ID = id; userInfo.UserName = context.Request["txtEditUserName"]; userInfo.UserPass = context.Request["txtEditUserPass"]; userInfo.Email = context.Request["txtEditEmail"]; BLL.UserInfoService userInfoService = new BLL.UserInfoService(); if (userInfoService.Update(userInfo)) { context.Response.Write("ok"); } else { context.Response.Write("no"); } } else { context.Response.Write("no"); } }
public IList <Model.UserInfo> GetGroupNTIDList(string prefixText) { IList <Model.UserInfo> iList = new List <Model.UserInfo>(); string cmdText = @"select top 10 * from ( select userid,displayname,mail,0 as isgroup from WinADUser where status=1 union all select distinct RoleName,RoleName,RoleName,1 as isgroup from RoleUser ru inner join Role r on ru.RoleId=r.RoleId) a where (mail like @prefix or displayName like @prefix) order by isgroup desc"; SqlParameter para = new SqlParameter("@prefix", prefixText + "%"); using (SqlDataReader reader = SqlHelper.ExecuteReader(cmdText, para)) { while (reader.Read()) { Model.UserInfo user = new Model.UserInfo() { UID = reader["userid"].ToString(), DisplayName = reader["displayname"].ToString(), Email = reader["mail"].ToString(), IsGroup = int.Parse(reader["isgroup"].ToString()) }; iList.Add(user); } } return(iList); }
public List <Model.UserInfo> GetAdUserListByRoleName(string roleName) { List <Model.UserInfo> list = new List <Model.UserInfo>(); string sql = @"select ru.uid,w.displayName,w.mail from RoleUser ru inner join winaduser w on ru.uid=w.userid where ru.status=1 and ru.RoleID=(select RoleID from Role where RoleName=@roleName)" ; SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("@roleName", roleName) }; using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, parameters)) { while (reader.Read()) { Model.UserInfo u = new Model.UserInfo { UID = reader["uid"].ToString(), DisplayName = reader["displayName"].ToString(), Email = reader["mail"].ToString() }; list.Add(u); } } return(list); }
public async Task <List <Email> > GetPop3EmailHeaders(Model.UserInfo userInfo) { Pop3 pop3 = await ConnectPop3(userInfo); try { if (pop3 != null) { List <string> uids = pop3.GetAll(); MailBuilder builder = new MailBuilder(); foreach (string uid in uids) { var headers = pop3.GetHeadersByUID(uid); IMail mail = builder.CreateFromEml(headers); Email email = new Email { Uid = uid, Date = mail.Date ?? DateTime.MinValue, Subject = mail.Subject, From = string.Join(",", mail.From?.Select(s => s.Address)), }; emailHeaderList.Add(email); } } return(emailHeaderList); } finally { serverConnection.Add(pop3); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Clear(); BLL.UserInfoExt bllUserInfo = new BLL.UserInfoExt(); Model.UserInfo modelUserInfo = new Model.UserInfo(); string strUserName = context.Request["UName"]; string strEmail = context.Request["UEmail"]; string strPwd = context.Request["UPwd"]; Guid roles = new Guid("7e6573be-d49f-48f0-a9cd-1fe8d64a84a6"); //注册时写死为普通会员 modelUserInfo.RoleID = roles; modelUserInfo.UserName = strUserName; modelUserInfo.Email = strEmail; modelUserInfo.Password = lv_Common.DEncrypt.DEncrypt.Encrypt(strPwd); modelUserInfo.LastLoginDate = DateTime.Now; modelUserInfo.CreateDate = DateTime.Now; modelUserInfo.ApprovedState = (int)BLL.TypeEnum.UserApprovedState.已审核; //注册就通过审核,否则无法跳转到用户后台 bllUserInfo.Add(modelUserInfo); BLL.MenberValidate.RegisterTicket(strUserName); context.Response.Write("yes"); context.Response.End(); }
//删除===>通过选取复选框 #region protected void btnDel_Click(object sender, EventArgs e) { int s = 0; for (int i = 0; i <= gvUserInfo.Rows.Count - 1; i++) { CheckBox cbox = (CheckBox)gvUserInfo.Rows[i].Cells[1].FindControl("CheckBox1"); if (cbox.Checked == true) { s++; Model.UserInfo u = new Model.UserInfo(); u.UserID = Convert.ToString(gvUserInfo.DataKeys[i].Value); BLL.UserManageBll.DelUserInfo(u); } } if (s == 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请选择要删除的用户!')", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "alert('已删除" + s + "条数据')", true); BindUserInfo(); //刷新 } }
// create five different connection to server public async Task ServerConnections(Model.UserInfo userInfo) { // List To store server connections serverConnection = new List <Pop3>(); // atleast one connection required for Headers Pop3 pop3 = await ConnectPop3(userInfo); serverConnection.Add(pop3); // Run the others connections await Task.Run(async() => { int numOfConnection = 5; int connFailure = 0; for (int i = 0; i < numOfConnection - 1; i++) { try { Pop3 imapconnections = await ConnectPop3(userInfo); serverConnection.Add(imapconnections); } catch (Exception) { connFailure++; break; } } }); }
protected void ibLogin_Click(object sender, ImageClickEventArgs e) { if (VaildateNull()) { Model.UserInfo u = BLL.UserInfo.UserLogin(txtID.Text, txtPassword.Text); if (u != null) { Session["User"] = u; if (u.UserType == 0) { Response.Redirect("MyAttendance.aspx"); } else if (u.UserType == 1) { Response.Redirect("AttendanceManage.aspx"); } else if (u.UserType == 2) { Response.Redirect("AttendanceSetting.aspx"); } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('用户名或密码有误,请重新填写!');", true); } } }
protected void save() { try { int id = int.Parse(hfuserid.Value); if (id <= 0) { Response.Write("<script>alert('无效的id');history.go(-1);</script>"); return; } Model.UserInfo info = BLL.UsersBLL.GetModel(id); if (info == null || info.UserID != id) { Response.Write("<script>alert('无效的id');history.go(-1);</script>"); return; } info.Email = txbEmail.Text.Trim(); info.DisplayName = txbDisplayName.Text.Trim(); int result = BLL.UsersBLL.Update(info); if (result > 0) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToString(), "alert('修改成功');location.href='companys.aspx';", true); } else { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToString(), "alert('修改失败');", true); } } catch (Exception exc) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), DateTime.Now.ToString(), "alert('提交失败" + exc.Message.Replace("'", "").Replace("\r", "").Replace("\n", "") + "');", true); } }
public ActionResult UserInfo(Model.UserAdditionalInfo usr) { if (Session[SessionKey.User] == null) { return(RedirectToAction("Login")); } if (ModelState.IsValid) { //save changes and commit to db Model.UserInfo susr = (Model.UserInfo)Session[SessionKey.User]; var old_usr = _uow.UserInfoService.Get(u => u.Id == susr.Id); if (old_usr == null || (old_usr.Id != susr.Id)) { return(RedirectToAction("Error", "Home")); } old_usr.TrueName = usr.TrueName == null ? "" : usr.TrueName; old_usr.IdentityCardNo = usr.IdentityCardNo == null ? "" : usr.IdentityCardNo; old_usr.Phone = usr.Phone == null ? "" : usr.Phone; old_usr.UpdateTime = DateTime.Now; _uow.Commit(); //susr = old_usr; Session[SessionKey.User] = old_usr; return(RedirectToAction("Summary")); } else { ModelState.AddModelError("", "Error 101"); } return(View()); }
/// <summary> /// Get User information from AD /// </summary> /// <param name="ntid">AD用户名</param> /// <returns>用户实例</returns> public static UserInfo GetADUserEntity(string ntid) { if (string.IsNullOrEmpty(ntid)) { throw new Exception("Searched user id cannot be null."); } DirectoryEntry entry = new DirectoryEntry(LDAP_PATH); DirectorySearcher searcher = new DirectorySearcher(entry); searcher.Filter = "(&(objectClass=user)(sAMAccountName=" + ntid + "))"; SearchResult searchResult = searcher.FindOne(); if (searchResult != null) { Model.UserInfo user = new Model.UserInfo(); user.UID = ntid; user.Department = GetADProperty(searchResult, "department"); user.DisplayName = GetADProperty(searchResult, "displayName"); user.Email = GetADProperty(searchResult, "mail"); user.Site = GetSiteCodeFromUserOUPath(searchResult.Path); return(user); } return(null); }
public ActionResult Put([FromBody] Model.UserInfo users) { try { var n = DAL.UserInfo.Instance.Update(users); if (n != 0) { return(Json(Result.Ok("修改成功"))); } else { return(Json(Result.Err("用户名不存在"))); } } catch (Exception ex) { if (ex.Message.ToLower().Contains("null")) { return(Json(Result.Err("密码,身份不能为空"))); } else { return(Json(Result.Err(ex.Message))); } } }
public ActionResult UserCheck([FromBody]Model.UserInfo users) { try { var result = DAL.UserInfo.Instance.GetModel(users.username); if (result == null) return Json(Result.Err("用户名错误")); else if (result.passWord == users.passWord) { if (result.type == "管理员") { result.passWord = "******"; return Json(Result.Ok("管理员登录成功",result)); } else return Json(Result.Err("只有管理员能够进入后台管理")); } else return Json(Result.Err("密码错误")); } catch (Exception esx) { return Json(Result.Err(ex.Message)); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { int year = 2015; int month = 11; for (int i = year - 3; i < year + 3; i++) { ddlYear.Items.Add(new ListItem(i.ToString(), i.ToString())); } ddlYear.SelectedValue = year.ToString(); for (int i = 1; i <= 12; i++) { ddlMonth.Items.Add(new ListItem(i.ToString(), i.ToString())); } ddlMonth.SelectedValue = month.ToString(); Model.UserInfo u = (Model.UserInfo)Session["User"]; if (u.UserType == 1) { ddlType.Visible = false; } else if (u.UserType == 2) { ddlType.Visible = false; } } }
// 添加用户页面 public ActionResult DeleteUser(long id) { if (Identity.LoginUserInfo.RoleID != 10) { return(Json(new { Message = "只有管理员才能编辑用户" })); } // 查询用户信息 Model.UserInfo userInfo = BLL.BackgroundUserBll.GetSingleUserInfo(id); if (userInfo == null) { return(Json(new { Message = "该用户不存在或已被删除!!" })); } if (BLL.BackgroundUserBll.DeleteSingleUserInfo(id)) { // 记录日志 string logTitle = "删除后台用户"; string logMsg = string.Format("删除用户信息:用户名【{0}】,角色【{1}】", userInfo.UserName, userInfo.RoleType == 10 ? "管理员" : "普通用户"); BLL.BackgroundUserBll_log.AddLog(logTitle, logMsg, Request.UserHostAddress); return(Json(new { Message = "OK" })); } else { return(Json(new { Message = "删除失败!" })); } }
public void ProcessRequest(HttpContext context) { string regName = context.Request["UName"]; string regPwd = context.Request["UPwd"]; string regEmail = context.Request["UEmail"]; UserInfoExt bllUserInfo = new UserInfoExt(); Guid roles = new Guid("7e6573be-d49f-48f0-a9cd-1fe8d64a84a6"); //注册时写死为普通会员 Model.UserInfo modelUserInfo = new Model.UserInfo(); modelUserInfo.RoleID = roles; modelUserInfo.UserName = regName; modelUserInfo.Email = regEmail; modelUserInfo.Password = lv_Common.DEncrypt.DEncrypt.Encrypt(regPwd); modelUserInfo.LastLoginDate = DateTime.Now; modelUserInfo.CreateDate = DateTime.Now; modelUserInfo.ApprovedState = (int)BLL.TypeEnum.UserApprovedState.已审核; //注册就通过审核,否则无法跳转到用户后台 bllUserInfo.Add(modelUserInfo); #region FormsAuthentication.SetAuthCookie(regName, true, FormsAuthentication.FormsCookiePath); FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(regName, true, 180);//3小时超时 string HashTicket = FormsAuthentication.Encrypt(Ticket); HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, HashTicket); context.Response.Cookies.Add(UserCookie); modelUserInfo.LastLoginDate = DateTime.Now; bllUserInfo.Update(modelUserInfo); context.Response.Write("yes"); #endregion }
// Connect to POP3 public async Task <Pop3> ConnectPop3(Model.UserInfo userInfo) { var serverconnTask = Task.Run(() => { Pop3 pop3 = new Pop3(); if (userInfo.EncryptionType == Model.Enum.EncryptionType.Unencrypted) { pop3.Connect(userInfo.Server, userInfo.Port); } else if (userInfo.EncryptionType == Model.Enum.EncryptionType.SSLTLS) { pop3.ConnectSSL(userInfo.Server, userInfo.Port); } else { pop3.Connect(userInfo.Server, userInfo.Port); pop3.StartTLS(); } pop3.UseBestLogin(userInfo.UserName, userInfo.Password); return(pop3); }); var completedTask = await Task.WhenAny(serverconnTask); if (completedTask == serverconnTask) { return(await serverconnTask); } else { throw new TimeoutException("server Connection timed out"); } }
public ActionResult genUserCheck([FromBody] Model.UserInfo users) { try { var result = DAL.UserInfo.Instance.GetModel(users.userName); if (result == null) { return(Json(Result.Err("用户名错误"))); } else if (result.passWord == users.passWord) { result.passWord = "******"; return(Json(Result.Ok("登录成功", result)) ); } else { return(Json(Result.Err("密码错误"))); } } catch (Exception ex) { return(Json(Result.Err(ex.Message))); } }
/// <summary> /// 添加用户 /// </summary> /// <returns></returns> public int UserAdd() { try { var guid = Guid.NewGuid().ToString("N"); Model.UserInfo user = new Model.UserInfo { UserId = guid, UserCode = "Dikeko1234566", UserNickName = "Dikeko111", UserPhone = "13212345678", UserPassWord = "******", WxOpenId = string.Empty, QqOpenId = string.Empty, AlipayOpenId = string.Empty, SianOpenId = string.Empty, Status = 0, CreateUserId = guid, CreateTime = DateTime.Now, UpdateUserId = guid, UpdateTime = DateTime.Now, Sort = 0 }; var result = db.Insert(user); return(result); } catch (Exception) { throw; } }
public void TestMethod2() { Model.UserInfo user = new Model.UserInfo { userName = "******", passWord = "******", type = "¹ÜÀíÔ±" }; Console.WriteLine(DAL.UserInfo.instance.Add(user)); Console.WriteLine(JsonConvert.SerializeObject(DAL.UserInfo.instance.GetAll())); user.qq = "104512708"; Console.WriteLine(DAL.UserInfo.instance.Update(user)); var model = DAL.UserInfo.instance.GetModel("Guest"); Console.WriteLine(JsonConvert.SerializeObject(model)); Console.WriteLine(DAL.UserInfo.instance.Delete("Guest")); var page = DAL.UserInfo.instance.GetPage(new Model.Page { pageIndex = 2, pageSize = 2 }); Console.WriteLine(JsonConvert.SerializeObject(page)); Console.WriteLine(DAL.UserInfo.instance.GetCount()); }
//修改个人信息 private void UpdatePersonInfo() { //判断两次密码是否相同==>1.当两次密码不相同的情况下 if (txtAgainPwd.Text != txtNewPwd.Text) { // this.ClientScript.RegisterStartupScript(GetType(), "", "alert('两次填写密码不相同');", true); } else { //2.当两次密码相同的情况下==》判断密码是否为空进行保存,为空密码还是原来的密码,否则修改了原密码==》 Model.UserInfo u = (Model.UserInfo)Session["user"]; //(1)密码不为空的情况下 if (!string.IsNullOrEmpty(txtAgainPwd.Text)) { u.Password = txtNewPwd.Text; u.Cellphone = txtCellPhone.Text; } else { //(2)密码为空的情况下 u.Cellphone = txtCellPhone.Text; } //修改成功 if (BLL.LoginBll.UpdateUserPwd(u)) { this.ClientScript.RegisterStartupScript(GetType(), "", "alert('恭喜您,修改成功!');window.parent.dialog.close();", true); } else { this.ClientScript.RegisterStartupScript(GetType(), "", "alert('很遗憾,修改失败!');", true); } } }
protected void Page_Load(object sender, EventArgs e) { var id = Convert.ToInt32(Request.QueryString["id"]); if (!IsPostBack) { var bll = new BLL.UserInfoBLL(); var userInfo = bll.GetEntityModel(id); if (userInfo != null) { UserDetail = userInfo; } } else { UserDetail = new Model.UserInfo { ID = id, UserName = Request.Form["txtName"], UserPass = Request.Form["txtPwd"], RegTime = Convert.ToDateTime(Request.Form["txtRegTime"]), Email = Request.Form["txtEmail"] }; var bll = new BLL.UserInfoBLL(); if (bll.UpdateEntityModel(UserDetail)) { Response.Redirect("index.aspx"); } } }
public Model.UserInfo SelectUser(string userName, string Password) //根据 ui 选择返回一个user { using (SqlConnection conn = new SqlConnection(DatabaseUtility.ConnString)) { //创建一个命令对象,并添加命令 SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = @"SELECT ID,UserName,Password FROM USERS WHERE UserName=@UserName AND Password=@Password"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@userName", userName)); cmd.Parameters.Add(new SqlParameter("@Password", Password)); conn.Open(); //打开数据链接 SqlDataReader reader = cmd.ExecuteReader(); Model.UserInfo user = null; //用于保存读取的数据 while (reader.Read()) //开始读取数据 { user = new Model.UserInfo(); user.ID = reader.GetInt32(0); user.UserName = reader.GetString(1); user.Password = reader.GetString(2); } return(user); } }
// GET: Message protected string GetUnreadMsgCountGroupByType() { Model.UserInfo userInfo = GetActiveUserInfo(); var userMessages = userMessageService.LoadEntities(u => u.UserId == userInfo.ID && u.IsRead == 0); var rst = from u in userMessages group new { u.Announcement.AnnounType, u.Announcement } by new { u.Announcement.AnnounType.Name, u.Announcement.AnnounType.Id, u.Announcement.AnnounTypeId } into g select new { g.Key.Name, g.Key.Id, Count = g.Count(p => p.Announcement.AnnounTypeId != null) }; int Sum = rst.Sum(a => a.Count); if (rst != null) { return(Common.SerializeHelper.SerializeToString(new { state = 0, msg = "消息获取成功", rst = rst, Sum = Sum })); } else { return(Common.SerializeHelper.SerializeToString(new { state = 1, msg = "消息获取失败" })); } }
public Model.Result Delete(Model.UserInfo user, int roleid) { using (TransactionScope ts = new TransactionScope()) { try { string sql = "declare @count int select @count = count(1) from UserInfo where RoleID = " + roleid; sql += "if(@count>0) begin select -1 end else begin delete from RoleInfo where RoleID =" + roleid + " select 1 end"; int ret = (int)DbHelper.SqlHelper.ExecuteScalarByString(sql, new Dictionary <string, object>()); if (ret == -1) { return(new Result() { ReturnValue = false, Message = "角色使用中无法删除,删除失败!" }); } ts.Complete(); return(new Result() { ReturnValue = true, Message = "删除成功!" }); } catch (Exception ex) { return(new Result() { ReturnValue = false, Message = ex.Message }); } } }
private void bindform() { if (userid > 0) { Model.UserInfo info = BLL.UsersBLL.GetModel(userid); if (info != null && info.UserID > 0) { hfUserId.Value = info.UserID.ToString(); txbUserName.Text = info.UserName; txbUserName.Enabled = false; txbDisPlayName.Text = info.DisplayName; passrow.Visible = false; txbFirstName.Text = info.FirstName; txbLastName.Text = info.LastName; txbEmail.Text = info.Email; if (!info.IsLock) { rbNoIsLockedOut.Checked = true; rbIsLockedOut.Checked = false; } else { rbNoIsLockedOut.Checked = false; rbIsLockedOut.Checked = true; } if (info.UserType == Common.enumUserType.host.ToString()) { rbNoIsLockedOut.Enabled = rbIsLockedOut.Enabled = false; } btnsave.Enabled = true; btnsave.Text = "修改"; } } }
public override void SubProcessRequest(HttpContext context) { #region 接收参数 //接收参数 string strUserId = Context.Request.Form["UserId"]; string strUsername = Context.Request.Form["Username"]; string strPassword = Context.Request.Form["Password"]; string strRealName = Context.Request.Form["RealName"]; string strPhone = Context.Request.Form["Phone"]; string strUserType = Context.Request.Form["UserType"]; string strStatus = Context.Request.Form["Status"]; string strCreateDate = Context.Request.Form["CreateDate"]; #endregion UserInfoBll bllUserInfo = new UserInfoBll(); #region 实体赋值 //实体赋值 oyxf.Model.UserInfo model = new Model.UserInfo(); if (!string.IsNullOrWhiteSpace(strUserId) && strUserId.IsNumber()) { //修改 model.UserId = Convert.ToInt32(strUserId); } model.Username = !string.IsNullOrWhiteSpace(strUsername) ? strUsername : ""; model.RealName = !string.IsNullOrWhiteSpace(strRealName) ? strRealName : ""; model.Phone = !string.IsNullOrWhiteSpace(strPhone) ? strPhone : ""; model.UserType = (!string.IsNullOrWhiteSpace(strUserType) && strUserType.IsNumber()) ? Convert.ToInt32(strUserType) : 0; model.Status = (!string.IsNullOrWhiteSpace(strStatus) && strStatus.IsNumber()) ? Convert.ToInt32(strStatus) : 0; //创建时间 model.CreateDate = !string.IsNullOrWhiteSpace(strCreateDate) ? DateTime.ParseExact(strCreateDate, "yyyy-MM-dd HH:mm:ss:fff", System.Globalization.CultureInfo.CurrentCulture) : DateTime.Now; //密码 model.Password = !string.IsNullOrWhiteSpace(strPassword) ? strPassword.ToUpper() : ""; #endregion #region 用户名是否重复 //用户名是否重复 if (bllUserInfo.IsExistUsername(model)) { AjaxHelper.WriteError(msg: "用户名已存在"); } #endregion #region 新增或修改 //新增或修改 if (bllUserInfo.AddOrUpdate(model)) { AjaxHelper.WriteSuccess(); } else { AjaxHelper.WriteError(msg: "操作失败"); } #endregion }
public async Task <Model.UserInfo> GetUserInfoAsync(string userName) { var query = context.UserInfos .Include("UserCustomer") .Where(x => x.UserName == userName); var result = await query .AsNoTracking() .FirstOrDefaultAsync(); if (result != null) { var user = new Model.UserInfo() { UserId = result.UserId, UserName = result.UserName }; if (result.UserCustomers != null && result.UserCustomers.Any()) { foreach (var c in result.UserCustomers) { user.UserCustomers.Add(new Model.UserCustomer() { UserId = c.UserId, CustomerId = c.CustomerId, DivisionId = c.DivisionId }); } } return(user); } return(null); }
//注册验证 public ActionResult CheckRegister(RegisterModel registerModel) { string validateCode = Session["validateCode"] == null ? string.Empty : Session["validateCode"].ToString(); if (string.IsNullOrEmpty(validateCode)) { return(Content("no:验证码错误!")); } Session["validateCode"] = null; string requestCode = Request["vCode"]; if (!requestCode.Equals(validateCode, StringComparison.InvariantCultureIgnoreCase)) { return(Content("no:验证码错误!!")); } CT.Model.UserInfo userInfo = new Model.UserInfo { UserInfo_Name = registerModel.User_Name, UserInfo_Password = registerModel.User_Password, UserInfo_Email = registerModel.User_Email, UserInfo_Phone = registerModel.User_Phone, UserInfo_Img = registerModel.User_Img }; var adduser = UserInfoService.Add(userInfo); if (adduser == true) { return(Content("ok:注册成功")); } else { return(Content("no:注册失败")); } }
private void AddUserInfo(HttpContext context) { BLL.UserInfo bll = new BLL.UserInfo(); string UserName = context.Request["U_username"]; int ExistRes = bll.Exist(string.Format("U_username='******'", UserName)); if (ExistRes > 0) { context.Response.Write("exist"); return; } Model.UserInfo model = new Model.UserInfo(); model.U_username = UserName; model.U_password = model.U_username; model.U_power = context.Request["U_power"]; model.U_nickname = context.Request["U_nickname"]; model.U_mailbox = context.Request["U_mailbox"]; model.U_Role = context.Request["U_Role"]; model.U_Comments = context.Request["U_Comments"]; model.U_CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); model.U_IsDelete = 0; if (bll.Add(model) > 0) { context.Response.Write("success"); } else { context.Response.Write("fail"); } }
private void UpdateUserInfo(HttpContext context) { BLL.UserInfo bll = new BLL.UserInfo(); string UserName = context.Request["U_username"]; string ID = context.Request["U_ID"]; int ExistRes = bll.Exist(string.Format("U_username='******' and U_ID not in ({1})", UserName, ID)); if (ExistRes > 0) { context.Response.Write("exist"); return; } Model.UserInfo model = new Model.UserInfo(); model.U_ID = Convert.ToInt32(ID); model.U_username = UserName; model.U_power = context.Request["U_power"]; model.U_nickname = context.Request["U_nickname"]; model.U_mailbox = context.Request["U_mailbox"]; model.U_Role = context.Request["U_Role"]; model.U_Comments = context.Request["U_Comments"]; if (bll.Update(model)) { context.Response.Write("success"); } else { context.Response.Write("fail"); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (CheckInput()) { Model.UserInfo modelUserInfo = new Model.UserInfo(); modelUserInfo.UserName = txtUserName.Text; modelUserInfo.Password = lv_Common.DEncrypt.DEncrypt.Encrypt(this.txtPassword.Text); modelUserInfo.Email = txtEmail.Text; modelUserInfo.ApprovedState = (int)BLL.TypeEnum.UserApprovedState.未审核; modelUserInfo.RoleID = new Guid(ddlUserRoles.SelectedValue); bllUserInfo.Add(modelUserInfo); lv_Common.MessageBox.ShowAndRedirect(this.Page, "新增成功", "List.aspx"); } }
public Fangor.Model.UserInfo GetBind(SqlDataReader Reader) { Fangor.Model.UserInfo result = new Model.UserInfo(); result.User_Id1 = Convert.ToInt32(Reader["User_Id"]); result.User_Name1 = Reader["User_Name"].ToString(); result.User_Type1 = Convert.ToInt32(Reader["User_Type"]); result.PassWord1 = Reader["PassWord"].ToString(); result.Time1 = Convert.ToDateTime(Reader["Time"]); return result; }
protected void LogInButton_Click(object sender, EventArgs e) { var user = new Model.UserInfo(); user.UserName = this.UserField.Text.Trim(); user.Password = this.PassField.Text.Trim(); if (Membership.ValidateUser(user.UserName, user.Password)) { FormsAuthentication.RedirectFromLoginPage(user.UserName, false); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + "Invalid username or password" + "');", true); } }
public void ProcessRequest(HttpContext context) { string email = context.Request["Email"]; string user = context.Request["User"]; if (user != null && user != "") { Model.UserInfo modelUserInfo = new Model.UserInfo(); UserInfoExt bllUserInfo = new UserInfoExt(); modelUserInfo = bllUserInfo.GetUserByName(user); if (email == modelUserInfo.Email) { context.Response.Write("yes"); } else { context.Response.Write("no"); } } }
/// <summary> /// 获取起点或终点在同一城市的用户信息 /// </summary> /// <param name="city">城市名</param> /// <returns></returns> public List<Model.UserInfo> GetAllUserInfoByCity(string cityname) { List<Model.UserInfo> userinfoList = null; OracleDataReader reader = null; try { reader = OracleHelper.ExecuteReader("SELECT REGDATE,CONTACT,IP,STARTNAME,ENDNAME,DRAGPOINTS,EMAIL,NAME,PWD,FLAG,ID FROM USERINFO WHERE STARTNAME = :cityname OR ENDNAME = :cityname ", new OracleParameter[] { new OracleParameter("cityname",cityname) }); if (reader.RowSize > 0) { userinfoList = new List<Model.UserInfo>(); while (reader.Read()) { Model.UserInfo userinfo = new Model.UserInfo(); userinfo.RegDate = reader.GetDateTime(0); userinfo.Contact = reader.GetString(1); userinfo.IP = reader.GetString(2); userinfo.StartName = reader.GetString(3); userinfo.EndName = reader.GetString(4); userinfo.DragPoints = reader.GetString(5); userinfo.Email = reader.GetString(6); userinfo.Name = reader.GetString(7); userinfo.Pwd = reader.GetString(8); userinfo.Flag = reader.GetInt32(9); userinfo.ID = reader.GetInt64(10); userinfoList.Add(userinfo); } } } catch (System.Exception) { throw; } finally { reader.Close(); } return userinfoList; }
private void Login(string id, string name) { BLL.UserInfoExt bllUserInfo = new BLL.UserInfoExt(); if (!bllUserInfo.IsExistUserName(id)) { Model.UserInfo modelUserInfo = new Model.UserInfo(); modelUserInfo.UserName = id; modelUserInfo.Password = lv_Common.DEncrypt.DEncrypt.Encrypt(DateTime.Now.ToString()); modelUserInfo.ApprovedState = (int)BLL.TypeEnum.UserApprovedState.未审核; modelUserInfo.Email = ""; modelUserInfo.Nick = name; BLL.UserRolesExt bllUserRoles = new BLL.UserRolesExt(); modelUserInfo.RoleID = bllUserRoles.GetRoleByRoleName("普通会员").UserRoleID; bllUserInfo.Add(modelUserInfo); } Model.UserInfo modelUser = bllUserInfo.GetUserByName(id); if (modelUser.Nick != name) { bllUserInfo.UpdateField("Nick", name, modelUser.UserID); } BLL.MenberValidate.RegisterTicket(id); }
public Fangor.Model.Quotes GetBind(SqlDataReader Reader) { Fangor.Model.Quotes result = new Model.Quotes(); result.Quote_Id1 = Convert.ToInt32(Reader["Quote_Id"]); result.Quote_Name1 = Reader["Quote_Name"].ToString(); result.Quote_Content1 = Reader["Quote_Content"].ToString(); result.Quote_Case1 = Convert.ToInt32(Reader["Quote_Case"]); result.Quote_Time1 = Convert.ToDateTime(Reader["Quote_Time"]); result.Quote_Type1 = Convert.ToInt32(Reader["Quote_Type"]); Fangor.Model.UserInfo users = new Model.UserInfo(); users.User_Id1 = Convert.ToInt32(Reader["Quote_Writer"]); result.Quote_Writer1 = users; return result; }
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text.Trim() == "") { MessageBox.Show("用户名不能为空!", "Error"); return; } if (textBox2.Text.Trim() == "") { MessageBox.Show("密码不能为空!", "Error"); return; } string user = textBox1.Text.Trim(); string pass = textBox2.Text.Trim(); Model.UserInfo adduser = new Model.UserInfo(); adduser.UserName = user; adduser.Password = pass; BLL.UserInfo insectuser = new BLL.UserInfo(); if (insectuser.AddUserInfoList(adduser)) { MessageBox.Show("注册成功!"); this.Hide(); LoginUI f; f = new LoginUI(); f.Show(); } else { MessageBox.Show("很抱歉,注册失败!","Error"); textBox1.Text = ""; textBox2.Text = ""; textBox1.Focus(); } }
public Model.UserInfo GetUserInfoByUserID(int userid) { Model.UserInfo userinfo = null; OracleDataReader reader = null; try { reader = OracleHelper.ExecuteReader("SELECT REGDATE,CONTACT,IP,STARTNAME,ENDNAME,DRAGPOINTS,EMAIL,NAME,PWD,FLAG FROM USERINFO WHERE ID = :id", new OracleParameter[] { new OracleParameter("id",userid) }); if (reader.RowSize > 0) { userinfo = new Model.UserInfo(); userinfo.ID = userid; userinfo.RegDate = reader.GetDateTime(0); userinfo.Contact = reader.GetString(1); userinfo.IP = reader.GetString(2); userinfo.StartName = reader.GetString(3); userinfo.EndName = reader.GetString(4); userinfo.DragPoints = reader.GetString(5); userinfo.Email = reader.GetString(6); userinfo.Name = reader.GetString(7); userinfo.Pwd = reader.GetString(8); userinfo.Flag = reader.GetInt32(9); } } catch (System.Exception) { throw; } finally { reader.Close(); } return userinfo; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.UserInfo GetModel(int UserID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ui_YongHID,ui_YongHDLMC,ui_YongHDLMM,ui_JueSID,ui_Enalbed,ui_Deleted,ui_YongHBZ from UserInfo "); strSql.Append(" where ui_YongHID=@ui_YongHID and ui_Deleted=0 "); SqlParameter[] parameters = { new SqlParameter("@ui_YongHID", SqlDbType.Int,4) }; parameters[0].Value = UserID; Model.UserInfo model = new Model.UserInfo(); DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringProfile, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ui_YongHID"] != null && ds.Tables[0].Rows[0]["ui_YongHID"].ToString() != "") { model.ui_YongHID = int.Parse(ds.Tables[0].Rows[0]["ui_YongHID"].ToString()); } if (ds.Tables[0].Rows[0]["ui_YongHDLMC"] != null && ds.Tables[0].Rows[0]["ui_YongHDLMC"].ToString() != "") { model.ui_YongHDLMC = ds.Tables[0].Rows[0]["ui_YongHDLMC"].ToString(); } if (ds.Tables[0].Rows[0]["ui_YongHDLMM"] != null && ds.Tables[0].Rows[0]["ui_YongHDLMM"].ToString() != "") { model.ui_YongHDLMM = ds.Tables[0].Rows[0]["ui_YongHDLMM"].ToString(); } if (ds.Tables[0].Rows[0]["ui_JueSID"] != null && ds.Tables[0].Rows[0]["ui_JueSID"].ToString() != "") { model.ui_JueSID = int.Parse(ds.Tables[0].Rows[0]["ui_JueSID"].ToString()); } if (ds.Tables[0].Rows[0]["ui_Enalbed"] != null && ds.Tables[0].Rows[0]["ui_Enalbed"].ToString() != "") { model.ui_Enalbed = int.Parse(ds.Tables[0].Rows[0]["ui_Enalbed"].ToString()); } if (ds.Tables[0].Rows[0]["ui_Deleted"] != null && ds.Tables[0].Rows[0]["ui_Deleted"].ToString() != "") { model.ui_Deleted = int.Parse(ds.Tables[0].Rows[0]["ui_Deleted"].ToString()); } if (ds.Tables[0].Rows[0]["ui_YongHBZ"] != null && ds.Tables[0].Rows[0]["ui_YongHBZ"].ToString() != "") { model.ui_YongHBZ = ds.Tables[0].Rows[0]["ui_YongHBZ"].ToString(); } return model; } else { return null; } }
/// <summary> /// 数据分页 /// </summary> /// <param name="strWhere"></param> /// <param name="PageSize"></param> /// <param name="PageIndex"></param> /// <param name="TableName"></param> /// <param name="SqlFiled"></param> /// <param name="PrimaryKey"></param> /// <param name="SqlOrder"></param> /// <param name="ZCount"></param> /// <returns></returns> public List<Model.UserInfo> GetUserInfo(string strWhere, int PageSize, int PageIndex, string TableName, string SqlFiled, string PrimaryKey, string SqlOrder, out int ZCount) { List<Model.UserInfo> UserInfoModel = new List<Model.UserInfo>(); SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@SqlWhere", SqlDbType.VarChar,8000), new SqlParameter("@PageSize", SqlDbType.Int), new SqlParameter("@PageIndex", SqlDbType.Int), new SqlParameter("@SqlTable", SqlDbType.VarChar,8000), new SqlParameter("@SqlField", SqlDbType.VarChar,8000), new SqlParameter("@SqlPK", SqlDbType.VarChar,50), new SqlParameter("@SqlOrder", SqlDbType.VarChar), new SqlParameter("@Count", SqlDbType.Int), }; parms[0].Value = strWhere; parms[1].Value = PageSize; parms[2].Value = PageIndex; parms[3].Value = TableName; parms[4].Value = SqlFiled; parms[5].Value = PrimaryKey; parms[6].Value = SqlOrder; parms[7].Direction = ParameterDirection.Output; DataTable dt = SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "pagination", parms); ZCount = int.Parse(parms[7].Value.ToString()); for (int i = 0; i < dt.Rows.Count; i++) { Model.UserInfo _UserInfo = new Model.UserInfo(); _UserInfo.ui_YongHID = int.Parse(dt.Rows[i]["ui_YongHID"].ToString()); _UserInfo.ui_YongHDLMC = dt.Rows[i]["ui_YongHDLMC"].ToString(); _UserInfo.ui_YongHDLMM = dt.Rows[i]["ui_YongHDLMM"].ToString(); _UserInfo.ui_JueSID = int.Parse(dt.Rows[i]["ui_JueSID"].ToString()); _UserInfo.ui_Enalbed = int.Parse(dt.Rows[i]["ui_Enalbed"].ToString()); _UserInfo.ui_Deleted = int.Parse(dt.Rows[i]["ui_Deleted"].ToString()); _UserInfo.ui_YongHBZ = dt.Rows[i]["ui_YongHBZ"].ToString(); UserInfoModel.Add(_UserInfo); } return UserInfoModel; }
public ActionResult UserInfo() { if (Session[SessionKey.User] == null) return RedirectToAction("Login"); Model.UserInfo usr = new Model.UserInfo(); usr = (Model.UserInfo)Session[SessionKey.User]; if (!string.IsNullOrWhiteSpace(usr.TrueName) && !string.IsNullOrWhiteSpace(usr.IdentityCardNo) && !string.IsNullOrWhiteSpace(usr.Phone)) { return RedirectToAction("Summary"); } Model.UserAdditionalInfo uai = new Model.UserAdditionalInfo(); uai.UserName = usr.UserName; uai.TrueName = usr.TrueName; uai.IdentityCardNo = usr.IdentityCardNo; uai.Phone = usr.Phone; return View(uai); }