예제 #1
0
        /// <summary>
        /// 根据条件查询登录日志信息
        /// </summary>
        /// <returns></returns>
        public static LoginLog GetLoginLogByConn(string demandType, string demandContent)
        {
            string        sql      = "Select * from LoginLog where " + demandType + " = @" + demandType;
            LoginLog      LoginLog = new LoginLog();
            SqlDataReader dr       = DBHelper.ExecuteReader(sql, CommandType.Text, new SqlParameter[] {
                new SqlParameter("@" + demandType, demandContent)
            });

            if (dr.Read())
            {
                LoginLog = new LoginLog()
                {
                    Log_City      = dr["Log_City"].ToString(),
                    Log_Country   = dr["Log_Country"].ToString(),
                    Log_Date      = dr["Log_Date"].ToString(),
                    Log_ipAddress = dr["Log_ipAddress"].ToString(),
                    Log_Province  = dr["Log_Province"].ToString(),
                    P_LoginName   = dr["P_LoginName"].ToString(),
                    Log_No        = Convert.ToInt32(dr["Log_No"])
                };
            }
            dr.Close();
            DBHelper.CloseCon();
            return(LoginLog);
        }
예제 #2
0
        /// <summary>
        /// 获取全部登录日志信息(按序号从大到小排序)
        /// </summary>
        /// <returns></returns>
        public static List <LoginLog> GetAllLoginLogByDesc(string LoginName)
        {
            List <LoginLog> list = new List <LoginLog>();
            SqlDataReader   dr   = DBHelper.ExecuteReader("Select_LoginLogByDesc", CommandType.StoredProcedure,
                                                          new SqlParameter[] {
                new SqlParameter("@P_LoginName", LoginName)
            });

            while (dr.Read())
            {
                LoginLog atype = new LoginLog()
                {
                    Log_City      = dr["Log_City"].ToString(),
                    Log_Country   = dr["Log_Country"].ToString(),
                    Log_Date      = dr["Log_Date"].ToString(),
                    Log_ipAddress = dr["Log_ipAddress"].ToString(),
                    Log_Province  = dr["Log_Province"].ToString(),
                    P_LoginName   = dr["P_LoginName"].ToString(),
                    Log_No        = Convert.ToInt32(dr["Log_No"])
                };
                list.Add(atype);
            }
            dr.Close();
            DBHelper.CloseCon();
            return(list);
        }
예제 #3
0
        /// <summary>
        /// 删除登录日志数据
        /// </summary>
        /// <returns></returns>
        public static int DeleteLoginLog(LoginLog obj)
        {
            int n = DBHelper.ExecuteNonQuery("Delete_LoginLog", CommandType.StoredProcedure,
                                             new SqlParameter[] {
                new SqlParameter("@Log_No", obj.Log_No)
            });

            return(n);
        }
예제 #4
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="LoginLog">LoginLog实体对象</param>
 /// <returns>int值,返回自增ID</returns>
 public int addReturnId(LoginLog model)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter ("@User_Account",model.User_Account),
         new SqlParameter ("@LoginLog_BuilTime",model.LoginLog_BuilTime),
         new SqlParameter ("@LoginLog_IP",model.LoginLog_IP),
         new SqlParameter ("@LoginLog_Status",model.LoginLog_Status),
         new SqlParameter ("@User_id",model.User_id)
     };
        return Convert.ToInt32(Helper.ExecuteScalar ("LoginLog_AddReturnId",param));
 }
예제 #5
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <param name="LoginLog">LoginLog实体对象</param>
 /// <returns>bool值,判断是否操作成功</returns>
 public bool add(LoginLog model)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter ("@User_Account",model.User_Account),
         new SqlParameter ("@LoginLog_BuilTime",model.LoginLog_BuilTime),
         new SqlParameter ("@LoginLog_IP",model.LoginLog_IP),
         new SqlParameter ("@LoginLog_Status",model.LoginLog_Status),
         new SqlParameter ("@User_id",model.User_id)
     };
        return Helper.ExecuteNonQuery("LoginLog_Add",param);
 }
예제 #6
0
        /// <summary>
        /// 写入登录日志,返回日志Id
        /// </summary>
        /// <param name="loginLog"></param>
        /// <returns></returns>
        public int WriteLoingLog(LoginLog loginLog)
        {
            string sql = "INSERT INTO LoginLogs (LoginId,SPName,ServerName) VALUES (@LoginId,@SPName,@ServerName);SELECT @@IDENTITY";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@LoginId", loginLog.LoginId),
                new SqlParameter("@SPName", loginLog.SPName),
                new SqlParameter("@ServerName", loginLog.ServerName)
            };
            return(Convert.ToInt32(SqlHelper.GetSingleResult(sql, param)));
        }
예제 #7
0
        /// <summary>
        /// 添加登录日志数据
        /// </summary>
        /// <returns></returns>
        public static int InsertLoginLog(LoginLog obj)
        {
            int n = DBHelper.ExecuteNonQuery("Insert_LoginLog", CommandType.StoredProcedure,
                                             new SqlParameter[] {
                new SqlParameter("@Log_City", obj.Log_City),
                new SqlParameter("@Log_Country", obj.Log_Country),
                new SqlParameter("@Log_Date", obj.Log_Date),
                new SqlParameter("@Log_ipAddress", obj.Log_ipAddress),
                new SqlParameter("@Log_Province", obj.Log_Province),
                new SqlParameter("@P_LoginName", obj.P_LoginName)
            });

            return(n);
        }
