Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

Combine the output of multiple values

Dear Expert;

In c# .NET I need to combine the following values to create a unique inventory control number for a product.  The method must:

Get 2 digit Plant number from Table “PLANTMASTER” WHERE  “currentLocation” = 1
Get 2 digit year from system DATE/Time
Get Reader Number (a value of 1 digit located in Table “READERNUMBER” WHERE “currenReader = 1)
Get last ticket number (5 digits) from table and increment by one

Combine these values into value called newTicket and display it in the appropriate text box on a form.


I thought this would be easy enough but I am struggling wth it.

Thanks... Ed&Rosie
0
edrosie
Asked:
edrosie
  • 2
1 Solution
 
Daniel Van Der WerkenIndependent ConsultantCommented:
One thing you can do is use hex numbers and bit shifting.  For example, use a long integer as the value you want:

0x0000000000000000

Then, the 2 digit plant number could be like 0xA5

The Year is another two digit hex number like 0x06

One digit reader is 0x01

Five digit ticket could be stored as a normal int:  0x004A

Now, put these together like this:

0x0000000000000000 | 0x004A to make the value 0x000000000000004A.
Shift it left by 16 bits:
0x000000000000004A << 16 which makes 0x00000000004A0000

Now or it again with the next value which is the one digit reader value:
0x00000000004A0000 | 0x01 and shift by 8 because you only need one byte this time
0x00000000004A0001 << 8 is 0x00000000004A0100

or the next value, the year for 0x00000000004A0100 | 0x06 = 0x00000000004A0106
shift left by 8:
0x000000004A010600

Now do the last one:
0x0000004A010600A5

Now you have all your info stored in one number: 0x0000004A is the ticke number,
0x04A, 0x01, and 0x06 are all available.  You can get to them by using the logical and:

0x0000004A010600A5 & 0x0000FFFF00000000 will give you 0x0000004A00000000

etc.






0
 
edrosieAuthor Commented:
thanks for responding so quickly.

unfortunatly I have to use an existing format in order to coexist with the current system

The existing format is 10 digits numeric

example:  0806112345

Where:

08 = plant number
06 = year
1 = reader number
12345 = item number which must incriment by one each time a new ticket is created.


Thanks for your help on this
0
 
edrosieAuthor Commented:
Thank you for responding so quickly
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now