⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderentryframe.java

📁 java在线商店的源代码。编写十分规范的哦
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    txtOrderDate.setDataSet(dm.getOrderDataSet());
    lblOrderTrackNum.setText(res.getString("OEF_OrderTrack_No"));
    lblCustomerPONum.setText(res.getString("OEF_PO_No"));
    btnSaveShipTo.setText(res.getString("OEF_Save_as_Default"));
    pnlOrderItemButtons.setLayout(gridBagLayout12);
    pnlOrderItemStatus.setLayout(gridBagLayout11);
    btnAddOrderItem.setForeground(Color.blue);
    btnAddOrderItem.setText(res.getString("OEF_Add_Item"));
    btnAddOrderItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnAddOrderItem_actionPerformed(e);
      }
    });
    btnRemoveOrderItem.setForeground(Color.red);
    btnRemoveOrderItem.setText(res.getString("OEF_Remove_Item"));
    statusBarOrder.setOpaque(true);
    statusBarOrder.setDataSet(dm.getOrderDataSet());
    statusBarOrderItem.setDataSet(dm.getOrderItemDataSet());
    lblOrderItemStatus.setText(res.getString("OEF_Order_Item"));
    gridLayout1.setRows(3);
    gridLayout1.setColumns(2);
    btnRemoveOrderItem.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnRemoveOrderItem_actionPerformed(e);
      }
    });
    btnSaveShipTo.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnSaveShipTo_actionPerformed(e);
      }
    });
    lblShipDate.setText(res.getString("OEF_Ship_Date"));
    pnlBillToButtons.setLayout(gridBagLayout13);
    btnFindCustomer.setText(res.getString("OEF_Find_"));
    btnFindCustomer.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnFindCustomer_actionPerformed(e);
      }
    });
    btnNewCustomer.setText(res.getString("OEF_New_"));
    btnNewCustomer.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        btnNewCustomer_actionPerformed(e);
      }
    });
    imgLogo.setHorizontalAlignment(SwingConstants.CENTER);
    imgLogo.setVerticalAlignment(SwingConstants.CENTER);
    imgLogo.setIcon(new ImageIcon(this.getClass().getResource("images/logo_sml.gif")));
    contentPane.setLayout(borderLayout1);
    contentPane.add(pnlOrder, BorderLayout.NORTH);
    pnlOrder.add(pnlBillTo, new GridBagConstraints(0, 1, 1, 2, 100.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pnlBillTo.add(txtCustomerName, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlBillTo.add(txtCustomerID, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 8), 0, 0));
    pnlBillTo.add(txtBillAddr1, new GridBagConstraints(0, 2, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlBillTo.add(txtBillAddr2, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlBillTo.add(txtBillCity, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlBillTo.add(txtBillState, new GridBagConstraints(1, 4, 1, 2, 1.0, 0.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 0), 0, 0));
    pnlBillTo.add(txtBillPostalCode, new GridBagConstraints(2, 4, 1, 2, 1.0, 0.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 8), 0, 0));
    pnlBillTo.add(txtBillCountry, new GridBagConstraints(0, 5, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlBillTo.add(lblBillTo, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlBillTo.add(pnlBillToButtons, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 8), 20, 0));
    pnlBillToButtons.add(btnNewCustomer, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 50, 0));
    pnlBillToButtons.add(btnFindCustomer, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 2, 0, 0), 50, 0));
    pnlOrder.add(pnlShipTo, new GridBagConstraints(1, 1, 1, 2, 100.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pnlShipTo.add(txtShipName, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlShipTo.add(txtShipAddr1, new GridBagConstraints(0, 2, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlShipTo.add(txtShipAddr2, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlShipTo.add(txtShipCity, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlShipTo.add(txtShipState, new GridBagConstraints(1, 4, 1, 2, 1.0, 0.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 0), 0, 0));
    pnlShipTo.add(txtShipPostalCode, new GridBagConstraints(2, 4, 1, 2, 1.0, 0.0
            ,GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 8, 8), 0, 0));
    pnlShipTo.add(txtShipCountry, new GridBagConstraints(0, 5, 3, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlShipTo.add(lblShipTo, new GridBagConstraints(0, 0, 2, 1, 100.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlShipTo.add(btnSaveShipTo, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, -8, 0, 8), 0, 0));
    pnlOrder.add(pnlTop, new GridBagConstraints(0, 0, 2, 1, 100.0, 100.0
            ,GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pnlTop.add(pnlNavigator, new GridBagConstraints(0, 0, 1, 1, 100.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0));
    pnlNavigator.add(jdbNavToolBar1, new GridBagConstraints(0, 0, 2, 1, 100.0, 100.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 4, 4, 4), 0, 0));
    pnlNavigator.add(lblID, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0));
    pnlNavigator.add(txtID, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    pnlTop.add(pnlDate, new GridBagConstraints(1, 0, 1, 3, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlDate.add(lblDate, null);
    pnlDate.add(txtOrderDate, null);
    pnlDate.add(lblOrderTrackNum, null);
    pnlDate.add(txtOrderTrackNum, null);
    pnlDate.add(lblCustomerPONum, null);
    pnlDate.add(txtCustomerPONum, null);
    contentPane.add(pnlMiddle, BorderLayout.CENTER);
    pnlMiddle.add(pnlOrderInfo, BorderLayout.NORTH);
    pnlOrderInfo.add(txtCreditCardNum, new GridBagConstraints(2, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(cboPayMethod, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(cboShipMethod, new GridBagConstraints(4, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(cboStatus, new GridBagConstraints(5, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(lblCreditCardNum, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(lblPayMethod, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(lblShipMethod, new GridBagConstraints(4, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(lblStatus, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 0), 0, 0));
    pnlOrderInfo.add(txtShipDate, new GridBagConstraints(6, 1, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlOrderInfo.add(lblShipDate, new GridBagConstraints(6, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 8, 0, 8), 0, 0));
    pnlMiddle.add(pnlOrderItems, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(tblOrderItems);
    pnlOrderItems.add(jScrollPane1, BorderLayout.CENTER);
    pnlOrderItems.add(pnlOrderItemStatus, BorderLayout.SOUTH);
    pnlOrderItemStatus.add(statusBarOrderItem, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
    pnlOrderItemStatus.add(pnlOrderItemButtons, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    pnlOrderItemButtons.add(btnAddOrderItem, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 25, 0));
    pnlOrderItemButtons.add(btnRemoveOrderItem, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    pnlMiddle.add(pnlBottom, BorderLayout.SOUTH);
    pnlBottom.add(pnlButtons, new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pnlButtons.add(btnSave, new GridBagConstraints(0, 0, 1, 1, 100.0, 100.0
            ,GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    pnlButtons.add(btnCancel, new GridBagConstraints(0, 1, 1, 1, 100.0, 100.0
            ,GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    pnlButtons.add(btnClose, new GridBagConstraints(0, 2, 1, 1, 100.0, 100.0
            ,GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    pnlBottom.add(pnlTotals, new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    pnlTotals.add(lblSubTotal, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlTotals.add(lblTax, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlTotals.add(txtSubTotal, new GridBagConstraints(4, 0, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlTotals.add(txtTax, new GridBagConstraints(5, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    pnlTotals.add(txtTaxPercent, new GridBagConstraints(4, 1, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlTotals.add(txtShipping, new GridBagConstraints(5, 2, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    pnlTotals.add(lblShipping, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlTotals.add(txtAmtPaid, new GridBagConstraints(4, 3, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlTotals.add(txtAmtDue, new GridBagConstraints(4, 4, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlTotals.add(lblAmtPaid, new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlTotals.add(lblAmtDue, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 8, 0, 0), 0, 0));
    pnlTotals.add(txtShipPercent, new GridBagConstraints(4, 2, 1, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 0), 0, 0));
    pnlBottom.add(imgLogo, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    contentPane.add(statusBarOrder, BorderLayout.SOUTH);
    pnlOrderItemStatus.add(lblOrderItemStatus, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
  }

  /**
   * We created this method to separate code to initialize database and
   * data-aware controls, which otherwise would go in the jbInit() method. Note
   * that by doing so, the properties set here are not visible to the property
   * inspector. And setting any properties via the inspector will add code to
   * jbInit() instead of here.
   *
   * @throws Exception exception
   */
  private void initData() throws Exception {
    qdsOrder      = dm.getOrderDataSet();
    qdsOrderItem  = dm.getOrderItemDataSet();
    qdsPayMethod  = dm.getPayMethodDataSet();
    qdsShipMethod = dm.getShipMethodDataSet();
    qdsStatus     = dm.getStatusDataSet();
    qdsCustomer   = dm.getCustomerDataSet();
    qdsProduct    = dm.getProductDataSet();

    qdsOrder.open();
    qdsOrderItem.open();
    qdsPayMethod.open();
    qdsShipMethod.open();
    qdsStatus.open();
    qdsCustomer.open();
    qdsProduct.open();

    // Display the Tax percent and Shipping percent
    txtTaxPercent.setText((DataModule1.TAXPERCENT * 100) + "%" );
    txtShipPercent.setText((DataModule1.SHIPPERCENT * 100) + "%");

  }

  /**
   * Class method to access the singleton instance of the class.
   *
   * @return OrderEntryFrame
   */
  public static OrderEntryFrame getOrderEntryFrame() {
    if (myOrderEntryFrame == null)
      myOrderEntryFrame = new OrderEntryFrame();

    return myOrderEntryFrame;
  }

  /**
   * Method to insert a new customer order record.
   * Useful for inserting a new order from other forms in
   * the application.
   */
  public void newOrder() {
    try {
      // Open the dataset if not already opened.
      qdsOrder.open();
      qdsOrderItem.open();
      // Insert a new Order record at the end of the
      // dataset
      qdsOrder.insertRow(false);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * Method to insert a new customer order record and setting the customer ID
   * that is passed as the parameter customerID. Useful for inserting a new
   * order from other forms in the application.
   *
   * @param customerID int
   *
   */
  public void newOrder(int customerID) {
    try {
      // Open the dataset if not already opened.
      qdsOrder.open();
      qdsOrderItem.open();
      // Insert a new Order record at the end of the
      // dataset
      qdsOrder.insertRow(false);
      qdsOrder.setInt("CUSTOMERID", customerID);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * Method to locate an order given the order ID. If matching record is found,
   * the dataset cursor is positioned on the matching record, and returns true
   * boolean result. Useful for locating order record from other forms in the
   * application.
   *
   * @param orderID int
   * @return boolean
   */
  public boolean locateOrder(int orderID) {
    boolean found = false;
    try {
      // Define a DataRow to hold the orderID to look for
      // the Order Dataset. Open the dataset if not opened.
      qdsOrder.open();
      DataRow locateRow = new DataRow(qdsOrder, "ID");
      locateRow.setInt("ID", orderID);

      found = qdsOrder.locate(locateRow, Locate.FIRST);
    }
    catch (Exception e) {
      e.printStackTrace();
    }

    return found;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -