当前位置: 首页 > 面试题库 >

WAGU(表格视图中的数据)库中的修改

巩子实
2023-03-14
问题内容

提到post,其中Clough先生给出了答案,他已经编写了代码来获取这样的输出,

       PLATINUM COMPUTERS(PVT) LTD          
 NO 20/B, Main Street, Kandy, Sri Lanka.    
Land: 812254630 Mob: 712205220 Fax: 812254639

            CUSTOMER INVOICE

+-----------------------+----------------------+
|INFO                   |CUSTOMER              |
+-----------------------+----------------------+
|DATE: 2015-9-8         |ModernTec Distributors|
|TIME: 10:53:AM         |MOB: +94719530398     |
|BILL NO: 12            |ADDRES: No 25, Main St|
|INVOICE NO: 458-80-108 |reet, Kandy.          |
+-----------------------+----------------------+
|                SELLING DETAILS               |
+-----------------+---------+-----+------------+
|ITEM             | PRICE($)|  QTY|       VALUE|
+-----------------+---------+-----+------------+
|Optical mouse    |   120.00|   20|     2400.00|
|Gaming keyboard  |   550.00|   30|    16500.00|
|320GB SATA HDD   |   220.00|   32|     7040.00|
|500GB SATA HDD   |   274.00|   13|     3562.00|
|1TB SATA HDD     |   437.00|   11|     4807.00|
|RE-DVD ROM       |   144.00|   29|     4176.00|
|DDR3 4GB RAM     |   143.00|   13|     1859.00|
|Blu-ray DVD      |    94.00|   28|     2632.00|
|WR-DVD           |   122.00|   34|     4148.00|
|Adapter          |   543.00|   28|    15204.00|
+-----------------+---------+-----+------------+
|               RETURNING DETAILS              |
+-----------------+---------+-----+------------+
|ITEM             | PRICE($)|  QTY|       VALUE|
+-----------------+---------+-----+------------+
|320GB SATA HDD   |   220.00|    4|      880.00|
|WR-DVD           |   122.00|    7|      854.00|
|1TB SATA HDD     |   437.00|    7|     3059.00|
|RE-DVD ROM       |   144.00|    4|      576.00|
|Gaming keyboard  |   550.00|    6|     3300.00|
|DDR3 4GB RAM     |   143.00|    7|     1001.00|
+-----------------+---------+-----+------------+
                              GROSS   59,928.00 
                       DISCOUNT(5%)    2,996.40 
                             RETURN    9,670.00 
                            PAYABLE   47,261.60 
                               CASH   20,000.00 
                             CHEQUE   15,000.00 
                    CREDIT(BALANCE)   12,261.60


   ---------------------   --------------------- 
      CASH COLLECTOR         GOODS RECEIVED BY   
           soulution by clough.com

上面输出的代码如下:

