Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
import dao.ConnectionProvider;
import javax.swing.JOptionPane;
import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
/**
*
* @author ahsan
*/
public class Login extends javax.swing.JFrame {
/**
* Creates new form Login
*/
public Login() {
initComponents();
setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtUserName = new javax.swing.JTextField();
txtPassword = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
jButton3 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setAutoRequestFocus(false);
setBackground(new java.awt.Color(102, 0, 102));
setLocation(new java.awt.Point(0, 0));
setLocationByPlatform(true);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jLabel2.setText("Username");
getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 270, -1, -1));
jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
jLabel1.setForeground(new java.awt.Color(0, 0, 255));
jLabel1.setText("Login");
jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 170, 272, 61));
jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
jLabel3.setText("Password");
getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(490, 330, 100, -1));
txtUserName.setBackground(new java.awt.Color(0, 0, 0));
txtUserName.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
txtUserName.setForeground(new java.awt.Color(255, 255, 255));
getContentPane().add(txtUserName, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 270, 300, -1));
txtPassword.setBackground(new java.awt.Color(0, 0, 0));
txtPassword.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N
txtPassword.setForeground(new java.awt.Color(255, 255, 255));
txtPassword.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtPasswordActionPerformed(evt);
}
});
getContentPane().add(txtPassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(600, 330, 300, -1));
jButton1.setBackground(new java.awt.Color(255, 51, 51));
jButton1.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
jButton1.setForeground(new java.awt.Color(255, 255, 255));
jButton1.setText("Sign In");
jButton1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jButton1.setDefaultCapable(false);
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.setPreferredSize(new java.awt.Dimension(89, 25));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(700, 410, -1, -1));
jLabel4.setIcon(new javax.swing.ImageIcon("D:\Pharmacy management tools\Pharmacy Management System Images & Pattern\rafat vai.png")); // NOI18N
getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 170, -1, -1));
jButton3.setForeground(new java.awt.Color(255, 51, 51));
jButton3.setIcon(new javax.swing.ImageIcon("D:\Pharmacy management tools\cancel001-icon-front-side.png")); // NOI18N
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(1330, 0, 20, 20));
pack();
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String username =txtUserName.getText();
String password = txtPassword.getText();
int temp =0;
try {
Connection con = ConnectionProvider.getCon();
Statement stm = con.createStatement();
ResultSet rt = stm.executeQuery("select * from appuser where username='" + username + "' and password='" + password + "'");
while (rt.next()) {
temp = 1;
if (rt.getString("userRole").equals("Admin")) {
setVisible(false);
new AdminDashBoard(username).setVisible(true);
} else {
setVisible(false);
new PharmasistDashBoard(username).setVisible(true);
}
}
if (temp==0){
JOptionPane.showMessageDialog(null,"Incorrect Username or Password");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
private void txtPasswordActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
int a= JOptionPane.showConfirmDialog(null,"Are you sure to close?","Select",JOptionPane.YES_NO_OPTION);
if (a==0)
{
System.exit(a);// TODO add your handling code here:
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPasswordField txtPassword;
private javax.swing.JTextField txtUserName;
// End of variables declaration
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team