Home » U++ Library support » TreeCtrl » off by 1 dynamic tree with sql: SOLVED
Re: off by 1 dynamic tree with sql: SOLVED [message #53732 is a reply to message #53714] |
Sat, 25 April 2020 01:58  |
|
Hi all-
I just thought I'd share how I drew the tree with my chart of accounts...
thnx for all the cool help here. I'm working on making a very small budgeting application.
roboloki
void MyMain::RunSQL(){
Sql sql(m3_session);
sql.Clear();
int y = -0;
int n = 0;
int n1 = 1;
String mystr;
sql.SetStatement("SELECT DISTINCT PFIELD, COUNT(*) from accounts GROUP BY GROUPING SETS (PFIELD) order by pfield");
sql.Execute();
while (sql.Fetch()) {
mystr=sql[0];
if (mystr.Find('*') != -1){
vm.Add(sql[0],sql[1]);
// PromptOK(sql[0].ToString());
}
}
}
void MyMain::SlingTv() {
int n = 0;
int n1 = 0;
String mystr;
Sql sql(m3_session);
sql.Clear();
sql.SetStatement(Select(PFIELD,ACCTNUM, ACCTNAME).From(ACCOUNTS).OrderBy(ACCTNUM));
sql.Execute();
while (sql.Fetch()){
mystr=sql[0];
if ( mystr.Find('*') != -1){
//PromptOK(AsString(n1));
optree.Add(0, sql[2].ToString());
}
}
sql.SetStatement(Select(PFIELD,ACCTNUM, ACCTNAME).From(ACCOUNTS).OrderBy(ACCTNUM));
sql.Execute();
while (sql.Fetch()){
mystr=sql[0];
if ( mystr.Find('*') != -1){
//PromptOK(AsString(n1));
n1 = 0;
PromptOK(AsString(n)+":n");
++n;
continue;
} else {
optree.Insert(n,n1,sql[2].ToString());
n1++;;
PromptOK(AsString(n1 )+":n1");
}
}
// optree.Insert(5,0,"foo");
// optree.Insert(5,1,"foo2");
// optree.Add(
}
|
|
|
Goto Forum:
Current Time: Mon Aug 25 22:11:13 CEST 2025
Total time taken to generate the page: 0.05142 seconds
|