付费下载
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
管家婆家庭记账软件账务管理账务管理框相关类创已编写好的GUI分类管理界面 LedgerMngDialog.java到view包中在包中,创建实体类Ledger.javagjp_ledger的edeMngonrolleja *账务实体publicclassLedgerprivateintlid;账务privateStringparent父分类名privateStringsname;小分类名privateintsid;分类privateprivatedoublemoney;privateStringaccount;//账户privateStringcreatetime创建时间privateStringldesc;//账务说明…}弹出账务管理在MainFrameController#ledgerMng()方法中,创建账务管理窗口 *账务管理窗口 LedgerMngDialogextendsJDialogprotectedJTextFieldbeginDateTxtnewJTextField(6);//protectedJTextFieldendDateTxtnewJTextField(6);//结束查询时间protectedJComboBoxparentBox=newJComboBox();//父分类下拉列表protectedJComboBoxsortBox=newJComboBox();//小分类下拉列表protectedJTableledgerDataTable=newJTable();//账务数据列表protectedJLabelinMoneyTotalLabelnewJLabel("总收入:0.00元");protectedJLabelpayMoneyTotalLabelnewJLabel("总支出:0.00元privateJButtonqueryBtn=newJButton("查询");//查询按钮privateJButtonpieBtn=newJButton("收/支 privateJButtoncloseBtn=newJButton("关闭");privateJButtonaddBtn=newJButton("添加");privateJButtoneditBtnnewJButton("编辑");privateJButtondelBtn=newJButton("删除"); LedgerMngDialog(JFrameframe)super(frame,true);}protectedvoidinitDialog()}privatevoidinit(){this.setResizable(false设置窗体大小不可变this.setTitle("账务管理:");//设置标题this.setSize(680400按}private ponent()//设 标JLabeltitleLabel=newJLabel();titleLabel.setFont(newFont("宋体Font.ITALIC18));titleLabel.setBounds(280,20,165,20);起始日JLabelbeginDa abel=newJLabel("起始:"); abel.setBounds(30,70,60,28);this.beginDateTxt.setBounds(70,70,80, 结束日JLabelendDa abel=newJLabel("至:"); abel.setBounds(160,70,30,28);this.endDateTxt.setBounds(190,70,80,28);endDateTxt.setText(String.format("%tF",newDate())); 收支选JLabelinAndPayLabelnewJLabel("收/支:");inAndPayLabel.setBounds(280,70,50,28); boBoxModel(newString请选择收入支出收入支出this.parentBox.setBounds(320,70,90,28);收支项JLabelsortLabelnewJLabel("分类:");sortLabel.setBounds(420,70,50,28); boBoxModel(newString[]{"-请选择this.sortBox.setBounds(460,70,110,28);查询按queryBtn.setBounds(580,70,70,滚动面JScrollPanescrollPane=newJScrollPane();scrollPane.setBounds(30,100,620,160);选this.inMoneyTotalLabel.setBounds(400,260,120,28);inMoneyTotalLabel.setForeground(newjava.awt.Color(0,102,0));this.payMoneyTotalLabel.setBounds(530,260,120,payMoneyTotalLabel.setForeground(newjava.awt.Color(255,0,按addBtn.setBounds(30,290,140,28);editBtn.setBounds(270,290,140,28);delBtn.setBounds(510,290,140,28);//收支统计报表按钮pieBtn.setBounds(3033014028);关闭按closeBtn.setBounds(570,330,80,}*protectedLedgergetLedgerByTableRow(introw)}*protectedvoidsetTableModel(List<Ledger>ledgerList)StringcolNamesnewString[]ID收/支分类金额账户创建时间","说明"};String[]propNames=newString[]{"lid","parent","sname","money","account","createtime","ldesc"};if(ledgerList==null||ledgerList.size()==0){ledgerDataTable.setModel(newDefaultTableModel(newObject[][]{{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null},{null,null,null,null,null,null,null}}tryledgerDataTable.setModel(newListTableModel<Ledger>(ledgerList,Ledger.class,colNames,propNames));}catch(Exceptione){}}*给组件添 privatevoidaddListener(){queryBtn.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEventevt){}pieBtn.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt){}closeBtn.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt){}addBtn.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt){}editBtn.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt)}delBtn.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt){ }parentBox.addActionListener(newActionListener()publicvoidactionPerformed(ActionEventevt){}ledgerDataTable.addMouseListener(newMouseAdapter()publicvoidmouseClicked(MouseEvente)if(e.getButton()==1)if(e.getClickCount()>=2){}}}}*}} void* void* void * void*父分类变 void void*日期工具publicclassDateUtilspublicstaticintgetYear()return}publicstaticStringfirstdayByYear()intyear=returnyear+"-01-}publicstaticStringlastdayByYear()intyear=returnyear+"-12-publicstaticjava.sql.DatetoSQLDate(Stringstr)returnnew}publicstaticStringtoday()returndate2String(new}publicstaticStringdate2String(java.util.Datedate)returnString.format("%tF",}publicstaticjava.util.Datestring2Date(Stringstr){SimpleDateFormatsdf=newSimpleDateFormat("yyyy-MM-dd");try{returnreturn}catch(ParseExceptione)thrownewRuntimeException("日期字符格式错误:}}*publicstaticjava.util.DategetFirstDayOfMethod(){CalendarcCalendar.getInstance();//获取当前日期对象c.set(Calendar.DAY_OF_MONTH,1);//设置日期为1return}publicstaticjava.util.DategetLastDayOfMethod(){CalendarcCalendar.getInstance();//获取当前日期对象c.set(Calendar.DAY_OF_MONTH,return}}**publicclassDateChooserextends}*publicclassLedgerMngControllerLedgerMngDialogpublicLedgerMngController(JFrameframe)}publicvoidaddLedger()}publicvoideditLedger()}publicvoid edger()}publicvoidqueryLedger()}}publicvoidparentChange()}publicvoidpie()}}账务模块相关类dao数据层,创建类LedgerDao.java,给LedgerDao类添加一个成员变量QueryRunner对象,因为我们使用dbutils来操作数据库,所以在本项目中所有的DAOQueryRunner的成员变量;LedgerDaoservicedaoDao*publicclassLedgerDao//获取数据库连接池,得到操作表数据的对象QueryRunnerQueryRunnerqrnewQueryRunner(JDBCUtils.getDataSource());}Service*publicclassLedgerServiceprivateLedgerDaoledgerDao=new}下拉列表之间数据级现在弹出的账务管理框中,可以在下拉列表中选择“收/支”情况,当用户在选择-0List<Object>boxModel,再创建boxModel,然后设置给下拉列表对象;daoSortDao#queryAllSname()*publicclassSortDao…publicList<Object>Stringsql="selectsnamefromgjp_sort";Object[]params={};tryreturnqr.query(sql,newColumnListHandler(),}catch(SQLExceptione)thrownew}}publicList<Object>querySnameByParent(Stringparent){Stringsql="selectsnamefromgjp_sortwhereparent=?";Object[]params=tryreturnqr.query(sql,newColumnListHandler(),}catch(SQLExceptione)throwthrownew}}}ServiceSortService#queryAllSname()*publicclassSortService…daopublicList<Object>queryAllSname()//daoList<Object>allSname=return}}}*参数StringparentNamepublicList<Object>querySnameByParent(StringList<Object>list=return}Controller*publicclassLedgerMngControllerLedgerMngDialogprivateSortServicesortService=new…*关于下拉框的级联操作根据父分类选择的变化sort表中数据以publicpublicvoidparentChange()Stringparent=if(parent.equals("-请选择情况一请选择ObjectsortItems请选择elseif(parent.equals("收入/支出情况二收入/支出List<ObjectsortItemssortService.queryAllSname();sortItems.add(0,"-请选择-");}else情况三收入”或“支出List<ObjectsortItemssortService.querySnameByParent(parent);sortItems.add(0,"-请选择-");}}}添加账务添加账务框相关类创已编写好的GUI账务操作界面类 OperationLedgerDialog.java到view包 控制层,创建 AddLedgerController.java,继弹出添加账务添加账务框相关类详 *账务操作界面 OperationLedgerDialogextendsJDialogprotectedJComboBoxparentBoxnewJComboBox();//protectedJComboBoxsortBox=newJComboBox();//小分类下拉列表protectedJTextFieldaccountTxt=newJTextField();//账户文本框protectedJTextFieldmoneyTxt=newJTextField("0.0");//金额文本框protectedJTextFieldcreatetimeTxtnewJTextField();//创建日期文本框protectedJTextArealdescTxt=newJTextArea();//说明文本域protectedJLabeltitleLabelnewJLabel("需要子类设置privateJButtoncancelBtnnewJButton("取消privateJButtonsubmitBtnnewJButton("确定OperationLedgerDialog(JDialogdialog)super(dialog,}publicvoidinitDialog()}privatevoidinit(){this.setSize(400,450);}private ponent()标titleLabel.setFont(newjava.awt.Font("宋体018titleLabel.setBounds(160,10,120,选择"JLabelparentLabelnewJLabel("收/支:");parentLabel.setBounds(30,50,50,28); boBoxModel(newString请选择收入","支出"}));parentBox.setBounds(70,50,100,28);分JLabelsortLabelnewJLabel("分类:");sortLabel.setBounds(30,90,50,28); boBoxModel(newString请选择-"}));sortBox.setBounds(70,90,100,28);账JLabelaccountLabelnewJLabel("账户:");accountLabel.setBounds(30,130,50,28);accountTxt.setBounds(70,130,200,金JLabelmoneyLabelnewJLabel("金额:");moneyLabel.setBounds(30,170,50,28);moneyTxt.setBounds(70,170,100,28);moneyTxt.setHorizontalAlignment(JTextField.RIGHT文本右对齐时JLabelcreatetimeLabelnewJLabel("时间:");createtimeLabel.setBounds(30,210,50,28);createtimeTxt.setBounds(70,210,80,28);createtimeTxt.setText(String.format("%tF"
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026四川凉山州雷波县粮油贸易总公司面向社会招聘6人笔试备考试题及答案解析
- 2026年河北承德医学院公开选聘工作人员25名笔试备考题库及答案解析
- 2026上半年贵州事业单位联考遵义市招聘329人考试备考试题及答案解析
- 2026年乡村旅游开发实务培训
- 2026年大庆市中医医院招聘4人考试参考题库及答案解析
- 2026年AI数据标注质量控制培训
- 2026年水泥厂粉尘治理操作规范
- 2026年矿山爆破安全距离管理
- 2026年电竞赛事执行管理培训
- 2026年康复辅具适配技术培训
- 北京市顺义区2025-2026学年八年级上学期期末考试英语试题(原卷版+解析版)
- 英语A级常用词汇
- (二调)武汉市2025届高中毕业生二月调研考试 英语试卷(含标准答案)+听力音频
- 福建省龙岩市2024-2025学年高一上学期期末考试物理试卷(含答案)
- 汽车修理厂轮胎采购 投标方案(技术标 )
- 2023年7月浙江省普通高中学业水平考试(学考)化学试题
- DB3301-T 0461-2024 电动自行车停放充电场所消防安全管理规
- 小儿支气管炎护理课件
- NB-T 47013.15-2021 承压设备无损检测 第15部分:相控阵超声检测
- 打针协议免责书
- 四川省成都市八年级上学期物理期末考试试卷及答案
评论
0/150
提交评论