Beispiel #1
0
 private void checkLogin() {
   // 对输入进行基本的合法非法判断
   String id = idTxt.getText();
   String passwd = String.valueOf(passwordTxt.getPassword());
   ResultMessage idResult = Utility.checkInputValid(id, 4, 14, false);
   ResultMessage passwdResult = Utility.checkInputValid(passwd, 5, 14, false);
   if (idResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的用户名" + idResult.toFriendlyString() + "!");
     return;
   } else if (passwdResult != ResultMessage.SUCCESS) {
     MyOptionPane.showMessageDialog(null, "输入的密码" + passwdResult.toFriendlyString() + "!");
     return;
   }
   // 登录验证
   ResultMessage loginresult = loginController.login(usertype.getSelectedIndex(), id, passwd);
   if (loginresult == ResultMessage.SUCCESS) {
     new HomeUI(loginController);
     frame.dispose();
   } else {
     if (loginresult == ResultMessage.WRONG_ID) {
       MyOptionPane.showMessageDialog(null, "用户名错误!");
       idTxt.setText("");
       passwordTxt.setText("");
     } else if (loginresult == ResultMessage.WRONG_PASSWD) {
       MyOptionPane.showMessageDialog(null, "密码错误!");
       passwordTxt.setText("");
     } else {
       MyOptionPane.showMessageDialog(null, "服务器未开启!");
     }
   }
 }
 protected void showCommodityInfo() {
   if (commodityTxt.getText() != null) {
     addCommodityVO = vomap.get(commodityTxt.getText());
     if (addCommodityVO != null) {
       currentId.setText(addCommodityVO.id);
       currentName.setText(addCommodityVO.name);
       currentModel.setText(addCommodityVO.model);
       currentSystemNum.setText(Integer.toString(addCommodityVO.number));
       hasCommodity = true;
     } else {
       MyOptionPane.showMessageDialog(frame, "请重新选择商品!");
     }
   }
 }
 /**
  * 添加商品
  *
  * @param key 商品
  * @param num 商品数量
  */
 protected void addCommodity(int num) {
   if (hasCommodity) {
     this.exceptionLineItemVO =
         new ExceptionLineItemVO(
             addCommodityVO.id,
             addCommodityVO.name,
             addCommodityVO.model,
             addCommodityVO.number,
             num);
     ;
     this.panel.addLineItem(this.exceptionLineItemVO);
   } else {
     MyOptionPane.showMessageDialog(frame, "请选择商品信息!");
   }
 }