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;
        }
Пример #2
0
 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);
 }
Пример #3
0
 public ActionResult AddAjax(SysAccountInfoEntity accountEntity)
 {
     try
     {
         if (!Request.IsAjaxRequest())
         {
             return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}");
         }
         string msg = "";
         if (ModelState.IsValid)
         {
             ISysAccountInfoService accountService = ServiceContainer.Instance.Container.Resolve<ISysAccountInfoService>();
             SysAccountInfoQuery queryEntity = new SysAccountInfoQuery();
             queryEntity.LoginName = WKT.Common.Security.SecurityUtils.SafeSqlString(accountEntity.LoginName);
             IList<SysAccountInfoEntity> list = accountService.GetSysAccountInfoList(queryEntity);
             if (list.Count > 0)
             {
                 msg = "{\"result\":\"failure\",\"msg\":\"该登录名已经存在\"}";
             }
             else
             {
                 accountEntity.Pwd = WKT.Common.Security.DES.Encrypt(accountEntity.Pwd);
                 bool flag = accountService.AddSysAccountInfo(accountEntity);
                 if (flag)
                 {
                     msg = "{\"result\":\"success\"}";
                 }
                 else
                 {
                     msg = "{\"result\":\"failure\",\"msg\":\"添加失败,请检查\"}";
                 }
             }
         }
         else
         {
             msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}";
         }
         return Content(msg);
     }
     catch(Exception ex)
     {
         LogProvider.Instance.Error("添加管理账户失败:" + ex.Message);
         return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}");
     }
 }
Пример #4
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteSysAccountInfo(SysAccountInfoEntity sysAccountInfo)
 {
     return SysAccountInfoBusiness.DeleteSysAccountInfo(sysAccountInfo);
 }
Пример #5
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddSysAccountInfo(SysAccountInfoEntity sysAccountInfo)
 {
     return SysAccountInfoBusiness.AddSysAccountInfo(sysAccountInfo);
 }
Пример #6
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateSysAccountInfo(SysAccountInfoEntity sysAccountInfo)
 {
     return SysAccountInfoBusiness.UpdateSysAccountInfo(sysAccountInfo);
 }
Пример #7
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteSysAccountInfo(SysAccountInfoEntity sysAccountInfo)
 {
     return SysAccountInfoDataAccess.Instance.DeleteSysAccountInfo(sysAccountInfo);
 }
Пример #8
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="sysAccountInfo">SysAccountInfoEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddSysAccountInfo(SysAccountInfoEntity sysAccountInfo)
 {
     return SysAccountInfoDataAccess.Instance.AddSysAccountInfo(sysAccountInfo);
 }
        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;
        }
 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 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;
        }
Пример #13
0
 public ActionResult EditAjax(SysAccountInfoEntity accountEntity)
 {
     try
     {
         if (!Request.IsAjaxRequest())
         {
             return Content("{\"result\":\"failure\",\"msg\":\"非法请求\"}");
         }
         string msg = "";
         if (ModelState.IsValid)
         {
             ISysAccountInfoService accountService = ServiceContainer.Instance.Container.Resolve<ISysAccountInfoService>();
             accountEntity.Pwd = WKT.Common.Security.DES.Encrypt(accountEntity.Pwd);
             bool flag = accountService.UpdateSysAccountInfo(accountEntity);
             if (flag)
             {
                 msg = "{\"result\":\"success\"}";
             }
             else
             {
                 msg = "{\"result\":\"failure\",\"msg\":\"修改失败,请检查\"}";
             }
         }
         else
         {
             msg = "{\"result\":\"failure\",\"msg\":\"" + this.ExpendErrors() + "\"}";
         }
         return Content(msg);
     }
     catch (Exception ex)
     {
         LogProvider.Instance.Error("修改管理账户失败:" + ex.Message);
         return Content("{\"result\":\"error\",\"msg\":\"" + ex.Message + "\"}");
     }
 }