C#最大值
dtToSList = sqlAccess.ExecuteTable(CommandText); ToSNo = Convert.ToString(dtToSList.Rows[i].ItemArray[1]); if (Convert.ToInt32(sqlAccess.ExecuteScalar(CommandText)) > 0) { string LastToSID; CommandText = "SELECT ToSNo FROM OverSystems_ToSInfo where ToSNo like '" + NewToSID + "%' order by ToSNo desc"; LastToSID = Convert.ToString(sqlAccess.ExecuteScalar(CommandText)).Substring(4); if (LastToSID.IndexOf("-") >= 0) LastToSID = LastToSID.Substring(0, LastToSID.IndexOf("-")); NewToSID += (Convert.ToInt32(LastToSID) + 1).ToString("000"); } //所选合同中都没有子项。因此注释寻找最大值代码。 //dtPom = pc.GetPoMaster(" where ToSNO like '" + Ponum + "%' order by PoID desc "); int max = 0; //for (int v = 0; v < dtPom.Rows.Count; v++) //{ // //编号'-'后的最大值 // int[] num = new int[1000]; // for (int c = 0; c < dtPom.Rows.Count; c++) // { // string Pono = Convert.ToString(dtPom.Rows[c]["ToSNO"]); // if (Pono.Contains("-")) // { // string pn = Pono.Split('-')[1]; // num[c] = Convert.ToInt32(pn); // } // } // max = num.Max(); //}