String company = ""
            + "PLATINUM COMPUTERS(PVT) LTD\n"
            + "NO 20/B, Main Street, Kandy, Sri Lanka.\n"
            + "Land: 812254630 Mob: 712205220 Fax: 812254639\n"
            + " \n"
            + "CUSTOMER INVOICE\n"
            + " \n";
    List<String> t1Headers = Arrays.asList("INFO", "CUSTOMER");
    List<List<String>> t1Rows = Arrays.asList(
            Arrays.asList("DATE: 2015-9-8", "ModernTec Distributors"),
            Arrays.asList("TIME: 10:53:AM", "MOB: +94719530398"),
            Arrays.asList("BILL NO: 12", "ADDRES: No 25, Main Street, Kandy."),
            Arrays.asList("INVOICE NO: 458-80-108", "")
    );
    String t2Desc = "SELLING DETAILS";
    List<String> t2Headers = Arrays.asList("ITEM", "PRICE($)", "QTY", "VALUE");
    List<List<String>> t2Rows = Arrays.asList(
            Arrays.asList("Optical mouse", "120.00", "20", "2400.00"),
            Arrays.asList("Gaming keyboard", "550.00", "30", "16500.00"),
            Arrays.asList("320GB SATA HDD", "220.00", "32", "7040.00"),
            Arrays.asList("500GB SATA HDD", "274.00", "13", "3562.00"),
            Arrays.asList("1TB SATA HDD", "437.00", "11", "4807.00"),
            Arrays.asList("RE-DVD ROM", "144.00", "29", "4176.00"),
            Arrays.asList("DDR3 4GB RAM", "143.00", "13", "1859.00"),
            Arrays.asList("Blu-ray DVD", "94.00", "28", "2632.00"),
            Arrays.asList("WR-DVD", "122.00", "34", "4148.00"),
            Arrays.asList("Adapter", "543.00", "28", "15204.00")
    );
    List<Integer> t2ColWidths = Arrays.asList(17, 9, 5, 12);
    String t3Desc = "RETURNING DETAILS";
    List<String> t3Headers = Arrays.asList("ITEM", "PRICE($)", "QTY", "VALUE");
    List<List<String>> t3Rows = Arrays.asList(
            Arrays.asList("320GB SATA HDD", "220.00", "4", "880.00"),
            Arrays.asList("WR-DVD", "122.00", "7", "854.00"),
            Arrays.asList("1TB SATA HDD", "437.00", "7", "3059.00"),
            Arrays.asList("RE-DVD ROM", "144.00", "4", "576.00"),
            Arrays.asList("Gaming keyboard", "550.00", "6", "3300.00"),
            Arrays.asList("DDR3 4GB RAM", "143.00", "7", "1001.00")
    );
    String summary = ""
            + "GROSS\n"
            + "DISCOUNT(5%)\n"
            + "RETURN\n"
            + "PAYABLE\n"
            + "CASH\n"
            + "CHEQUE\n"
            + "CREDIT(BALANCE)\n";
    String summaryVal = ""
            + "59,928.00\n"
            + "2,996.40\n"
            + "9,670.00\n"
            + "47,261.60\n"
            + "20,000.00\n"
            + "15,000.00\n"
            + "12,261.60\n";
    String sign1 = ""
            + "---------------------\n"
            + "CASH COLLECTOR\n";
    String sign2 = ""
            + "---------------------\n"
            + "GOODS RECEIVED BY\n";
    String advertise = "soulution by clough.com";

    //bookmark
    Board b = new Board(48);
    b.setInitialBlock(new Block(b, 46, 7, company).allowGrid(false).setBlockAlign(Block.BLOCK_CENTRE).setDataAlign(Block.DATA_CENTER));
    b.appendTableTo(0, Board.APPEND_BELOW, new Table(b, 48, t1Headers, t1Rows));
    b.getBlock(3).setBelowBlock(new Block(b, 46, 1, t2Desc).setDataAlign(Block.DATA_CENTER));
    b.appendTableTo(5, Board.APPEND_BELOW, new Table(b, 48, t2Headers, t2Rows, t2ColWidths));
    b.getBlock(10).setBelowBlock(new Block(b, 46, 1, t3Desc).setDataAlign(Block.DATA_CENTER));
    b.appendTableTo(14, Board.APPEND_BELOW, new Table(b, 48, t3Headers, t3Rows, t2ColWidths));
    Block summaryBlock = new Block(b, 35, 9, summary).allowGrid(false).setDataAlign(Block.DATA_MIDDLE_RIGHT);
    b.getBlock(19).setBelowBlock(summaryBlock);
    Block summaryValBlock = new Block(b, 12, 9, summaryVal).allowGrid(false).setDataAlign(Block.DATA_MIDDLE_RIGHT);
    summaryBlock.setRightBlock(summaryValBlock);
    Block sign1Block = new Block(b, 24, 7, sign1).setDataAlign(Block.DATA_BOTTOM_MIDDLE).allowGrid(false);
    summaryBlock.setBelowBlock(sign1Block);
    sign1Block.setRightBlock(new Block(b, 24, 7, sign2).setDataAlign(Block.DATA_BOTTOM_MIDDLE).allowGrid(false));
    sign1Block.setBelowBlock(new Block(b, 48, 3, advertise).setDataAlign(Block.DATA_CENTER).allowGrid(false));
    //b.showBlockIndex(true);
    System.out.println(b.invalidate().build().getPreview());

现在,我面临的问题是我不希望发票中有“退货明细”部分。我只想添加公司标题部分而不是信息和客户部分,然后仅出售详细信息和总计。

