Example #1
0
        public QueryResult <TInfo> GetByID(TID id)
        {
            QueryResult <TInfo> result = null;

            try
            {
                AttendanceDataContext attendance = AttendanceDataContextFactory.Createattendance(ConnectStr);
                TInfo info = GetingItemByID(id, attendance);
                if (info != null)
                {
                    result = new QueryResult <TInfo>(ResultCode.Successful, successMsg, info);
                }
                else
                {
                    result = new QueryResult <TInfo>(ResultCode.Fail, string.Empty, info);
                }
            }
            catch (SqlException ex)
            {
                result = new QueryResult <TInfo>(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message, null);
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetByID()");
            }
            catch (Exception ex)
            {
                result = new QueryResult <TInfo>(ResultCode.Fail, ex.Message, null);
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetByID()");
            }
            return(result);
        }
Example #2
0
        public CommandResult Insert(TInfo info)
        {
            CommandResult result;

            try
            {
                AttendanceDataContext attendance = AttendanceDataContextFactory.Createattendance(ConnectStr);
                InsertingItem(info, attendance);
                attendance.SubmitChanges();
                result = new CommandResult(ResultCode.Successful, successMsg);
            }
            catch (SqlException ex)
            {
                result = new CommandResult(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message);
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "Insert()");
            }
            catch (Exception ex)
            {
                result = new CommandResult(ResultCode.Fail, ex.Message);
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "Insert()");
            }
            return(result);
        }
Example #3
0
        public QueryResultList <TInfo> GetItems(SearchCondition search)
        {
            QueryResultList <TInfo> result;

            try
            {
                AttendanceDataContext attendance = AttendanceDataContextFactory.Createattendance(ConnectStr);
                List <TInfo>          infoes;
                infoes = GetingItems(attendance, search);
                result = new QueryResultList <TInfo>(ResultCode.Successful, successMsg, infoes);
            }
            catch (SqlException ex)
            {
                result = new QueryResultList <TInfo>(ResultCodeResolver.GetFromSqlExceptionNumber(ex.Number), ex.Message, new List <TInfo>());
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetItems()");
            }
            catch (Exception ex)
            {
                result = new QueryResultList <TInfo>(ResultCode.Fail, ex.Message, new List <TInfo>());
                ExceptionPolicy.HandleException(ex, this.GetType().Name + "." + "GetItems()");
            }
            return(result);
        }