- /*
- * Copyright 1999,2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- package peaklau.eaglefund;
-
-
-
- import javax.microedition.lcdui.Alert;
- import javax.microedition.lcdui.AlertType;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.StringItem;
- import javax.microedition.lcdui.TextField;
-
-
- /**
- * User Interface for modifying one fund quota.<br>
- *
- *
- * @author peaklau <br>
- * email:<A HREF="mailto:peaklau@hotmail.com">peaklau@hotmail.com</A> <br>
- * <a href="http://www.peaklau.com/fund/english/">HomePage</a>
- * @version $Revision: 1.1 $ $Date: 2007/05/09 16:07:04 $
- */
-
- public class FundDoModifyScreen extends Form implements CommandListener {
- private Command back=new Command("返回",Command.BACK,1);
- private Command add=new Command("确认修改",Command.OK,1);
- private Alert alert=null;
-
- private INavigator navigator=null;
- private String codeID=null;
- private StringItem code=null;
- private TextField quantity=null;
-
- public FundDoModifyScreen(String codeID,INavigator navigator){
- super("修改基金");
- this.navigator=navigator;
- this.codeID=codeID;
- code=new StringItem("基金代码:",codeID);
- quantity=new TextField("份额(格式123.12):","",9,TextField.ANY);
-
- this.append(code);
- this.append(quantity);
-
- addCommand(add);
- addCommand(back);
- setCommandListener(this);
- alert=new Alert("提示信息");
- }
-
- public void commandAction(Command command, Displayable displayable) {
- if(command == back){
- if(navigator!=null){
- navigator.getDisplay().setCurrent(navigator.getDisplayable("fundModifyScreen"));
- }
- }else if(command == add){
- String squantity=quantity.getString();
- boolean error=false;
- for(int i=0;i<squantity.length();i++){
- char c=squantity.charAt(i);
- if(((c>='0')&&(c<='9'))||(c=='.')){
- }else{
- error=true;
- }
- }
- if(error){
- alert.setString("数量格式错误");
- alert.setType(AlertType.ERROR);
- navigator.getDisplay().setCurrent(alert,this);
- return;
- }
- int qquantity=0;
- int index=squantity.indexOf(".");
- if(index>=0){
- qquantity+=100*Integer.parseInt(squantity.substring(0,index));
- if(index+1<squantity.length()){
- qquantity+=10*Integer.parseInt(squantity.substring(index+1,index+2));
- }
- if(index+2<squantity.length()){
- qquantity+=Integer.parseInt(squantity.substring(index+2,index+3));
- }
- }else{
- if(squantity.length()==0){
- qquantity=0;
- }else{
- int tmp=Integer.parseInt(squantity);
- if(tmp>20000000){
- alert.setString("数量太大");
- alert.setType(AlertType.ERROR);
- navigator.getDisplay().setCurrent(alert,this);
- return;
- }
- qquantity=100*Integer.parseInt(squantity);
- }
- }
- String ccode=codeID;
- index=codeID.indexOf("(");
- if(index>0){
- ccode=codeID.substring(index+1,ccode.length()-1);
- }
-
- DataCenter.updateRecordQantity(ccode,qquantity);
- alert.setString("修改成功!");
- alert.setType(AlertType.INFO);
- navigator.getDisplay().setCurrent(alert,navigator.getDisplayable("valueScreen"));
- navigator.getCanvas("valueScreen").refresh();
- }
- }
-
- }