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,
- void NewAppID()
- {
- try
- {
- OleDbDataAdapter da = new OleDbDataAdapter("select [FormCode] from [Booking] order by [FormCode] desc", conn);
- DataSet ds = new DataSet();
- da.Fill(ds);
-
- if (lblProName.Text == "Fazal Sun City" || ds.Tables[0].Rows.Count > 0)
- {
- txtFormCode.Text = "FSC " + (int.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
- }
- else if (lblProName.Text == "Mehran Gold" || ds.Tables[0].Rows.Count > 0)
- {
- txtFormCode.Text = "MG " + (int.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
- }
- else
- {
- txtFormCode.Text = "1";
- }
-
- }
- catch (Exception ex)
- {
- MetroFramework.MetroMessageBox.Show(this, "Error" + ex.Message, "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop);
- }
- }