예제 #8
0
        /// <summary>
        /// 添加登录日志,返回记录编号
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public int WriteLoginLog(LoginLog info)
        {
            string sql = "insert into LoginLogs(LoginId,SPName,ServerName,LoginAddr,LoginDept)";

            sql += " values (@LoginId,@SPName,@ServerName,@LoginAddr,@LoginDept);select @@identity";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@LoginId", info.LoginId),
                new SqlParameter("@SPName", info.SPName),
                new SqlParameter("@ServerName", info.ServerName),
                new SqlParameter("@LoginAddr", info.LoginAddr),
                new SqlParameter("@LoginDept", info.LoginDept),
            };
            return(Convert.ToInt32(SQLHelper.GetSingleResult(sql, param)));
        }
예제 #9
0
        /// <summary>
        /// 添加登录日志
        /// </summary>
        /// <param name="info"></param>
        /// <returns>返回日志编号</returns>
        public int WriteLog(LoginLog info)
        {
            string sql = "insert into LoginLogs(LoginId,SPName,ServerName) ";

            sql += "values(@LoginId,@SPName,@ServerName);select @@identity";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@LoginId", info.LoginId),
                new SqlParameter("@SPName", info.SPName),
                new SqlParameter("@ServerName", info.ServerName)
            };
            try
            {
                return(Convert.ToInt32(SQLHelp.GetSingleResult(sql, param)));
            }
            catch (SqlException ex)
            {
                throw new Exception("应用程序与数据库连接出错,具体内容: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
 /// <summary>
 /// 查看全部
 /// </summary>
 /// <returns>list集合</returns>
 public List<LoginLog> selectAll()
 {
     List<LoginLog> list = new List<LoginLog>();
     LoginLog model = null;
     using (SqlDataReader dr = Helper.ExecuteReader("LoginLog_SelectAll", null))
     {
         while (dr.Read())
         {
             model = new LoginLog();
             model.LoginLog_ID= Convert.ToInt32(dr["LoginLog_ID"]);
             model.User_Account = dr["User_Account"].ToString();
             model.LoginLog_BuilTime= Convert.ToDateTime(dr["LoginLog_BuilTime"]);
             model.LoginLog_IP = dr["LoginLog_IP"].ToString();
             model.LoginLog_Status= Convert.ToInt32(dr["LoginLog_Status"]);
             if (DBNull.Value!=dr["User_id"])
                 model.User_id= Convert.ToInt32(dr["User_id"]);
             list.Add(model);
         }
     }
     return list;
 }
예제 #11
0
 /// <summary>
 /// 通过条件查询
 /// </summary>
 /// <param name="WhereString">查询条件</param>
 /// <returns>LoginLog实体类对象</returns>
 public List<LoginLog> selectByWhere(string WhereString)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter ("@where",WhereString)
     };
     List<LoginLog> list = new List<LoginLog>();
     LoginLog model = null;
     using (SqlDataReader dr = Helper.ExecuteReader("LoginLog_SelectByWhere", param))
     {
         while (dr.Read())
         {
             model = new LoginLog();
             model.LoginLog_ID= Convert.ToInt32(dr["LoginLog_ID"]);
             model.User_Account = dr["User_Account"].ToString();
             model.LoginLog_BuilTime= Convert.ToDateTime(dr["LoginLog_BuilTime"]);
             model.LoginLog_IP = dr["LoginLog_IP"].ToString();
             model.LoginLog_Status= Convert.ToInt32(dr["LoginLog_Status"]);
             if (DBNull.Value!=dr["User_id"])
                 model.User_id= Convert.ToInt32(dr["User_id"]);
             list.Add(model);
         }
     }
     return list;
 }
예제 #12
0
 /// <summary>
 /// 通过Id查询
 /// </summary>
 /// <param name="Id">主键Id</param>
 /// <returns>LoginLog实体类对象</returns>
 public LoginLog selectById(int Id)
 {
     SqlParameter[] param = new SqlParameter[]
     {
         new SqlParameter ("@LoginLog_ID",Id)
     };
     LoginLog model = new LoginLog();
     using (SqlDataReader dr = Helper.ExecuteReader("LoginLog_SelectById", param))
     {
         if (dr.Read())
         {
             model.LoginLog_ID= Convert.ToInt32(dr["LoginLog_ID"]);
             model.User_Account = dr["User_Account"].ToString();
             model.LoginLog_BuilTime= Convert.ToDateTime(dr["LoginLog_BuilTime"]);
             model.LoginLog_IP = dr["LoginLog_IP"].ToString();
             model.LoginLog_Status= Convert.ToInt32(dr["LoginLog_Status"]);
             if (DBNull.Value!=dr["User_id"])
                 model.User_id= Convert.ToInt32(dr["User_id"]);
         }
     }
     return model;
 }