t10=new JTextField(10); t10.setBounds(400,85,90,20);
t2.setEditable(false); t3.setEditable(false); t5.setEditable(false); t7.setEditable(false);
b1=new JButton(\查询\);
b1.setBounds(300,120,60,20); b2=new JButton(\应付\);
b2.setBounds(425,120,60,20); b3=new JButton(\结账\);
b3.setBounds(300,180,60,20); b4=new JButton(\退出\);
b4.setBounds(425,180,60,20);
Container c=getContentPane(); c.setLayout(null); c.add(aa); c.add(t1); c.add(bb); c.add(t2); c.add(cc); c.add(t3); c.add(dd); c.add(t4); c.add(ee); c.add(t5); c.add(ff); c.add(t6); c.add(gg); c.add(t7); c.add(hh); c.add(t8); c.add(ii); c.add(t9); c.add(jj); c.add(t10); c.add(b1); c.add(b2); c.add(b3); c.add(b4);
15
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String id=t1.getText(); try {
Class.forName(\); Connection
Statement s=c.createStatement();
ResultSet stmt=s.executeQuery(\售货
c=DriverManager.getConnection(\);
where 商品ID='\+id+\); while(stmt.next())
try {
Class.forName(\); Connection
Statement s=c.createStatement();
ResultSet stmt=s.executeQuery(\售货
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String id=t1.getText(); String num=t4.getText(); }
}
catch(Exception w) { }
System.err.println(w); { }
s.close(); c.close();
t2.setText(\+stmt.getString(2)); t3.setText(\+stmt.getString(3));
});
c=DriverManager.getConnection(\);
16
where 商品ID='\+id+\); if(stmt.next())
b3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String pay=t6.getText(); String num=t4.getText(); String sid=t8.getText(); String cgh=t9.getText(); String date=t10.getText(); try {
Class.forName(\); Connection
Statement s=c.createStatement();
ResultSet stmt=s.executeQuery(\售货
String id=t1.getText(); }
{ }
catch(Exception w) { }
System.err.println(w);
t3.setText(\+stmt.getString(3)); String price=t3.getText(); float
t5.setText(\+pp);
pp=Float.parseFloat(price)*Float.parseFloat(num);
}
s.close(); c.close();
});
c=DriverManager.getConnection(\);
where 商品ID='\+id+\); if(stmt.next())
{
t2.setText(\+stmt.getString(2));
17
float
t7.setText(\+pl);
t3.setText(\+stmt.getString(3));
String price=t3.getText(); float
t5.setText(\+pp);
pl=Float.parseFloat(pay)-Float.parseFloat(t5.getText());
pp=Float.parseFloat(price)*Float.parseFloat(num);
}
s.executeUpdate(\售货
values('\+sid+\+id+\+t3.getText()+\+num+\+t5.getText()+\+cgh+\+date+\); }
b4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { }
dispose(); }
}
catch(Exception w) { }
System.err.println(w); s.close(); c.close();
});
});
setSize(580,300); setResizable(false); setVisible(true);}
6.2.3.3售货模块的触发器代码
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON go
ALTER TRIGGER [dbo].[saddcount] ON [dbo].[Sales] AFTER insert
18
AS BEGIN
declare @quantity float
declare @inventoryid char(6)
select @quantity=quantity,@inventoryid =inventoryid from inserted update inventory set inventory.quantity=inventory.quantity-@quantity inventory.inventoryid = @inventoryid; END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON go
ALTER TRIGGER [dbo].[sdelcount] ON [dbo].[Sales] AFTER delete AS BEGIN
declare @quantity float
declare @inventoryid char(6)
select @quantity=quantity,@inventoryid =inventoryid from deleted update inventory set inventory.quantity=inventory.quantity+@quantity inventory.inventoryid = @inventoryid; END
19
where
where