Rizwan Ahmed

Rizwan Ahmed

  • 1.8k
  • 75
  • 3.1k

Generate new id code with alpha and number format

Nov 28 2018 11:35 AM
I create c# project with Access Database and I want to Autogenerated new id (Format as 3 Alphabets 3 Digits) but alphabets change automatically with selection of last form. i tried this but just 1st condition works,
 
  1. void NewAppID()  
  2.         {  
  3.             try  
  4.             {  
  5.                 OleDbDataAdapter da = new OleDbDataAdapter("select [FormCode] from [Booking] order by [FormCode] desc", conn);  
  6.                 DataSet ds = new DataSet();  
  7.                 da.Fill(ds);  
  8.   
  9.                 if (lblProName.Text == "Fazal Sun City" || ds.Tables[0].Rows.Count > 0)  
  10.                 {  
  11.                     txtFormCode.Text = "FSC " + (int.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();  
  12.                 }  
  13.                 else if (lblProName.Text == "Mehran Gold" || ds.Tables[0].Rows.Count > 0)  
  14.                 {  
  15.                     txtFormCode.Text = "MG " + (int.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();  
  16.                 }  
  17.                 else  
  18.                 {  
  19.                     txtFormCode.Text = "1";  
  20.                 }  
  21.   
  22.             }  
  23.             catch (Exception ex)  
  24.             {  
  25.                 MetroFramework.MetroMessageBox.Show(this"Error" + ex.Message, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);  
  26.             }  
  27.         }  
 

Answers (1)