Exemplo n.º 1
0
        void bookGenerateId()
        {
            string         OID = "select BOOK_ID from BOOK ORDER BY BOOK_ID";
            string         BName;
            int            BID;
            string         format = "0000000";
            SqlDataAdapter ad     = new SqlDataAdapter(OID, consql);
            DataSet        ds     = new DataSet();

            ad.Fill(ds, "Book");
            if (ds.Tables["Book"].Rows.Count > 0)
            {
                BName  = ds.Tables["Book"].Rows[ds.Tables["Book"].Rows.Count - 1][0].ToString();
                BID    = int.Parse(BName.Substring(1, (BName.Length - 1)));
                bookID = "B" + ((BID + 1).ToString(format));
            }
            else
            {
                bookID = "B0000001";
            }
        }