我正在编写自己根据自己的要求进行更改的代码,但无法剪切返回详细信息部分和“签名”部分。下面是我的代码:

          String company = ""
            + "V.K Autos Larkana\n"
            + "Near Rehmaniya Masjid Larkana\n"
            + "Police Shopping Center Larkana\n"
            + "Cell: 0334-3269198, 0333-3910951\n"
            + " \n"
            + "CUSTOMER INVOICE\n"
            + " \n";

    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

    List<String> t1Headers = Arrays.asList("INFO", "CUSTOMER");
    List<List<String>> t1Rows = Arrays.asList(
            Arrays.asList("DATE: " + date + "", "" + txt_cnam.getText()),
            Arrays.asList("TIME: " + sdf.format(cal.getTime()) + "", "Bill No:" + billno + "")
    );
    String t2Desc = "SELLING DETAILS";
    List<String> t2Headers = Arrays.asList("ITEM", "QTY", "Rate", "Total");

    List<List<String>> t2Rows = new ArrayList<List<String>>();

    for (int i = 0; i < tbl_sale.getRowCount(); i++) {
        String pid = tbl_sale.getValueAt(i, 0).toString();
        String item = tbl_sale.getValueAt(i, 1).toString();
        String quant = tbl_sale.getValueAt(i, 2).toString();
        String rate = tbl_sale.getValueAt(i, 3).toString();
        String rs = tbl_sale.getValueAt(i, 4).toString();
        ArrayList<String> temp = new ArrayList<String>();
        temp.add(item);
        temp.add(quant);
        temp.add(rate);
        temp.add(rs);
        t2Rows.add(temp);
    }
    List<Integer> t2ColWidths = Arrays.asList(17, 9, 5, 12);
    String t3Desc = "Sub Total";
    List<String> t3Headers = Arrays.asList("", "", "", "");
    List<List<String>> t3Rows = Arrays.asList(
            Arrays.asList("WR-DVD", "122.00", "7", "854.00")
    );

    String summary = ""
            + "Sub Total\n";

    String summaryVal = ""
            + txt_total.getText() + "\n";
    String sign1 = ""
            + "------------Thank You-------------\n";
    String sign2 = ""
            + "-We value your visit-\n";
    String advertise = "-We value your visit-";
    try {
        Board b = new Board(48);
        b.setInitialBlock(new Block(b, 46, 7, company).allowGrid(false).setBlockAlign(Block.BLOCK_CENTRE).setDataAlign(Block.DATA_CENTER));
        b.appendTableTo(0, Board.APPEND_BELOW, new Table(b, 48, t1Headers, t1Rows));
        b.getBlock(3).setBelowBlock(new Block(b, 46, 1, t2Desc).setDataAlign(Block.DATA_CENTER));
        b.appendTableTo(5, Board.APPEND_BELOW, new Table(b, 48, t2Headers, t2Rows, t2ColWidths));
        b.getBlock(10).setBelowBlock(new Block(b, 46, 1, t3Desc).setDataAlign(Block.DATA_CENTER));
        b.appendTableTo(14, Board.APPEND_BELOW, new Table(b, 48, t3Headers, t3Rows, t2ColWidths));
        Block summaryBlock = new Block(b, 35, 3, summary).allowGrid(false).setDataAlign(Block.DATA_MIDDLE_RIGHT);
        b.getBlock(19).setBelowBlock(summaryBlock);
        Block summaryValBlock = new Block(b, 12, 3, summaryVal).allowGrid(false).setDataAlign(Block.DATA_MIDDLE_RIGHT);
        summaryBlock.setRightBlock(summaryValBlock);
        Block sign1Block = new Block(b, 24, 7, sign1).setDataAlign(Block.DATA_BOTTOM_MIDDLE).allowGrid(false);
        summaryBlock.setBelowBlock(sign1Block);
        sign1Block.setRightBlock(new Block(b, 24, 7, sign2).setDataAlign(Block.DATA_BOTTOM_MIDDLE).allowGrid(false));
        sign1Block.setBelowBlock(new Block(b, 48, 3, advertise).setDataAlign(Block.DATA_CENTER).allowGrid(false));
        System.out.println(b.invalidate().build().getPreview());

以上代码的输出为:

                  V.K Autos Larkana               
      Near Rehmaniya Masjid Larkana         
     Police Shopping Center Larkana         
    Cell: 0334-3269198, 0333-3910951

            CUSTOMER INVOICE

+-----------------------+----------------------+
|INFO                   |CUSTOMER              |
+-----------------------+----------------------+
|DATE: 2016/01/27       |Mohammad Rafi Abro    |
|TIME: 23:23:49         |Bill No:9             |
+-----------------------+----------------------+
|                SELLING DETAILS               |
+-----------------+---------+-----+------------+
|ITEM             |      QTY| Rate|       Total|
+-----------------+---------+-----+------------+
|nuts             |       50|   25|        1250|
+-----------------+---------+-----+------------+
|                   Sub Total                  |
+-----------------+---------+-----+------------+
|                 |         |     |            |
+-----------------+---------+-----+------------+
|WR-DVD           |   122.00|    7|      854.00|
+-----------------+---------+-----+------------+
                          Sub Total        1250


   ------------Thank You--------                        
    -We value your visit-
    -We value your visit-

但我想要这样的输出:

                  V.K Autos Larkana               
      Near Rehmaniya Masjid Larkana         
     Police Shopping Center Larkana         
    Cell: 0334-3269198, 0333-3910951

            CUSTOMER INVOICE

+-----------------------+----------------------+
|INFO                   |CUSTOMER              |
+-----------------------+----------------------+
|DATE: 2016/01/27       |Mohammad Rafi Abro    |
|TIME: 23:23:49         |Bill No:9             |
+-----------------------+----------------------+
|                SELLING DETAILS               |
+-----------------+---------+-----+------------+
|ITEM             |      QTY| Rate|       Total|
+-----------------+---------+-----+------------+
|nuts             |       50|   25|        1250|
+-----------------+---------+-----+------------+                  
                          Sub Total        1250

     ===== Thank you for your kind visit ===

而且我也想减小其宽度,当前板的宽度为48,但是当我将其值更改为40时,它也向我显示错误:(请任何人帮助我解决这个问题。


问题答案:

最终,我花了一整夜的时间编写代码:)好,感谢Clough先生提供的WAGU示例。

我的代码如下:

String company = ""
            + "V.K Autos Larkana\n"
            + "Near Rehmaniya Masjid Larkana\n"
            + "Police Shopping Center Larkana\n"
            + "Cell: 0334-3269198, 0333-3910951\n"
            + " \n"
            + "CUSTOMER INVOICE"
            + " ";

    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");

    List<String> t1Headers = Arrays.asList("INFO", "CUSTOMER");
    List<List<String>> t1Rows = Arrays.asList(
            Arrays.asList("DATE: " + date + "", "" + txt_cnam.getText()),
            Arrays.asList("TIME: " + sdf.format(cal.getTime()) + "", "Bill No:" + billno + "")
    );
    String t2Desc = "SELLING DETAILS";
    List<String> t2Headers = Arrays.asList("ITEM", "QTY", "Rate", "Total");

    List<List<String>> t2Rows = new ArrayList<List<String>>();

    for (int i = 0; i < tbl_sale.getRowCount(); i++) {
        String pid = tbl_sale.getValueAt(i, 0).toString();
        String item = tbl_sale.getValueAt(i, 1).toString();
        String quant = tbl_sale.getValueAt(i, 2).toString();
        String rate = tbl_sale.getValueAt(i, 3).toString();
        String rs = tbl_sale.getValueAt(i, 4).toString();
        ArrayList<String> temp = new ArrayList<String>();
        temp.add(item);
        temp.add(quant);
        temp.add(rate);
        temp.add(rs);
        t2Rows.add(temp);
    }
    List<Integer> t2ColWidths = Arrays.asList(16, 5, 7, 9);
    String t3Desc = "Sub Total";
    List<String> t3Headers = Arrays.asList("", "", "", "");
    List<List<String>> t3Rows = Arrays.asList(
            Arrays.asList("WR-DVD", "122.00", "7", "854.00")
    );

    String summary = ""
            + "Sub Total\n";

    String summaryVal = ""
            + txt_total.getText() + "\n";
    String sign1 = ""
            +"------Thank you for your visit------\n";
    String sign2 = ""
            + "-We value your visit-\n";
    String advertise = "******** Soulution by AbroSoft *******\n* abrosoft@outlook.com # 03337584273 *";
    try {
        Board b = new Board(48);
        b.setInitialBlock(new Block(b, 40, 6, company).allowGrid(true).setBlockAlign(Block.BLOCK_LEFT).setDataAlign(Block.DATA_CENTER));
        b.appendTableTo(0, Board.APPEND_BELOW, new Table(b, 42, t1Headers, t1Rows));
        b.getBlock(3).setBelowBlock(new Block(b, 40, 1, t2Desc).setDataAlign(Block.DATA_CENTER));
        b.appendTableTo(5, Board.APPEND_BELOW, new Table(b, 40, t2Headers, t2Rows, t2ColWidths));
        Block summaryBlock = new Block(b, 30, 1, summary).setDataAlign(Block.DATA_TOP_RIGHT);
        b.getBlock(10).setBelowBlock(summaryBlock);
        Block summaryValBlock = new Block(b, 9, 1, summaryVal).setDataAlign(Block.DATA_TOP_RIGHT);
        summaryBlock.setRightBlock(summaryValBlock);
        Block sign1Block = new Block(b, 40, 1, sign1).setDataAlign(Block.DATA_CENTER);
        b.getBlock(14).setBelowBlock(sign1Block);
        Block sign2Block = new Block(b, 40, 2, advertise).setDataAlign(Block.DATA_CENTER);
        b.getBlock(16).setBelowBlock(sign2Block);
        System.out.println(b.invalidate().build().getPreview());

现在的输出就像我需要的:)。输出如下:

  +----------------------------------------+      
  |            V.K Autos Larkana           |      
  |      Near Rehmaniya Masjid Larkana     |      
  |     Police Shopping Center Larkana     |      
  |    Cell: 0334-3269198, 0333-3910951    |      
  |                                        |      
  |            CUSTOMER INVOICE            |      
  +--------------------+-------------------+      
  |INFO                |CUSTOMER           |      
  +--------------------+-------------------+      
  |DATE: 2016/01/28    |Mohammad Rafi Abro |      
  |TIME: 15:31:15      |Bill No:10         |      
  +--------------------+-------------------+      
  |             SELLING DETAILS            |      
  +----------------+-----+-------+---------+      
  |ITEM            |  QTY|   Rate|    Total|      
  +----------------+-----+-------+---------+      
  |nuts            |   12|     25|      300|      
  |70 CC           |   12|   7000|    84000|      
  |125 CC          |   13|  95000|  1235000|      
  |12              |   25|   2500|    62500|      
  +----------------+-----+-------+---------+      
  |                     Sub Total|  1381800|      
  +------------------------------+---------+      
  |  ------Thank you for your visit------  |      
  +----------------------------------------+      
  | ******** Soulution by AbroSoft ******* |      
  | * abrosoft@outlook.com # 03337584273 * |      
  +----------------------------------------+

好吧,再次感谢



 类似资料:
  • 问题内容: 我开始学习javaFX,我需要用数据库中的数据填充表。我在网上阅读了很多代码,但没有找到我想要的东西。我读了这篇文章,但不知道如何实现最后一个功能。我阅读了一些其他代码来做到这一点,到目前为止,这是我的一些代码: 我希望你能帮帮我 问题答案: 我相信这会为您提供帮助: 在控制器类中执行以下操作: 并为每个要使用TableView操纵的实体(表)创建一个单独的Java文件POJO 我已经

  • 问题内容: 输入: 客户声称,查询某些数据时应用程序(.NET)返回的数据与客户直接查看数据表时返回的数据不同。 我了解可能有多种原因,并且在完全不同的地方。我的目的不是在这里解决问题,而是向经验丰富的DBA和DB开发人员询问是否: VIEW是否可能显示与基础表不匹配的数据? 有哪些可能的原因/原因? 如果表确实没有,视图上的UPDATE语句是否可以导致将来的SELECT返回“更新的”数据? 可能

  • 问题内容: 每次访问数据库记录时,什么是最合适的和最有效的存储视图计数的方法? 我有包含以下字段的表: 每个项目都有自己的永久链接:http : //domain.com/item_name 我希望能够使用此数据并在页面上显示一个。哪种方法最好? 方法一 在表中创建一个附加字段,并对其进行更新以增加视图计数: 方法B 创建一个包含以下字段的新表: 并在每次查看页面时将新记录添加到表中。 方法C 完

  • 我正在设计一个具有滚动视图的页面,其上方是表格视图(禁用滚动)。为此,我在这个问题中提到了答案 - 使UITableView不可滚动并调整高度以容纳所有单元格,但没有成功。 视图层次结构以及提供的约束- -主视图 -滚动视图< br >固定在主视图的所有边上(0,0,0,0),限制边距 -内容视图 固定到滚动视图(0,0,0,0),与主视图宽度相等,与主视图高度相等(优先级-250) -内容视图中

  • 问题内容: 我正在尝试为在表格视图单元格中按下的按钮运行一个动作。下面的代码在我的表视图控制器类中。 在我的UITableViewCell类的称为requestCell的插座中,该按钮已被描述为“是”。 我正在使用“解析”来保存数据,并且想在按下按钮时更新对象。我的objectIds数组可以正常工作,cell.yes.tag还会在日志中输出正确的数字,但是,为了正常运行查询,我无法将该数字输入“连

  • 问题内容: 我试图让表单元格在创建新行时显示字符串。但是所有行都是空的。有人知道我在做什么错吗?这是主要的类:包应用程序; 这是正常的并且可以正常工作,所以我认为您不必为此担心。 这是控制器类。我认为问题可能出在哪里。 这也是tableviewer所需的表类 你们知道什么地方可能出错,或者建议我如何只添加tableviewer,使其代码仍可与SceneBuilder中的其余fxml文件一起使用?