Accumulated by bit [C #]-large ranking of delegated numbers (automatically generated)

Source: Internet
Author: User

 

Batch Number ranking (automatically generated ):

Effect:

Description: IDs are automatically generated in this table. The IDS are sorted in all tables. For example, if the delegate number generated on the add page is not 00048, the number generated in other tables is 00049.

Call:

 1   Protected   Void Page_load ( Object  Sender, eventargs E)  2   {  3 Response. expires =- 1  ;  4               If (!Ispostback)  5   {  6                7                   If (Actiontype = Commonenum. actionlevel. Write)  8   {  9                       10 Tbwtbh. Text = Getwtbh ();  11                       12   } 13   }  14   }  15   16   Protected   String  Getwtbh ()  17   {  18               String Getwtbh = commonfunction. getbymenucode (thispositionid, applicationinfo. serialnumwt, "  Qjlzhuan_lydj " , "  Wtbh  "  );  19               Return  Getwtbh;  20 }

Function:

 1   # Region Delegated number ranking 2   3           Public   Static   String Getbymenucode (String Thispositionid, Int Digit, String Tablename, String  Rowname)  4   {  5               String Getcode = String  . Empty;  6               String Title = String  . Empty; 7               String SQL = String . Format ( @"  Select max (right ({0 },  " + Digit + "  ) As rowname from {1 };  " + 8                                           "  Select left (max ({2}), Len (max ({2 }))-  " + Digit + " ) As rowtitle from {3}  " , "  Wtbhcode  " , "  Wtbh  "  , Rowname, tablename );  9 Dbcommand sqlcommand = Erpdatabase. erpdb. getsqlstringcommand (SQL );  10 Dataset dsdata = New  Dataset (); 11 Erpdatabase. erpdb. loaddataset (sqlcommand, dsdata, New   String [] { "  Data  " , "  Title  "  });  12               If (Dsdata. Tables [ "  Data  " ]. Rows. Count>0  )  13   {  14 Datarow ROW = dsdata. Tables [ "  Data  " ]. Rows [ 0  ];  15                   If (Row [ "  Rowname  " ] = Dbnull. value) 16   {  17 Getcode = "  1  "  ;  18 Getcode = getcode. padleft (digit, '  0  '  );  19   }  20                   Else 21   {  22                       String Second = row [ "  Rowname  "  ]. Tostring ();  23 Getcode = second. padleft (digit, '  0  '  );  24   }  25  }  26               If (Dsdata. Tables [ "  Title  " ]. Rows. Count> 0  )  27   {  28 Datarow ROW = dsdata. Tables [ "  Title  " ]. Rows [ 0 ];  29                   If (Row [ "  Rowtitle  " ]! = Dbnull. value)  30   {  31 Title = row [ "  Rowtitle  "  ]. Tostring ();  32   } 33   }  34               Return Title + Getcode;  35   }  36   37           Public   Static   Bool Repeatexperimnetid ( String Wtbh, Int  DIGIT)  38  {  39               Bool Isrepeat = False  ;  40 Stringbuilder strsql = New  Stringbuilder ();  41 Strsql. append ( String . Format ( "  Select right (wtbhcode,  " + Digit + " ) As wtbhcode from wtbh where right (wtbhcode,  " + Digit + "  ) = '{0 }'  " , Wtbh. substring (wtbh. Length- Digit, digit )));  42 Dbcommand sqlstringcommand = Erpdatabase. erpdb. getsqlstringcommand (strsql. tostring ());  43 Dataset dsdata = New  Dataset ();  44 Erpdatabase. erpdb. loaddataset (sqlstringcommand, dsdata, "  Data  "  );  45               If (Dsdata. Tables [ "  Data  " ]. Rows. Count> 0  )  46   {  47 Isrepeat = True ;  48   }  49               Return  Isrepeat;  50   }  51   52           Public   Static   Void Updatewtcode ( String Wtbh, Int  DIGIT) 53   {  54 Wtbh = (convert. toint32 (wtbh. substring (wtbh. Length-digit, digit) + 1 ). Tostring (). padleft (digit, '  0  '  );  55               String SQL = "  Update wtbh set wtbhcode = @ wtbhcode  "  ;  56 Dbcommand sqlcommand = Erpdatabase. erpdb. getsqlstringcommand (SQL );  57 Erpdatabase. erpdb. addinparameter (sqlcommand, "  @ Wtbhcode  " , Dbtype. String, wtbh. substring (wtbh. Length- Digit, digit ));  58   Erpdatabase. erpdb. executenonquery (sqlcommand );  59   }  60   61          # Endregion 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.