private string Mapn() { DataTable dt = bll.LoadPN(); if (dt.Rows.Count == 0) { return("PN01"); } else { string a = dt.Rows[0][0].ToString(); int mamax = int.Parse(a.Substring(2, a.Length - 2)); for (int i = 0; i < dt.Rows.Count; i++) { string b = dt.Rows[i][0].ToString(); int ma = int.Parse(b.Substring(2, b.Length - 2)); if (ma > mamax) { mamax = ma; } } return("PN0" + (mamax + 1).ToString()); } }