package Barber;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.Label;
import java.awt.event.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.StringTokenizer;
import Barber.Mainpage;
import javax.swing.JTextField;
import Barber.Customerinfo;
import javax.swing.JComboBox;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;
import java.awt.Color;
import javax.swing.JTextArea;
import java.awt.Font;
public class CustomerW extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JButton jButton1 = null;
private Label label = null;
private Label label1 = null;
private JButton jButton2 = null;
private Mainpage mainpage;
private JTextField jTextField = null;
private JButton jButton3 = null;
private Customerinfo customerinfo;
private JComboBox jComboBox = null;
private JComboBox jComboBox1 = null;
private Label label3 = null;
private String service_filename="service.ini"; // @jve:decl-index=0:
private String barber_filename="barber.ini";
private String datafile="data.txt";
private int customer_total_num=0; //顾客总数
private long customer_total_time=0;//秒钟
private int customer_total_queue=0;//顾客排队总长度
private int total_money=0;
private int grade1_money=0; //各个等级理发师营业额
private int grade2_money=0;
private int grade3_money=0;
private long need_time=0; //需要时间
private int barber_num=0; //理发师总数
private Service[] service=new Service[10];
private Barber[] barber=new Barber[50];
private Customer[] customer=new Customer[200];
private Customer[] customer_1=new Customer[200];
private Customer[] customer_2=new Customer[200];
private Customer[] customer_3=new Customer[200];
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JTextArea jTextArea = null;
/**
* This is the default constructor
*/
public CustomerW() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
this.setBounds(new Rectangle((screenWidth - 636)/ 2,(screenHeight - 537)/ 2, 636, 537));
this.setContentPane(getJContentPane());
this.setTitle("HIT理发店管理系统");
this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Barber/top.jpg")));
this.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
public void propertyChange(java.beans.PropertyChangeEvent e) {
if ((e.getPropertyName().equals("enabled"))) {
System.out.println("propertyChange(enabled)"); // TODO Auto-generated property Event stub "enabled"
}
}
});
readData();
}
public void readData() //读取文件内容
{
try
{
//初始化数组
for(int j=0;j<10;j++)//初始化service数组
{
service[j]=new Service();
}
for(int j=0;j<50;j++)
{
barber[j]=new Barber();
}
for(int j=0;j<200;j++)
{
customer[j]=new Customer();
}
for(int j=0;j<200;j++)
{
customer_3[j]=new Customer();
}
for(int j=0;j<200;j++)
{
customer_2[j]=new Customer();
}
for(int j=0;j<200;j++)
{
customer_1[j]=new Customer();
}
//初始化结束
BufferedReader in;
in=new BufferedReader(new FileReader("customer.txt"));
for(int i=0;i<200;i++)
{
String s="";
if((s=in.readLine())==null)
{
break;
}
StringTokenizer t=new StringTokenizer(s,",");
customer[i].setBarber_id(t.nextToken());
customer[i].setEnd_time(new Long(t.nextToken()).longValue());
customer[i].setIn_time(new Long(t.nextToken()).longValue());
customer[i].setOut_time(new Long(t.nextToken()).longValue());
customer[i].setStart_time(new Long(t.nextToken()).longValue());
if(t.nextToken().equals("true"))
customer[i].setState(true);
else
customer[i].setState(false);
customer[i].setDouliu(Integer.parseInt(t.nextToken()));
customer[i].setGrade(Integer.parseInt(t.nextToken()));
customer[i].setId(t.nextToken());
customer[i].setService(Integer.parseInt(t.nextToken()));
customer[i].setWait(Integer.parseInt(t.nextToken()));
}
in.close();
in=new BufferedReader(new FileReader("customer1.txt"));
for(int i=0;i<200;i++)
{
String s="";
if((s=in.readLine())==null)
{
break;
}
StringTokenizer t=new StringTokenizer(s,",");
customer_1[i].setBarber_id(t.nextToken());
customer_1[i].setEnd_time(new Long(t.nextToken()).longValue());
customer_1[i].setIn_time(new Long(t.nextToken()).longValue());
customer_1[i].setOut_time(new Long(t.nextToken()).longValue());
customer_1[i].setStart_time(new Long(t.nextToken()).longValue());
if(t.nextToken().equals("true"))
customer_1[i].setState(true);
else
customer_1[i].setState(false);
customer_1[i].setDouliu(Integer.parseInt(t.nextToken()));
customer_1[i].setGrade(Integer.parseInt(t.nextToken()));
customer_1[i].setId(t.nextToken());
customer_1[i].setService(Integer.parseInt(t.nextToken()));
customer_1[i].setWait(Integer.parseInt(t.nextToken()));
}
in.close();
in=new BufferedReader(new FileReader("customer2.txt"));
for(int i=0;i<200;i++)
{
String s="";
if((s=in.readLine())==null)
{
break;
}
StringTokenizer t=new StringTokenizer(s,",");
customer_2[i].setBarber_id(t.nextToken());
customer_2[i].setEnd_time(new Long(t.nextToken()).longValue());
customer_2[i].setIn_time(new Long(t.nextToken()).longValue());
customer_2[i].setOut_time(new Long(t.nextToken()).longValue());
customer_2[i].setStart_time(new Long(t.nextToken()).longValue());
if(t.nextToken().equals("true"))
customer_2[i].setState(true);
else
customer_2[i].setState(false);
customer_2[i].setDouliu(Integer.parseInt(t.nextToken()));
customer_2[i].setGrade(Integer.parseInt(t.nextToken()));
customer_2[i].setId(t.nextToken());
customer_2[i].setService(Integer.parseInt(t.nextToken()));
customer_2[i].setWait(Integer.parseInt(t.nextToken()));
}
in.close();
in=new BufferedReader(new FileReader("customer3.txt"));
for(int i=0;i<200;i++)
{
String s="";
if((s=in.readLine())==null)
{
break;
}
StringTokenizer t=new StringTokenizer(s,",");
customer_3[i].setBarber_id(t.nextToken());
customer_3[i].setEnd_time(new Long(t.nextToken()).longValue());
customer_3[i].setIn_time(new Long(t.nextToken()).longValue());
customer_3[i].setOut_time(new Long(t.nextToken()).longValue());
customer_3[i].setStart_time(new Long(t.nextToken()).longValue());
if(t.nextToken().equals("true"))
customer_3[i].setState(true);
else
customer_3[i].setState(false);
customer_3[i].setDouliu(Integer.parseInt(t.nextToken()));
customer_3[i].setGrade(Integer.parseInt(t.nextToken()));
customer_3[i].setId(t.nextToken());
customer_3[i].setService(Integer.parseInt(t.nextToken()));
customer_3[i].setWait(Integer.parseInt(t.nextToken()));
}
in.close();
in=new BufferedReader(new FileReader("data.txt"));
String d;
if((d=in.readLine())!=null)
{
StringTokenizer dd=new StringTokenizer(d,",");
customer_total_num=Integer.parseInt(dd.nextToken());
customer_total_time=Integer.parseInt(dd.nextToken());
评论0