rutgermons
asked on
add case/if statement to java
folks
i have the following
super.action();
Mbo mbo = getMboValue().getMbo();
String prioprity = mbo.getString("WOPRIORITY" );
if (!getMboValue().isNull())
{
SqlFormat sqlpriority = new SqlFormat(mbo, " domainid='SR_CALCPRIO' and value=:1 ");
sqlpriority.setObject(1, "numericdomain", "value", prioprity);
MboRemote WORemote = mbo.getMboSet("$numericdom ain", "numericdomain", sqlpriority.format()).getM bo(0);
if (WORemote != null && !mbo.isNull("TARGSTARTDATE ")){
int priodesc = WORemote.getInt("DESCRIPTI ON");
Date targerstart = mbo.getDate("TARGSTARTDATE ");
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
c.add(Calendar.MINUTE,prio desc);
mbo.setValue("TARGCOMPDATE ", c.getTime(), 2L);
}
if want to add time on the targetstart as you see but i now want to have the following
if WOPRIORTIY = 10 then
c.add(Calendar.MINUTE,prio desc * 1.35)
if
WOPRIORTIY = 20 then
c.add(Calendar.MINUTE,prio desc * 1.55)
all help will do
r
i have the following
super.action();
Mbo mbo = getMboValue().getMbo();
String prioprity = mbo.getString("WOPRIORITY"
if (!getMboValue().isNull())
{
SqlFormat sqlpriority = new SqlFormat(mbo, " domainid='SR_CALCPRIO' and value=:1 ");
sqlpriority.setObject(1, "numericdomain", "value", prioprity);
MboRemote WORemote = mbo.getMboSet("$numericdom
if (WORemote != null && !mbo.isNull("TARGSTARTDATE
int priodesc = WORemote.getInt("DESCRIPTI
Date targerstart = mbo.getDate("TARGSTARTDATE
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
c.add(Calendar.MINUTE,prio
mbo.setValue("TARGCOMPDATE
}
if want to add time on the targetstart as you see but i now want to have the following
if WOPRIORTIY = 10 then
c.add(Calendar.MINUTE,prio
if
WOPRIORTIY = 20 then
c.add(Calendar.MINUTE,prio
all help will do
r
ASKER
how would i place that in my code?
You could do
if (WORemote != null && !mbo.isNull("TARGSTARTDATE")){
int priodesc = WORemote.getInt("DESCRIPTION");
Date targerstart = mbo.getDate("TARGSTARTDATE");
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
switch(WOPRIORITY) {
case 10:
priodesc *= 1.35;
break;
case 20:
priodesc *= 1.55;
break;
}
c.add(Calendar.MINUTE,priodesc);
mbo.setValue("TARGCOMPDATE", c.getTime(), 2L);
}
Is that now clear?
try the following:
if (!getMboValue().isNull())
{
SqlFormat sqlpriority = new SqlFormat(mbo, " domainid='SR_CALCPRIO' and value=:1 ");
sqlpriority.setObject(1, "numericdomain", "value", prioprity);
MboRemote WORemote = mbo.getMboSet("$numericdom ain", "numericdomain", sqlpriority.format()).getM bo(0);
if (WORemote != null && !mbo.isNull("TARGSTARTDATE ")){
int priodesc = WORemote.getInt("DESCRIPTI ON");
Date targerstart = mbo.getDate("TARGSTARTDATE ");
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
if (prioprity==10) priodesc *= 1.35;
else if (prioprity==20) priodesc *= 1.55;
c.add(Calendar.MINUTE,prio desc);
mbo.setValue("TARGCOMPDATE ", c.getTime(), 2L);
}
if (!getMboValue().isNull())
{
SqlFormat sqlpriority = new SqlFormat(mbo, " domainid='SR_CALCPRIO' and value=:1 ");
sqlpriority.setObject(1, "numericdomain", "value", prioprity);
MboRemote WORemote = mbo.getMboSet("$numericdom
if (WORemote != null && !mbo.isNull("TARGSTARTDATE
int priodesc = WORemote.getInt("DESCRIPTI
Date targerstart = mbo.getDate("TARGSTARTDATE
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
if (prioprity==10) priodesc *= 1.35;
else if (prioprity==20) priodesc *= 1.55;
c.add(Calendar.MINUTE,prio
mbo.setValue("TARGCOMPDATE
}
Instead of
priodesc *= 1.35;
you need to do the following:
priodesc *= 1.35;
you need to do the following:
priodesc = (int)(priodesc * 1.35);
ASKER
objects
the == statment in the if is causing issues ,could you advise pls, te priority is declared as a string at the top
all help will do
the == statment in the if is causing issues ,could you advise pls, te priority is declared as a string at the top
all help will do
SOrry - didn't know it was String. You can do
if (WORemote != null && !mbo.isNull("TARGSTARTDATE")){
int priodesc = WORemote.getInt("DESCRIPTION");
Date targerstart = mbo.getDate("TARGSTARTDATE");
Calendar c = Calendar.getInstance();
c.setTime(targerstart);
switch(Integer.parseInt(WOPRIORITY)) {
case 10:
priodesc *= 1.35;
break;
case 20:
priodesc *= 1.55;
break;
}
c.add(Calendar.MINUTE,priodesc);
mbo.setValue("TARGCOMPDATE", c.getTime(), 2L);
}
And you'll need to make the adjustment i mentioned too:
priodesc = (int)(priodesc * 1.35); //etc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
lemme test it,thanks and great work! i app. it
Is that now clear rutgermons?
:-)
Open in new window