- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
String getFindList(StringBuffer sb, String[] src) {
// int tid = Helper.parseType(src[2]);
// if(tid < 1 || tid > 99) return "Error parse good type";
int stk = Helper.parseType(src[3]);
if(stk < 412 || stk > 416) return "Error parse stock code";
// --------------------------------------------------------
IntHashtable work = new IntHashtable();
double[] vals = null;
Entry ent = null;
Enumeration e=cache.getEntryElements();
while(e.hasMoreElements()) {
ent = (Entry)e.nextElement();
if(ent.Credit != stk) continue;
if(ent.Status == 0) continue;
vals = (double[])work.get(ent.SubCred);
if(vals == null) {
vals = new double[2];
vals[0] = ent.Value;
work.put(ent.SubCred, vals);
} else
vals[0]+=ent.Value;
}
// ---------------------------------------------------------
String s="SELECT ... ";
int id;
String cod, gnm, uni;
double amt,val,pack,vlr;
double[] prcs = new double[4];
Connection con = cache.getConnection();
if(con == null) return "No free conection";
try {
Statement stmt = con.createStatement();
ResultSet rset = stmt.executeQuery(s);
while(rset.next()) {
id = rset.getInt("id");
cod = rset.getString("code");
gnm = rset.getString("name");
uni = rset.getString("unit");
pack = rset.getDouble("pack");
amt = rset.getDouble("amount");
val = rset.getDouble("value");
prcs[0] = rset.getDouble("price");
prcs[1] = rset.getDouble("price1");
prcs[1]=(prcs[1] < 0.01) ? prcs[0] : prcs[1];
prcs[2] = rset.getDouble("price2");
prcs[2]=(prcs[2] < 0.01) ? prcs[1] : prcs[2];
prcs[3] = rset.getDouble("sprice");
prcs[3]=(prcs[3] < 0.01) ? prcs[2] : prcs[3];
vals = (double[])work.get(id);
vlr =(vals == null) ? 0 : vals[0];
sb.append(id+",'"+gnm+"','"+cod+"','"+uni+"',"+pack+","+val+","+vlr+",");
for(int i=0; i<prcs.length; i++) sb.append(prcs[i]+",");
sb.append((amt/val)+",\n");
}
rset.close();
stmt.close();
s = null;
} catch (SQLException ex) {
s=ex.getMessage();
}
cache.freeConnection(con);
return s;
}