📄 message.java
字号:
{
PasswordTrange1 pt1=new PasswordTrange1();
pt1.setVisible(true);
}
if("打印此表".equals(e.getActionCommand()))
{
if(temp==1)//此处便可以充分体现temp的作用,因为temp等于1,从上可知,其显示的是第一个版面,下面就打印的是第一个表
{
printTable(jtb1);
}
if(temp==2)
{
printTable(jtb2);
}
if(temp==3)
{
printTable(jtb3);
}
if(temp==4)
{
printTable(jtb4);
}
if(temp==5)
{
printTable(jtb5);
}
}
if("员工意见".equals(e.getActionCommand()))
{
NewsBox news=new NewsBox();
news.setVisible(true);
}
if("添加".equals(e.getActionCommand()))
{
Add add=new Add();
add.setVisible(true);
}
if("修改".equals(e.getActionCommand()))
{
if(temp==1&&row1()>=0||temp==2&&row2()>=0||temp==3&&row3()>=0||temp==4&&row4()>=0||temp==5&&row5()>=0)
{
Modify mdf=new Modify();
mdf.setVisible(true);
}
else
{
String str1="所选值为空!";
String str2="请选择所要修改的元素!";
Alert alert=new Alert(str1,str2);
alert.setVisible(true);
}
}
if("删除".equals(e.getActionCommand()))
{
if(temp==1&&row1()>=0)
{
//temp=1,与上面订单相对应,处理数据库orderform也就是订单的内容,以下雷同
String sq1="delete from orderform where id='"+(row1()+1)+"'";
trange(sq1);
for(i=row1()+1;i!=0&&i<=max(sql1);i++)
{
String s1="update orderform set id='"+i+"' where id='"+(i+1)+"'";
trange(s1);
}
renew(sql1,dtb1);
System.out.println(temp);
}
else if(temp==2&&row2()>=0)
{
String sq2="delete from reckoning where id='"+(row2()+1)+"'";
trange(sq2);
for(i=row2()+1;i!=0&&i<=max(sql2);i++)
{
String s2="update reckoning set id='"+i+"' where id='"+(i+1)+"'";
trange(s2);
}
renew(sql2,dtb2);
System.out.println(temp);
}
else if(temp==3&&row3()>=0)
{
String sq3="delete from message where id='"+(row3()+1)+"'";
trange(sq3);
for(i=row3()+1;i!=0&&i<=max(sql3);i++)
{
String s3="update message set id='"+i+"' where id='"+(i+1)+"'";
trange(s3);
}
renew(sql3,dtb3);
System.out.println(temp);
}
else if(temp==4&&row4()>=0)
{
int j=row4()+1;
String sq4="delete from staffmessage where id='"+(row4()+1)+"'";
trange(sq4);
//删除之后,将其id号重新按自然数顺序排列
for(i=row4()+1;i!=0&&i<=max(sql4);i++)
{
String s4="update staffmessage set id='"+i+"' where id='"+(i+1)+"'";
trange(s4);
}
renew(sql4,dtb4);
//在删除了某员工信息后,将其以其名为帐号与密码一同删除,避免外人的登录
String sq41="delete from staff where id='"+j+"'";
trange(sq41);
for(i=j;i!=0&&i<=max(sql4)+1;i++)
{
String s41="update staff set id='"+i+"' where id='"+(i+1)+"'";
trange(s41);
}
System.out.println(temp);
}
else if(temp==5&&row5()>=0)
{
String sq5="delete from duty where id='"+(row5()+1)+"'";
trange(sq5);
for(i=row5()+1;i!=0&&i<=max(sql5);i++)
{
String s5="update duty set id='"+i+"' where id='"+(i+1)+"'";
trange(s5);
}
renew(sql5,dtb5);
System.out.println(temp);
}
else
{
String str1="所选值为空!";
String str2="请选择所要删除的元素!";
Alert alert=new Alert(str1,str2);
alert.setVisible(true);
}
}
if("查找".equals(e.getActionCommand()))
{
Search sch=new Search();
sch.setVisible(true);
}
if("返回".equals(e.getActionCommand()))
{
card1.next(jp0);//使jp0回到有修改,添加等的操作界面
if(temp==1)
{
renew(sql1,dtb1);//同时刷新表格,回复原来的数据形式
}
if(temp==2)
{
renew(sql2,dtb2);
}
if(temp==3)
{
renew(sql3,dtb3);
}
if(temp==4)
{
renew(sql4,dtb4);
}
if(temp==5)
{
renew(sql5,dtb5);
}
}
if("退出".equals(e.getActionCommand()))
{
setVisible(false);
}
}
//实现修改的函数
public class Modify extends JFrame implements ActionListener
{
JTextField j12;
JTextField j13;
JTextField j14;
JTextField j15;
JTextField j16;
JTextField j17;
JTextField j18;
JTextField j22;
JTextField j23;
JTextField j24;
JTextField j25;
JTextField j26;
JTextField j27;
JTextField j28;
JTextField j32;
JTextField j33;
JTextField j34;
JTextField j35;
JTextField j36;
JTextField j37;
JTextField j42;
JTextField j43;
JTextField j44;
JTextField j45;
JTextField j46;
JTextField j47;
JTextField j48;
JTextField j49;
JTextField j40;
JTextField j52;
JTextField j53;
JTextField j54;
JTextField j55;
JTextField j56;
JButton b1 = new JButton("确定");
JButton b2 = new JButton("取消");
public Modify()
{
setSize(350,300);
setLocation(350,300);
if(temp==1)
{
set1();
}
if(temp==2)
{
set2();
}
if(temp==3)
{
set3();
}
if(temp==4)
{
set4();
}
if(temp==5)
{
set5();
}
}
//该函数实现该类的布局形式
public void set1()
{
//获取要修改的行的信息,以方便修改
j12=new JTextField(dtb1.getValueAt(row1(), 1).toString());
j13=new JTextField(dtb1.getValueAt(row1(), 2).toString());
j14=new JTextField(dtb1.getValueAt(row1(), 3).toString());
j15=new JTextField(dtb1.getValueAt(row1(), 4).toString());
j16=new JTextField(dtb1.getValueAt(row1(), 5).toString());
j17=new JTextField(dtb1.getValueAt(row1(), 6).toString());
j18=new JTextField(dtb1.getValueAt(row1(), 7).toString());
Container c=getContentPane();
c.setLayout(new GridLayout(8,2,5,5));
JLabel l2=new JLabel("客 户");
JLabel l3=new JLabel("货 物");
JLabel l4=new JLabel("订 金");
JLabel l5=new JLabel("总 金 额");
JLabel l6=new JLabel("订 货 日");
JLabel l7=new JLabel("取 货 日");
JLabel l8=new JLabel("备 注");
c.add(l2);c.add(j12);
c.add(l3);c.add(j13);
c.add(l4);c.add(j14);
c.add(l5);c.add(j15);
c.add(l6);c.add(j16);
c.add(l7);c.add(j17);
c.add(l8);c.add(j18);
c.add(b1);c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void set2()
{
j22=new JTextField(dtb2.getValueAt(row2(), 1).toString());
j23=new JTextField(dtb2.getValueAt(row2(), 2).toString());
j24=new JTextField(dtb2.getValueAt(row2(), 3).toString());
j25=new JTextField(dtb2.getValueAt(row2(), 4).toString());
j26=new JTextField(dtb2.getValueAt(row2(), 5).toString());
j27=new JTextField(dtb2.getValueAt(row2(), 6).toString());
j28=new JTextField(dtb2.getValueAt(row2(), 7).toString());
Container c=getContentPane();
c.setLayout(new GridLayout(8,2,5,5));
JLabel l2=new JLabel("贷 款");
JLabel l3=new JLabel("还 款");
JLabel l4=new JLabel("支 出");
JLabel l5=new JLabel("收 入");
JLabel l6=new JLabel("盈 利");
JLabel l7=new JLabel("日 期");
JLabel l8=new JLabel("备 注");
c.add(l2);c.add(j22);
c.add(l3);c.add(j23);
c.add(l4);c.add(j24);
c.add(l5);c.add(j25);
c.add(l6);c.add(j26);
c.add(l7);c.add(j27);
c.add(l8);c.add(j28);
c.add(b1);c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void set3()
{
j32=new JTextField(dtb3.getValueAt(row3(), 1).toString());
j33=new JTextField(dtb3.getValueAt(row3(), 2).toString());
j34=new JTextField(dtb3.getValueAt(row3(), 3).toString());
j35=new JTextField(dtb3.getValueAt(row3(), 4).toString());
j36=new JTextField(dtb3.getValueAt(row3(), 5).toString());
j37=new JTextField(dtb3.getValueAt(row3(), 6).toString());
Container c=getContentPane();
c.setLayout(new GridLayout(7,2,5,5));
JLabel l2=new JLabel("产 品 编 号");
JLabel l3=new JLabel("尺寸大小(码)");
JLabel l4=new JLabel("生产总数(双)");
JLabel l5=new JLabel("价 格 (元)");
JLabel l6=new JLabel("颜 色");
JLabel l7=new JLabel("备 注");
c.add(l2);c.add(j32);
c.add(l3);c.add(j33);
c.add(l4);c.add(j34);
c.add(l5);c.add(j35);
c.add(l6);c.add(j36);
c.add(l7);c.add(j37);
c.add(b1);c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void set4()
{
j42=new JTextField(dtb4.getValueAt(row4(), 1).toString());
j43=new JTextField(dtb4.getValueAt(row4(), 2).toString());
j44=new JTextField(dtb4.getValueAt(row4(), 3).toString());
j45=new JTextField(dtb4.getValueAt(row4(), 4).toString());
j46=new JTextField(dtb4.getValueAt(row4(), 5).toString());
j47=new JTextField(dtb4.getValueAt(row4(), 6).toString());
j48=new JTextField(dtb4.getValueAt(row4(), 7).toString());
j49=new JTextField(dtb4.getValueAt(row4(), 8).toString());
j40=new JTextField(dtb4.getValueAt(row4(), 9).toString());
Container c=getContentPane();
c.setLayout(new GridLayout(10,2,5,5));
JLabel l2=new JLabel("姓 名");
JLabel l3=new JLabel("职 位");
JLabel l4=new JLabel("薪 金");
JLabel l5=new JLabel("上 班 时 间");
JLabel l6=new JLabel("假 期");
JLabel l7=new JLabel("入 厂 时 间");
JLabel l8=new JLabel("家 庭 住 址");
JLabel l9=new JLabel("出 生 年 月");
JLabel l0=new JLabel("备 注");
c.add(l2);c.add(j42);
c.add(l3);c.add(j43);
c.add(l4);c.add(j44);
c.add(l5);c.add(j45);
c.add(l6);c.add(j46);
c.add(l7);c.add(j47);
c.add(l8);c.add(j48);
c.add(l9);c.add(j49);
c.add(l0);c.add(j40);
c.add(b1);c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void set5()
{
j52=new JTextField(dtb5.getValueAt(row5(), 1).toString());
j53=new JTextField(dtb5.getValueAt(row5(), 2).toString());
j54=new JTextField(dtb5.getValueAt(row5(), 3).toString());
j55=new JTextField(dtb5.getValueAt(row5(), 4).toString());
j56=new JTextField(dtb5.getValueAt(row5(), 5).toString());
Container c=getContentPane();
c.setLayout(new GridLayout(6,2,5,5));
JLabel l2=new JLabel("员 工");
JLabel l3=new JLabel("出 勤 情 况");
JLabel l4=new JLabel("员 工 表 现");
JLabel l5=new JLabel("日 期");
JLabel l6=new JLabel("备 注");
c.add(l2);c.add(j52);
c.add(l3);c.add(j53);
c.add(l4);c.add(j54);
c.add(l5);c.add(j55);
c.add(l6);c.add(j56);
c.add(b1);c.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -