Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. generating CustomerID

generating CustomerID

Scheduled Pinned Locked Moved .NET (Core and Framework)
sales
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kolisa
    wrote on last edited by
    #1

    int n = int.Parse(CustomerID[CustomerID.Length - 1].CustomerID.Substring(4, 3)) + 1; i try this to generate customer ID but kept telling me the is clash with surburbID becouse i linked surburb in customer table

    J N 2 Replies Last reply
    0
    • K kolisa

      int n = int.Parse(CustomerID[CustomerID.Length - 1].CustomerID.Substring(4, 3)) + 1; i try this to generate customer ID but kept telling me the is clash with surburbID becouse i linked surburb in customer table

      J Offline
      J Offline
      Jens Meyer
      wrote on last edited by
      #2

      Dear Kolisa, have you tried something like that: int currentMax = CustomerID.Max(customer => int.Parse(CustomerID.Substring(4, 3)))+1; I assume you use c# as your choosen language in version 3.x. If not, pls specifiy your problem in more detail. Besides, i suggest to give your variables more distinguished names. Have an array with name CustomerID of type CustomerID is a little bit confusing. Also int.Parse on a substring without null checks or length checks is quite dangerous. Regards Jens

      When in trouble, when in doubt, run in circles, scream and shout

      1 Reply Last reply
      0
      • K kolisa

        int n = int.Parse(CustomerID[CustomerID.Length - 1].CustomerID.Substring(4, 3)) + 1; i try this to generate customer ID but kept telling me the is clash with surburbID becouse i linked surburb in customer table

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #3

        You have given very little context. What is surburbID? I assume a foreign key. What does your data structure like? How are you assigning the id? We can't read your mind and we're not working on the same project with you.


        I know the language. I've read a book. - _Madmatt

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups