summaryrefslogtreecommitdiffstats
path: root/Dozentenmodul/src/GUI/AddSoftware.java
blob: 1539e1de27a3b125da82049b926d195a0cecb006 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package GUI;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import javax.swing.JFrame;
import sql.sql;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JCheckBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import javax.swing.DefaultComboBoxModel;

@SuppressWarnings("serial")
public class AddSoftware extends JFrame {

	private final JPanel contentPanel = new JPanel();
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	@SuppressWarnings("rawtypes")
	JComboBox comboBox;
	JCheckBox checkBox;
	sql sql=new sql();
	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		try {
			AddSoftware dialog = new AddSoftware();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}*/

	/**
	 * Create the dialog.
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public AddSoftware() {
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		setTitle("Dozentenmodul");
		
			try {
				UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			} catch (ClassNotFoundException | InstantiationException
					| IllegalAccessException | UnsupportedLookAndFeelException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int top=(screenSize.height - 416) / 2;
		int left=(screenSize.width - 300) / 2;
		setBounds(left, top, 416, 300);
		//setBounds(100, 100, 288, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblNewLabel = new JLabel("Software hinzuf\u00FCgen");
			lblNewLabel.setFont(new Font("Dialog", Font.PLAIN, 14));
			lblNewLabel.setBounds(10, 11, 194, 25);
			contentPanel.add(lblNewLabel);
		}
		{
			JLabel lblHersteller = new JLabel("Hersteller: *");
			lblHersteller.setBounds(10, 47, 100, 20);
			contentPanel.add(lblHersteller);
		}
		{
			textField = new JTextField();
			textField.setBounds(120, 47, 270, 20);
			contentPanel.add(textField);
			textField.setColumns(10);
		}
		{
			JLabel lblNewLabel_1 = new JLabel("Name: *");
			lblNewLabel_1.setBounds(10, 78, 100, 20);
			contentPanel.add(lblNewLabel_1);
		}
		{
			textField_1 = new JTextField();
			textField_1.setColumns(10);
			textField_1.setBounds(120, 78, 270, 20);
			contentPanel.add(textField_1);
		}
		{
			JLabel lblVersion = new JLabel("Version: *");
			lblVersion.setBounds(10, 109, 100, 20);
			contentPanel.add(lblVersion);
		}
		{
			textField_2 = new JTextField();
			textField_2.setColumns(10);
			textField_2.setBounds(120, 109, 270, 20);
			contentPanel.add(textField_2);
		}
		{
			JLabel lblArchitektur = new JLabel("Architektur: *");
			lblArchitektur.setBounds(10, 140, 100, 20);
			contentPanel.add(lblArchitektur);
		}
		
		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"32-bit", "64-bit"}));
		comboBox.setBounds(120, 140, 135, 20);
		contentPanel.add(comboBox);
		
		JLabel lblLizenzpflichtig = new JLabel("Lizenzpflichtig: *");
		lblLizenzpflichtig.setBounds(10, 171, 100, 20);
		contentPanel.add(lblLizenzpflichtig);
		
		checkBox = new JCheckBox("");
		checkBox.setBounds(120, 167, 97, 23);
		contentPanel.add(checkBox);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						if(textField.getText().isEmpty()==false&&textField_2.getText().isEmpty()==false&&comboBox.getSelectedIndex()!=-1&&textField_1.getText().isEmpty()==false)
						{
						int Kosten=0;
						if(checkBox.isSelected()==true)
						{
							Kosten=1;
						}
						Connection con=sql.getConnection();
						sql.AddSoftware(con, textField_1.getText().toString(), textField_2.getText().toString(), comboBox.getSelectedItem().toString(), Kosten, textField.getText().toString());
						dispose();
						}else
						{
							JOptionPane.showMessageDialog(null, "Bitte geben Sie alle notwendigen Daten an!",
									"Error", JOptionPane.ERROR_MESSAGE);	
						}
					}
					
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Zur\u00FCck");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						dispose();
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
	}
}