public bool AddSysAccountInfo(SysAccountInfoEntity sysAccountInfoEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("@UserName"); sqlCommandText.Append(", @LoginName"); sqlCommandText.Append(", @Pwd"); sqlCommandText.Append(", @Gender"); sqlCommandText.Append(", @Email"); sqlCommandText.Append(", @Mobile"); sqlCommandText.Append(", @Status"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.SysAccountInfo ({0}) VALUES ({1})", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString())); db.AddInParameter(cmd, "@UserName", DbType.AnsiString, sysAccountInfoEntity.UserName); db.AddInParameter(cmd, "@LoginName", DbType.AnsiString, sysAccountInfoEntity.LoginName); db.AddInParameter(cmd, "@Pwd", DbType.AnsiString, sysAccountInfoEntity.Pwd); db.AddInParameter(cmd, "@Gender", DbType.Byte, sysAccountInfoEntity.Gender); db.AddInParameter(cmd, "@Email", DbType.AnsiString, sysAccountInfoEntity.Email); db.AddInParameter(cmd, "@Mobile", DbType.AnsiString, sysAccountInfoEntity.Mobile); db.AddInParameter(cmd, "@Status", DbType.Byte, sysAccountInfoEntity.Status);; try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { if (TicketTool.IsLogin()) { AccountEntity = JsonConvert.DeserializeObject <SysAccountInfoEntity>(TicketTool.GetUserData()); } else { filterContext.HttpContext.Response.Redirect("/login/", true); } base.OnActionExecuting(filterContext); }
public List <SysAccountInfoEntity> MakeSysAccountInfoList(DataTable dt) { List <SysAccountInfoEntity> list = new List <SysAccountInfoEntity>(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { SysAccountInfoEntity sysAccountInfoEntity = MakeSysAccountInfo(dt.Rows[i]); list.Add(sysAccountInfoEntity); } } return(list); }
public SysAccountInfoEntity GetSysAccountInfo(Int32 adminID) { SysAccountInfoEntity sysAccountInfoEntity = null; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("SELECT TOP 1 AdminID,UserName,LoginName,Pwd,Gender,Email,Mobile,Status,LastIP,LoginDate,LogOnTimes,AddDate FROM dbo.SysAccountInfo WITH(NOLOCK)"); sqlCommandText.Append(" WHERE AdminID=@AdminID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd, "@AdminID", DbType.Int32, adminID); using (IDataReader dr = db.ExecuteReader(cmd)) { sysAccountInfoEntity = MakeSysAccountInfo(dr); } return(sysAccountInfoEntity); }
public SysAccountInfoEntity MakeSysAccountInfo(DataRow dr) { SysAccountInfoEntity sysAccountInfoEntity = null; if (dr != null) { sysAccountInfoEntity = new SysAccountInfoEntity(); sysAccountInfoEntity.AdminID = (Int32)dr["AdminID"]; sysAccountInfoEntity.UserName = (String)dr["UserName"]; sysAccountInfoEntity.LoginName = (String)dr["LoginName"]; sysAccountInfoEntity.Pwd = (String)dr["Pwd"]; sysAccountInfoEntity.Gender = (Byte)dr["Gender"]; sysAccountInfoEntity.Email = (String)dr["Email"]; sysAccountInfoEntity.Mobile = (String)dr["Mobile"]; sysAccountInfoEntity.Status = (Byte)dr["Status"]; sysAccountInfoEntity.LastIP = (String)dr["LastIP"]; sysAccountInfoEntity.LoginDate = (DateTime)dr["LoginDate"]; sysAccountInfoEntity.LogOnTimes = (Int32)dr["LogOnTimes"]; sysAccountInfoEntity.AddDate = (DateTime)dr["AddDate"]; } return(sysAccountInfoEntity); }
public bool DeleteSysAccountInfo(SysAccountInfoEntity sysAccountInfoEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.SysAccountInfo"); sqlCommandText.Append(" WHERE AdminID=@AdminID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd, "@AdminID", DbType.Int32, sysAccountInfoEntity.AdminID); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
public List <SysAccountInfoEntity> MakeSysAccountInfoList(IDataReader dr) { List <SysAccountInfoEntity> list = new List <SysAccountInfoEntity>(); while (dr.Read()) { SysAccountInfoEntity sysAccountInfoEntity = new SysAccountInfoEntity(); sysAccountInfoEntity.AdminID = (Int32)dr["AdminID"]; sysAccountInfoEntity.UserName = (String)dr["UserName"]; sysAccountInfoEntity.LoginName = (String)dr["LoginName"]; sysAccountInfoEntity.Pwd = (String)dr["Pwd"]; sysAccountInfoEntity.Gender = (Byte)dr["Gender"]; sysAccountInfoEntity.Email = (String)dr["Email"]; sysAccountInfoEntity.Mobile = (String)dr["Mobile"]; sysAccountInfoEntity.Status = (Byte)dr["Status"]; sysAccountInfoEntity.LastIP = (String)dr["LastIP"]; sysAccountInfoEntity.LoginDate = (DateTime)dr["LoginDate"]; sysAccountInfoEntity.LogOnTimes = (Int32)dr["LogOnTimes"]; sysAccountInfoEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(sysAccountInfoEntity); } dr.Close(); return(list); }
public bool UpdateSysAccountInfo(SysAccountInfoEntity sysAccountInfoEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" AdminID=@AdminID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" UserName=@UserName"); sqlCommandText.Append(", LoginName=@LoginName"); sqlCommandText.Append(", Gender=@Gender"); sqlCommandText.Append(", Email=@Email"); sqlCommandText.Append(", Mobile=@Mobile"); sqlCommandText.Append(", Status=@Status"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.SysAccountInfo SET {0} WHERE {1}", sqlCommandText.ToString(), whereCommandText.ToString())); db.AddInParameter(cmd, "@AdminID", DbType.Int32, sysAccountInfoEntity.AdminID); db.AddInParameter(cmd, "@UserName", DbType.AnsiString, sysAccountInfoEntity.UserName); db.AddInParameter(cmd, "@LoginName", DbType.AnsiString, sysAccountInfoEntity.LoginName); db.AddInParameter(cmd, "@Gender", DbType.Byte, sysAccountInfoEntity.Gender); db.AddInParameter(cmd, "@Email", DbType.AnsiString, sysAccountInfoEntity.Email); db.AddInParameter(cmd, "@Mobile", DbType.AnsiString, sysAccountInfoEntity.Mobile); db.AddInParameter(cmd, "@Status", DbType.Byte, sysAccountInfoEntity.Status); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSysAccountInfo(SysAccountInfoEntity sysAccountInfo) { return(SysAccountInfoDataAccess.Instance.AddSysAccountInfo(sysAccountInfo)); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSysAccountInfo(SysAccountInfoEntity sysAccountInfo) { return(SysAccountInfoDataAccess.Instance.DeleteSysAccountInfo(sysAccountInfo)); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteSysAccountInfo(SysAccountInfoEntity sysAccountInfo) { return(SysAccountInfoBusiness.DeleteSysAccountInfo(sysAccountInfo)); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateSysAccountInfo(SysAccountInfoEntity sysAccountInfo) { return(SysAccountInfoBusiness.UpdateSysAccountInfo(sysAccountInfo)); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddSysAccountInfo(SysAccountInfoEntity sysAccountInfo) { return(SysAccountInfoBusiness.AddSysAccountInfo(sysAccountInfo)); }