Esempio n. 1
0
        private void BindDetail(string code, string name, string ip, DateTime dateBegin, DateTime dateEnd)
        {
            try
            {
                if (dateBeginDate.DateTime > dateEndDate.DateTime)
                {
                    MsgBox.Warn("开始时间不能大于结束时间。");
                    return;
                }

                LoginLogEntiy logs = new LoginLogEntiy();
                labCode      = logs.UserCode = string.IsNullOrEmpty(code) ? null : code;
                labName      = logs.UserName = string.IsNullOrEmpty(name) ? null : name;
                labIp        = logs.IP = string.IsNullOrEmpty(ip) ? null : ip;
                labDateBegin = dateBegin;
                labDateEnd   = dateEnd;

                List <LoginLogEntiy> loginlogs = userDal.ListLoginLogs(logs, dateBegin, dateEnd.AddDays(1));
                gridOperateHistoryEntities.DataSource = loginlogs;
                labelTextDisplay();
            }
            catch (Exception ex)
            {
                MsgBox.Err(ex.Message);
            }
        }
Esempio n. 2
0
        public int InsertLoginLog(LoginLogEntiy loginlog)
        {
            IMapper map = DatabaseInstance.Instance();
            int     ret = -1;

            ret = map.Execute(
                string.Format("insert into LOGIN_LOG(USERCODE, IP, LOGINDATE, LOGINTYPE) " +
                              "values(@USER_CODE, @IP, {0}, @LOGINTYPE)", map.GetSysDateString()),
                new
            {
                USER_CODE = loginlog.UserCode,
                IP        = loginlog.IP,
                LOGINTYPE = loginlog.LoginType
            });
            return(ret);
        }
Esempio n. 3
0
        public List <LoginLogEntiy> ListLoginLogs(LoginLogEntiy log, DateTime DateFrom, DateTime DateTo)
        {
            IMapper map = DatabaseInstance.Instance();

            string sql = "select l.IP, l.LOGINDATE, l.LOGINTYPE, u.USER_CODE, u.USER_NAME from LOGIN_LOG l " +
                         "inner join Users u on u.USER_CODE = l.USER_CODE " +
                         "where (@IP is null or l.IP = @IP) and (@Name is null or u.USER_NAME = @Name) " +
                         "and (@Code is null or u.USER_CODE = @Code) and (@DateFrom is null or l.LOGINDATE >= @DateFrom) " +
                         "and (@DateTo is null or l.LOGINDATE <= @DateTo)";

            return(map.Query <LoginLogEntiy>(sql,
                                             new
            {
                IP = log.IP,
                Name = log.UserName,
                Code = log.UserCode,
                DateFrom = DateFrom,
                DateTo = DateTo
            }));
        }