⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 insertuserinfogui.java

📁 企业级的即时通软件。。java语言写的 这是服务端部份。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			{
				if(!(Tools.checkMsg(passwordField.getText(), 6, 10, false)))
	 			{
	 				JOptionPane.showMessageDialog(frame,"输入的密码不符合长度!","警告",JOptionPane.WARNING_MESSAGE,null);
	 				passwordField.setText("");
	 				return;
	 			}
			}
			if(passwordTwo.getText().length()==0)
				{
				JOptionPane.showMessageDialog(frame,"重复密码不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
				}
			else
			{
				if(!(Tools.checkMsg(passwordTwo.getText(), 6, 10, false)))
	 			{
	 				JOptionPane.showMessageDialog(frame,"输入的重复密码不符合长度!","警告",JOptionPane.WARNING_MESSAGE,null);
	 				passwordTwo.setText("");
	 				return;
	 			}
			}
			if(!passwordField.getText().equals(passwordTwo.getText()))
				{
				JOptionPane.showMessageDialog(frame,"重复密码和新密码不同!","警告",JOptionPane.WARNING_MESSAGE,null);
				passwordField.setText("");
				passwordTwo.setText("");
				return;
				}
			if(sex.equals(""))
			{
				JOptionPane.showMessageDialog(frame,"请选择性别!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
			}
			if(positionField.getText().length()==0)
			{
				JOptionPane.showMessageDialog(frame,"职务不能为空","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
			}else
			{
				if(!(positionField.getText().length()<=5))
				{
					JOptionPane.showMessageDialog(frame,"职务超过5个字符!","警告",JOptionPane.WARNING_MESSAGE,null);
					return;
				}
			}
			if((!(Tools.checkMsg(delField.getText(), 7, 12, true)))||delField.getText().length()==0)
			{
				JOptionPane.showMessageDialog(frame,"电话输入的不对,请确认是在7-12的数字!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
			}
			if((!(Tools.includeChar(emailField.getText(),'@')))||emailField.getText().length()==0)
			{
				JOptionPane.showMessageDialog(frame,"E_mail输入的格式不正确!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
			}
			if(!(Tools.checkMsg(textArea.getText(), 0, 30, false)))
			{
				JOptionPane.showMessageDialog(frame,"备注超过长度!","警告",JOptionPane.WARNING_MESSAGE,null);
				return;
			}
				
			String [] userinfo=UserBO.userhead(idField.getText());
			if(userinfo[0]!="F"){
				JOptionPane.showMessageDialog(frame, "该ID号已存在", "提示", JOptionPane.WARNING_MESSAGE);
				 idField.setText("");
				 idField.requestFocus();
				 return;
			}else{
				JOptionPane.showMessageDialog(frame, "可以使用", "提示", JOptionPane.WARNING_MESSAGE);
				idField.setEditable(false);
			}
						
						String year=(String)yearComboBox.getSelectedItem();
						String month=(String)monthComboBox.getSelectedItem();
						if(month.length()==1){
							month="0"+month;
						}
						String day=(String)dayComboBox.getSelectedItem();
						if(day.length()==1){
							day="0"+day;
						}
						String dept=(String)deptComboBox.getSelectedItem();
						String birth=year+month+day;
						String name=nameField.getText();
						String position=positionField.getText();
						String remark=textArea.getText();
						
						int i=UserBO.insertInfo(idField.getText(), name, passwordField.getText(), position, dept, sex, birth, delField.getText(), emailField.getText(), headpic, remark);
						if(i==1){
							JOptionPane.showMessageDialog(frame, "添加成功", "提示", JOptionPane.INFORMATION_MESSAGE);
						}else
						{
							JOptionPane.showMessageDialog(frame, "添加失败", "提示", JOptionPane.WARNING_MESSAGE);
						}
					}
		});
		commit.setText("提交");
		commit.setBounds(71, 421, 78, 27);
		frame.getContentPane().add(commit);

		final JButton butRe = new JButton();
		butRe.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				idField.setEditable(true);
				textArea.setText("");
				emailField.setText("");
				delField.setText("");
				passwordTwo.setText("");
				passwordField.setText("");
				nameField.setText("");
				idField.setText("");
			}
		});
		butRe.setText("重置");
		butRe.setBounds(171, 421, 77, 27);
		frame.getContentPane().add(butRe);

		head = new JButton();
		
		head.setBounds(336, 6, 49, 48);
		frame.getContentPane().add(head);

		final JButton button_2 = new JButton();
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				panel.setVisible(true);
			}
		});
		button_2.addMouseListener(new MouseAdapter() {
			public void mouseEntered(final MouseEvent e) {
				button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/0.gif"));
			}
			public void mouseExited(final MouseEvent e) {
				button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
			}
		});
		button_2.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/h7.gif"));
		button_2.setBounds(384, 27, 15, 27);
		frame.getContentPane().add(button_2);

		panel = new JPanel();
		panel.setLayout(new GridLayout(0, 1));
		panel.setBounds(336, 52, 45, 318);
		panel.setVisible(false);
		frame.getContentPane().add(panel);

		final JButton button_9 = new JButton();
		button_9.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_9.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t2.png";
			}
		});
		button_9.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t2.png"));
		panel.add(button_9);

		final JButton button_5 = new JButton();
		button_5.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_5.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t1.png";
			}
		});
		button_5.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t1.png"));
		panel.add(button_5);

		final JButton button_3 = new JButton();
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_3.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t3.png";
			}
		});
		button_3.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t3.png"));
		panel.add(button_3);

		final JButton button_4 = new JButton();
		button_4.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t7.png"));
		button_4.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_4.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t7.png";
			}
		});
		panel.add(button_4);

		final JButton button_6 = new JButton();
		button_6.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t4.png"));
		button_6.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_6.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t4.png";
			}
		});
		panel.add(button_6);

		final JButton button_7 = new JButton();
		button_7.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t5.png"));
		button_7.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_7.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t5.png";
			}
		});
		panel.add(button_7);

		final JButton button_8 = new JButton();
		button_8.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t6.png"));
		button_8.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_8.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t6.png";
			}
		});
		panel.add(button_8);

		final JButton button_10 = new JButton();
		button_10.setIcon(SwingResourceManager.getIcon(InsertUserInfoGUI.class, "/edu/sccp/chat/image/t8.png"));
		button_10.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				head.setIcon(button_10.getIcon());
				panel.setVisible(false);
				headpic="/edu/sccp/chat/image/t8.png";
			}
		});
			
		panel.add(button_10);

		final JButton button = new JButton();
		
		button.setText("检测ID");
		button.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				if(idField.getText().length()==0)
		 		{
		 			JOptionPane.showMessageDialog(frame,"用户名不能为空!","警告",JOptionPane.WARNING_MESSAGE,null);
		 			idField.setText("");
					return;
		 		}
		 		else
		 		{
		 			if(!(Tools.checkMsg(idField.getText(),8,10,true)))
		 			{
		 				JOptionPane.showMessageDialog(frame,"用户名输入格式不对,请确认输入的是数字并保持在8-10之内!","警告",JOptionPane.WARNING_MESSAGE,null);
		 				idField.setText("");
		 				return;
		 			}
		 		}
				String [] userinfo=UserBO.userhead(idField.getText());
				if(userinfo[0]!="F"){
					JOptionPane.showMessageDialog(frame, "该ID号已存在", "提示", JOptionPane.WARNING_MESSAGE);
					 idField.setText("");
					 idField.requestFocus();
				}else{
					JOptionPane.showMessageDialog(frame, "可以使用", "提示", JOptionPane.WARNING_MESSAGE);
					idField.setEditable(false);
				}
			}
		});
		button.setBounds(226, 7, 75, 25);
		frame.getContentPane().add(button);

		label_11 = new JLabel();
		label_11.setForeground(new Color(255, 0, 0));
		label_11.setBounds(226, 67, 82, 15);
		frame.getContentPane().add(label_11);

		label_12 = new JLabel();
		label_12.setForeground(new Color(255, 0, 0));
		label_12.setBounds(227, 96, 81, 15);
		frame.getContentPane().add(label_12);

		label_13 = new JLabel();
		label_13.setForeground(new Color(255, 0, 0));
		label_13.setBounds(226, 245, 87, 15);
		frame.getContentPane().add(label_13);

		label_14 = new JLabel();
		label_14.setForeground(new Color(255, 0, 0));
		label_14.setBounds(226, 271, 82, 15);
		frame.getContentPane().add(label_14);
		
		Tools.setFormat(label_11);
		Tools.setFormat(label_12);
		Tools.setFormat(label_13);
		Tools.setFormat(label_14);

		final JLabel label_15 = new JLabel();
		label_15.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
		label_15.setText("职务:");
		label_15.setBounds(0, 293, 64, 25);
		frame.getContentPane().add(label_15);

		positionField = new JTextField();
		positionField.setBounds(81, 293, 141, 26);
		frame.getContentPane().add(positionField);

		label_16 = new JLabel();
		label_16.setForeground(new Color(255, 0, 0));
		label_16.setBounds(226, 37, 82, 16);
		frame.getContentPane().add(label_16);

		final JButton button_1 = new JButton();
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(final ActionEvent e) {
				frame.dispose();
			}
		});
		button_1.setText("关闭");
		button_1.setBounds(263, 422, 77, 25);
		frame.getContentPane().add(button_1);
	}
	public void showGUI()
	{
		frame.setResizable(false);
		frame.setSize(410,482);
		frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		//new InsertUserInfoGUI().showGUI();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -