📄 jishutongji.java
字号:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.border.*;
public class Jishutongji extends JFrame implements ActionListener,ItemListener{
private DefaultTableModel philosophers;
private JTable table;
private JScrollPane jspn;
private JButton xianshi,dayin;
private Choice yewuyuanChoice;
private Choice nianChoice,yueChoice;
private Container con=null;
private Font font;
private Vector vec;
StringBuffer strbuf=new StringBuffer();
private String name,truename,where;
private JCheckBox zhengtitongji,mingxitongji;
private JRadioButton yiqianding,yijieqing,weijieqing;
private JTextField sqltt;
private JLabel label;
public Jishutongji(String name,String truename){
super("售后服务统计查询-------------------------------正在完善。。。。");
this.name=name;
this.truename=truename;
int iii=(int)(Toolkit.getDefaultToolkit().getScreenSize().getWidth());
if(iii==800){
font=new java.awt.Font("宋体",Font.PLAIN,12);
//labelBox2=new JLabel(" ");
setBounds(80,70,650,400);
}else{
font=new java.awt.Font("宋体",Font.PLAIN,14);
//labelBox2=new JLabel(" ");
setBounds(140,80,840,600);
}
Box box1=Box.createHorizontalBox();
yewuyuanChoice=new Choice();
String sql;
Connection dbConn;
Statement stat;
try {
Class.forName(Yewu.forName);
dbConn=DriverManager.getConnection(Yewu.jdbc);
stat=dbConn.createStatement();
//---------------------------------------------------------------------------
if(name.equals("master")||name.equals("root")){
sql="select distinct truename from zhuceTable where truename!=''";
}else{
sql="select distinct truename from zhuceTable where name='"+name+"'";
}
ResultSet resSetyewuname=stat.executeQuery(sql);
StringVector vec1=new StringVector();
while(resSetyewuname.next()){
vec1.add(resSetyewuname.getString("truename"));
}
yewuyuanChoice.add("全部技术员");
for(int i=0;i<vec1.size();i++){
yewuyuanChoice.add(vec1.get(i));
}
stat.close();
dbConn.close(); //关闭数据库连接
}catch(Exception ee){
ee.printStackTrace();
}
nianChoice=new Choice();
yueChoice=new Choice();
nianChoice.addItemListener(this);
yueChoice.addItemListener(this);
yueChoice.setEnabled(false);
String nian[]={"全部","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020"};
String yue[]={"全部","01","02","03","04","05","06","07","08","09","10","11","12"};
for(int i=0;i<nian.length;i++){
nianChoice.add(nian[i].toString());
}
for(int j=0;j<yue.length;j++){
yueChoice.add(yue[j].toString());
}
// yueChoice.add(yue);
xianshi=new JButton("显示查询结果");
xianshi.addActionListener(this);
dayin=new JButton("打印");
yiqianding=new JRadioButton("已签合同");
yijieqing=new JRadioButton("已结清");
weijieqing=new JRadioButton("未结清");
zhengtitongji=new JCheckBox("整体");
mingxitongji=new JCheckBox("明细");
zhengtitongji.setFont(font);
mingxitongji.setFont(font);
yiqianding.setFont(font);
yijieqing.setFont(font);
weijieqing.setFont(font);
zhengtitongji.addItemListener(this);
mingxitongji.addItemListener(this);
yiqianding.addItemListener(this);
yijieqing.addItemListener(this);
weijieqing.addItemListener(this);
dayin.addActionListener(this);
yiqianding.setSelected(true);
zhengtitongji.setSelected(true);
box1.add(yewuyuanChoice);
box1.add(yiqianding);
box1.add(yijieqing);
box1.add(weijieqing);
box1.add(zhengtitongji);
box1.add(mingxitongji);
box1.add(nianChoice);
box1.add(yueChoice);
box1.add(xianshi);
box1.add(dayin);
//====不显示的组件-----------------------
sqltt=new JTextField(10);
box1.add(sqltt);
sqltt.setVisible(false);
//---------------------------------------
Box box2=Box.createHorizontalBox();
label=new JLabel("全部业务员 入厂至今 信息/差旅/合同 整体统计");
Font font1=new java.awt.Font("宋体",Font.BOLD,14);
label.setFont(font1);
box2.add(label);
//Box boxW=Box.createVerticalBox();
// boxW.add(box2);
//boxW.setBorder(new TitledBorder("2.统计查询条件如下:"));
// boxW.add(Box.createVerticalGlue());
Box boxH=Box.createVerticalBox();
boxH.add(box1);
boxH.setBorder(new TitledBorder("1.选择统计查询条件:"));
boxH.add(Box.createVerticalGlue());
Box boxN=Box.createVerticalBox();
boxN.setFont(font);
boxN.add(boxH);
boxN.add(box2);
boxN.add(Box.createVerticalGlue());
JPanel pp=new JPanel();
pp.add(boxN);
//lurujsp=new JScrollPane(pp);
con=getContentPane();
con.validate();
con.setLayout(new BorderLayout());
con.add(pp,BorderLayout.NORTH);
setVisible( true );
this.addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==xianshi){
StringBuffer sss=new StringBuffer();
if(nianChoice.getSelectedItem().trim().equals("全部")){
sss.append("全部");
//sss.toString()="全部";
}
if(!(nianChoice.getSelectedItem().trim().equals("全部"))){
if(yueChoice.getSelectedItem().trim().equals("全部")){
sss.append(nianChoice.getSelectedItem().trim());
//sss.toString()=nianChoice.getSelectedItem().trim();
}else{
sss.append(nianChoice.getSelectedItem().trim()).append("-").append(yueChoice.getSelectedItem().trim());
//sss.toString()=nianChoice.getSelectedItem().trim()+"-"+yueChoice.getSelectedItem().trim();
}
}
StringBuffer buf=new StringBuffer();
philosophers = new DefaultTableModel();
Vector vec=new Vector();
if(mingxitongji.isSelected()){
vec.add("业务员");
vec.add("产品型号");
vec.add("签订日期");
vec.add("清收期限");
vec.add("合同总额");
vec.add("收款总额");
vec.add("尚欠货款");
vec.add("客户名称");
if(yewuyuanChoice.getSelectedItem().trim().equals("全部业务员")){
strbuf=new StringBuffer();
//strbuf.append("全部业务员");
if(sss.toString().equals("全部")){
//strbuf.append("入厂至今");
if(yiqianding.isSelected()){
where=" where hetongzonge!=''";
strbuf.append("所有签订合同统计");
}
if(yijieqing.isSelected()){
where=" where zhifuyue=0";
strbuf.append("账目结清合同统计");
}
if(weijieqing.isSelected()){
where=" where zhifuyue!=0";
strbuf.append("账目未结清合同统计");
}
buf=buf.append("select yewuname,xinghao,qiandingriqi,hetongqixian,hetongzonge,zhifuzonge,zhifuyue,kehuname from (select distinct yewuname,xinghao,qiandingriqi,hetongqixian,hetongzonge,(sum(zhifujine)) as 'zhifuzonge',(hetongzonge-sum(zhifujine)) as 'zhifuyue' ,kehuname from hetongTable group by yewuname,kehuname,hetongzonge,xinghao,qiandingriqi,hetongqixian) as tt ");
buf=buf.append(where);
}else{
strbuf.append(sss.toString());
if(yiqianding.isSelected()){
where=" where hetongzonge!=''";
strbuf.append(" 所有签订合同统计");
}
if(yijieqing.isSelected()){
where=" where zhifuyue=0";
strbuf.append(" 账目已结清合同统计");
}
if(weijieqing.isSelected()){
where=" where zhifuyue!=0";
strbuf.append(" 账目未结清合同统计");
}
buf=buf.append("select yewuname,xinghao,qiandingriqi,hetongqixian,hetongzonge,zhifuzonge,zhifuyue,kehuname from (select distinct yewuname,xinghao,qiandingriqi,hetongqixian, hetongzonge,(sum(zhifujine)) as 'zhifuzonge',(hetongzonge-sum(zhifujine)) as 'zhifuyue' ,kehuname from hetongTable where convert(nvarchar(10),qiandingriqi,121) like '%").append(sss.toString()).append("%' group by yewuname,kehuname,hetongzonge,xinghao,qiandingriqi,hetongqixian) as tt ");
buf=buf.append(where);
}
}else{
strbuf=new StringBuffer();
if(sss.toString().equals("全部")){
strbuf.append(yewuyuanChoice.getSelectedItem().trim());
if(yiqianding.isSelected()){
where=" where hetongzonge!=''";
strbuf.append(" 签订合同统计");
}
if(yijieqing.isSelected()){
where=" where zhifuyue=0";
strbuf.append(" 账目结清合同统计");
}
if(weijieqing.isSelected()){
where=" where zhifuyue!=0";
strbuf.append(" 账目未结清合同统计");
}
buf=buf.append("select yewuname,xinghao,qiandingriqi,hetongqixian,hetongzonge,zhifuzonge,zhifuyue,kehuname from (select distinct yewuname,xinghao,qiandingriqi,hetongqixian, hetongzonge,(sum(zhifujine)) as 'zhifuzonge',(hetongzonge-sum(zhifujine)) as 'zhifuyue' ,kehuname from hetongTable where yewuname='"+yewuyuanChoice.getSelectedItem().trim()+"' group by yewuname,kehuname,hetongzonge,xinghao,qiandingriqi,hetongqixian) as tt ");
buf=buf.append(where);
}else{
strbuf.append(yewuyuanChoice.getSelectedItem().trim()).append(" ").append(sss.toString());
if(yiqianding.isSelected()){
where=" where hetongzonge!=''";
strbuf.append(" 所有签订合同统计");
}
if(yijieqing.isSelected()){
where=" where zhifuyue=0";
strbuf.append(" 账目结清合同统计");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -