📄 manage_reckoning.java
字号:
package clinique;
import java.awt.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.Font;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import com.borland.dbswing.JdbTable;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.QueryDescriptor;
import com.borland.dx.dataset.Column;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.SQLException;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class manage_reckoning extends JPanel {
int x=-1;
String id;
String firstday;
String secondday;
public manage_reckoning() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
this.setLayout(null);
jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 18));
jLabel1.setText("帐单统计");
jLabel1.setBounds(new Rectangle(33, 16, 83, 39));
jScrollPane1.setBounds(new Rectangle(239, 30, 525, 211));
jLabel2.setText("病人姓名:");
jLabel2.setBounds(new Rectangle(51, 78, 72, 15));
jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
jLabel3.setText("帐单汇总:");
jLabel3.setBounds(new Rectangle(39, 236, 83, 15));
huizong.setBorder(BorderFactory.createLoweredBevelBorder());
huizong.setBounds(new Rectangle(422, 282, 305, 135));
lookname.setBounds(new Rectangle(140, 74, 72, 21));
lookn.setBounds(new Rectangle(54, 123, 67, 25));
lookn.setText("查询");
lookn.addActionListener(new manage_reckoning_lookname_actionAdapter(this));
quxiao1.setBounds(new Rectangle(146, 122, 69, 28));
quxiao1.setText("取消");
quxiao1.addActionListener(new manage_reckoning_quxiao1_actionAdapter(this));
price.setEditable(false);
price.setBounds(new Rectangle(138, 186, 65, 21));
jLabel4.setFont(new java.awt.Font("宋体", Font.BOLD, 12));
jLabel4.setText("所选单个病人费用:");
jLabel4.setBounds(new Rectangle(16, 191, 128, 15));
jLabel6.setText("年");
jLabel6.setBounds(new Rectangle(190, 319, 19, 15));
jLabel7.setText("月");
jLabel7.setBounds(new Rectangle(259, 316, 20, 15));
jLabel8.setText("日");
jLabel8.setBounds(new Rectangle(333, 318, 20, 15));
jLabel9.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
jLabel9.setText("到");
jLabel9.setBounds(new Rectangle(82, 320, 25, 15));
jLabel10.setText("日");
jLabel10.setBounds(new Rectangle(333, 284, 20, 15));
jLabel11.setText("年");
jLabel11.setBounds(new Rectangle(190, 285, 19, 15));
jLabel12.setText("月");
jLabel12.setBounds(new Rectangle(260, 284, 20, 15));
looktime.setBounds(new Rectangle(126, 357, 66, 25));
looktime.setText("查询");
looktime.addActionListener(new manage_reckoning_looktime_actionAdapter(this));
sum.setBounds(new Rectangle(67, 403, 94, 25));
sum.setText("汇总");
sum.addActionListener(new manage_reckoning_sum_actionAdapter(this));
quxiao2.setBounds(new Rectangle(241, 357, 72, 25));
quxiao2.setText("取消");
quxiao2.addActionListener(new manage_reckoning_quxiao2_actionAdapter(this));
jButton6.setBounds(new Rectangle(299, 403, 87, 25));
jButton6.setText("显示全部");
jButton6.addActionListener(new manage_reckoning_jButton6_actionAdapter(this));
delete.setBounds(new Rectangle(187, 403, 88, 25));
delete.setText("删除数据");
delete.addActionListener(new manage_reckoning_delete_actionAdapter(this));
database1.setConnection(new ConnectionDescriptor(
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=clinique",
"sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
queryDataSet1.setQuery(new QueryDescriptor(database1,
"select * from reckoning", null, true, Load.ALL));
jdbTable1.setBorder(BorderFactory.createEtchedBorder());
jdbTable1.setDataSet(queryDataSet1);
jdbTable1.setEditable(false);
jdbTable1.addMouseListener(new manage_reckoning_jdbTable1_mouseAdapter(this));
jLabel5.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
jLabel5.setText("从");
jLabel5.setBounds(new Rectangle(83, 285, 23, 15));
column3.setColumnName("medicine");
column3.setDataType(com.borland.dx.dataset.Variant.STRING);
column3.setPrecision(100);
column3.setTableName("reckoning");
column3.setWidth(8);
column3.setServerColumnName("MEDICINE");
column3.setSqlType(1);
column4.setColumnName("price");
column4.setDataType(com.borland.dx.dataset.Variant.BIGDECIMAL);
column4.setPrecision(19);
column4.setScale(4);
column4.setTableName("reckoning");
column4.setWidth(6);
column4.setServerColumnName("PRICE");
column4.setSqlType(3);
column6.setColumnName("doctor");
column6.setDataType(com.borland.dx.dataset.Variant.STRING);
column6.setPrecision(50);
column6.setTableName("reckoning");
column6.setWidth(8);
column6.setServerColumnName("DOCTOR");
column6.setSqlType(1);
column7.setColumnName("date");
column7.setDataType(com.borland.dx.dataset.Variant.DATE);
column7.setTableName("reckoning");
column7.setWidth(8);
column7.setServerColumnName("DATE");
column7.setSqlType(93);
fyear.setBounds(new Rectangle(116, 282, 60, 20));
syear.setBounds(new Rectangle(117, 315, 60, 20));
fmonth.setBounds(new Rectangle(214, 282, 32, 20));
smonth.setBounds(new Rectangle(214, 315, 32, 20));
fday.setBounds(new Rectangle(287, 281, 32, 20));
sday.setBounds(new Rectangle(287, 314, 32, 20));
column1.setColumnName("id");
column1.setDataType(com.borland.dx.dataset.Variant.INT);
column1.setRowId(true);
column1.setTableName("reckoning");
column1.setWidth(6);
column1.setServerColumnName("ID");
column1.setSqlType(4);
column5.setColumnName("number");
column5.setDataType(com.borland.dx.dataset.Variant.INT);
column5.setTableName("reckoning");
column5.setWidth(6);
column5.setServerColumnName("NUMBER");
column5.setSqlType(4);
column8.setColumnName("patientname");
column8.setDataType(com.borland.dx.dataset.Variant.STRING);
column8.setPrecision(50);
column8.setTableName("reckoning");
column8.setWidth(10);
column8.setServerColumnName("PATIENTNAME");
column8.setSqlType(1);
jLabel13.setText("元");
jLabel13.setBounds(new Rectangle(209, 190, 26, 15));
this.add(jLabel1);
this.add(huizong);
this.add(jScrollPane1);
this.add(lookname);
this.add(jLabel2);
this.add(jLabel3);
this.add(sday);
this.add(fyear);
this.add(syear);
this.add(jLabel9);
this.add(jLabel5);
this.add(jLabel11);
this.add(jLabel6);
this.add(fmonth);
this.add(smonth);
this.add(fday);
this.add(jLabel7);
this.add(jLabel12);
this.add(jLabel8);
this.add(jLabel10);
this.add(sum);
this.add(looktime);
this.add(jButton6);
this.add(quxiao1);
this.add(lookn);
this.add(delete);
this.add(quxiao2);
this.add(price);
this.add(jLabel4);
this.add(jLabel13);
jScrollPane1.getViewport().add(jdbTable1);
queryDataSet1.setColumns(new Column[] {column1, column8, column3,
column4, column5, column6, column7});
login z=new login();
if(!z.username.equals("admin"))
{
delete.setEnabled(false);
}
}
JLabel jLabel1 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
Database database1 = new Database();
QueryDataSet queryDataSet1 = new QueryDataSet();
JdbTable jdbTable1 = new JdbTable();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
JTextArea huizong = new JTextArea();
JTextField lookname = new JTextField();
JButton lookn = new JButton();
JButton quxiao1 = new JButton();
JTextField price = new JTextField();
JLabel jLabel4 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel9 = new JLabel();
JLabel jLabel10 = new JLabel();
JLabel jLabel11 = new JLabel();
JLabel jLabel12 = new JLabel();
JButton looktime = new JButton();
JButton sum = new JButton();
JButton quxiao2 = new JButton();
JButton jButton6 = new JButton();
JButton delete = new JButton();
JLabel jLabel5 = new JLabel();
Column column3 = new Column();
Column column4 = new Column();
Column column6 = new Column();
Column column7 = new Column();
JTextField fyear = new JTextField();
JTextField syear = new JTextField();
JTextField fmonth = new JTextField();
JTextField smonth = new JTextField();
JTextField fday = new JTextField();
JTextField sday = new JTextField();
Column column1 = new Column();
Column column5 = new Column();
Column column8 = new Column();
JLabel jLabel13 = new JLabel();
public void lookname_actionPerformed(ActionEvent e) {
if(lookname.getText().length()==0)
{
JOptionPane.showMessageDialog(null,"请输入你要查询的关键字!");
lookname.requestFocus();
}
else if(!lookname.getText().equals(""))
{
queryDataSet1.close();
queryDataSet1.setQuery(new QueryDescriptor(database1,
"select * from reckoning where patientname=\'" +
lookname.getText() + "\'", null, true,
Load.ALL));
jdbTable1.setDataSet(queryDataSet1);
queryDataSet1.refresh();
if(queryDataSet1.getRowCount()==0)
{
JOptionPane.showMessageDialog(null,"你要查询的帐单信息不存在");
}
}
}
public void quxiao1_actionPerformed(ActionEvent e) {
lookname.setText("");
price.setText("");
}
public void jdbTable1_mouseClicked(MouseEvent e) {
x=1;
int n;
int s;
int x;
x=jdbTable1.getSelectedRow();
id=""+jdbTable1.getValueAt(x,0);
String pri;
float sum;
String num;
n=jdbTable1.getSelectedRow();
pri=String.valueOf(jdbTable1.getValueAt(n,3));
num=String.valueOf(jdbTable1.getValueAt(n,4));
sum=Float.parseFloat(pri)*Float.parseFloat(num);
price.setText(""+sum);
}
public void looktime_actionPerformed(ActionEvent e) {
firstday=fyear.getText()+"-"+fmonth.getText()+"-"+fday.getText();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -