Exemplo n.º 1
0
        public static GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request,
                                                          Field field)
        {
            var prefix = request.Prefix ?? "";

            var max = connection.Query <string>(new SqlQuery()
                                                .From(field.Fields)
                                                .Select(Sql.Max(field.Expression))
                                                .Where(
                                                    field.StartsWith(prefix) &&
                                                    field >= prefix.PadRight(request.Length, '0') &&
                                                    field <= prefix.PadRight(request.Length, '9')))
                      .FirstOrDefault();

            var response = new GetNextNumberResponse();

            long l;

            response.Number = max == null ||
                              !long.TryParse(max.Substring(prefix.Length), out l) ? 1 : l + 1;

            response.Serial = prefix + response.Number.ToString()
                              .PadLeft(request.Length - prefix.Length, '0');

            return(response);
        }
Exemplo n.º 2
0
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(new MyRepository().GetNextNumber(connection, request));
 }
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, MyRow.Fields.CustomerID));
 }
Exemplo n.º 4
0
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, fld.WaresMoveID));
 }
Exemplo n.º 5
0
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, TransactionRow.Fields.TransactionNumber));
 }
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, fld.Napomena));
 }
Exemplo n.º 7
0
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, fld.CounterpartyId));
 }
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return(GetNextNumberHelper.GetNextNumber(connection, request, fld.SerijskiBroj));
 }
Exemplo n.º 9
0
 public GetNextNumberResponse GetNextNumber(IDbConnection connection, GetNextNumberRequest request)
 {
     return new MyRepository().GetNextNumber(connection, request);
 }