ILOVA
package Klinika;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MyConnection {
public static Connection getConnection() {
try {
Connection con = null;
con = DriverManager.getConnection("jdbc:mysql://localhost/klinika?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Tashkent",
"root","");
return con;
} catch (SQLException ex) {
Logger.getLogger(MyConnection.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
package Klinika;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class LoginForm extends javax.swing.JFrame {
* Creates new form LoginForm
public LoginForm() {
initComponents();
this.setLocationRelativeTo(null);
}
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jPasswordField1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel1.setText("Login");
jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jLabel2.setText("Parol");
jButton1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton1.setText("Kirish");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
jButton2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton2.setText("Bekor qilish");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(61, 61, 61)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE))
.addGap(18, 18, 18)
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
String login = jTextField1.getText();
String pass = String.valueOf(jPasswordField1.getPassword());
PreparedStatement lg;
String query = "SELECT COUNT(*) as soni FROM `admin` WHERE login='" + login + "' and parol='" + pass + "'";
try {
lg = MyConnection.getConnection().prepareStatement(query);
ResultSet rt = lg.executeQuery(query);
while (rt.next()) {
int soni = rt.getInt("soni");
if (soni > 0) {
Klinika_kurs kurs = new Klinika_kurs();
kurs.setVisible(true);
kurs.pack();
kurs.setLocationRelativeTo(null);
kurs.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.dispose();
} else {
JOptionPane.showMessageDialog(null, "Login yoki parol xato!");
}
}
} catch (SQLException ex) {
Logger.getLogger(LoginForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.dispose();
}
package Klinika;
public class Klinika_kurs extends javax.swing.JFrame {
public Klinika_kurs() {
initComponents();
this.setLocationRelativeTo(null);
}
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jTextField1 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox<>();
jTextField2 = new javax.swing.JTextField();
jTextField3 = new javax.swing.JTextField();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jTextField4 = new javax.swing.JTextField();
jTextField5 = new javax.swing.JTextField();
jTextField6 = new javax.swing.JTextField();
jTextField7 = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jComboBox2 = new javax.swing.JComboBox<>();
jTextField8 = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Registratsiya");
setSize(new java.awt.Dimension(0, 0));
jTextField1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField1.setText("№");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Xodim", "Item 1", "Item 2", "Item 3", "Item 4" }));
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
}
});
jTextField2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jTextField2.setText("sana");
jTextField3.setText("F.I.SH");
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Erkak");
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Ayol");
jTextField4.setText("Tug'ilgan sanasi");
jTextField5.setText("Telefon raqami");
jTextField5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField5ActionPerformed(evt);
}
});
jTextField6.setText("Manzili");
jTextField7.setText("Kim tomonidan yuborilgan");
jTextPane1.setText("shikoyati");
jScrollPane1.setViewportView(jTextPane1);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "To'lov turi", "Item 1", "Item 2", "Item 3", "Item 4" }));
jTextField8.setText("Summa");
jButton1.setText("To'lash");
jButton2.setText("Saqlash");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setText("Bekor qilish");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
Do'stlaringiz bilan baham: |