public string GetInvoiceNo(string com, string ColName, string TabName) { AccountantCls accountantCls = new AccountantCls(); string conString = WebConfigurationManager.ConnectionStrings["FinanceConnStr"].ConnectionString; Class1 class1 = new Class1(); int i = 0; string P = ""; try { accountantCls.Cmd.Connection.ConnectionString = accountantCls.GetConnStr(); accountantCls.Cmd.Parameters.Clear(); //accountantCls.Cmd.CommandText = " select Max(" + ColName + ") as InvoiceId from " + TabName ; accountantCls.Cmd.CommandType = CommandType.StoredProcedure; accountantCls.Cmd.CommandText = "USP_PathCompany_Select"; accountantCls.Cmd.Parameters.Add("@PropertyId", SqlDbType.NVarChar).Value = com; accountantCls.beginTrans(); accountantCls.Reader = accountantCls.Cmd.ExecuteReader(); if (accountantCls.Reader.Read()) { if (accountantCls.Reader["depth"].ToString() == "") { P = "1"; } else { P = accountantCls.Reader["depth"].ToString(); //P = i.ToString(); } } else { P = "1"; } accountantCls.Reader.Close(); accountantCls.commitTrans(); } catch (Exception ex) { accountantCls.rollBackTrans(); } char pad = '0'; P = P.PadLeft(6, pad); string InvNo = com + P; return(InvNo); }