Esempio n. 1
0
 public void start() {
   t4.setText("");
   t5.setText("");
   t2.setText("");
   t3.setText("");
   /*
   if(makeConnection()){
   try{
   st=cn.createStatement();
   String sql="select count(clavec) as nombre from detalle_compras";
   ResultSet rs=st.executeQuery(sql);
   System.out.println();
   while(rs.next()){
   String a=rs.getInt(1)+"";
   a=a.replace("SQLServerResultSet:","");
   cc=Integer.parseInt(a)+1;
   t1.setText("Co-"+cc);
   }
   }
   catch(Exception ez){
   System.out.println(ez.getMessage());
   }
   }
   else{}
   */
   t4.setText(time.programa());
 }
Esempio n. 2
0
 public boolean isValidUser() throws SQLException {
   CreateJDBCConnection jdbc = new CreateJDBCConnection();
   Statement stmt = jdbc.getStatement();
   stmt.execute("use jana;");
   String sqlQuery =
       "select password from user_details where idno = '" + nameText.getText() + "';";
   ResultSet rs = stmt.executeQuery(sqlQuery);
   while (rs.next()) {
     if (rs.getString("password").equals(passText.getText())) return true;
   }
   return false;
 }
Esempio n. 3
0
  Jf() {

    j.setBounds(500, 40, 500, 500);
    j.setVisible(true);
    j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    j.setLayout(null);
    ImageIcon image = new ImageIcon("im1.jpg");
    JLabel l = new JLabel(image);
    int m = image.getIconWidth();
    int m1 = image.getIconHeight();
    j.setResizable(false); // frame resize nahi hoga	
    l.setBounds(0, 0, m, m1);
    j.add(l);
    l.add(linfo);
    l.add(lid);
    l.add(fid);
    l.add(lpass);
    l.add(fpass);
    fpass.setEchoChar('*');

    l.add(blogin);
    l.add(bnewaccount);
    l.add(bforget);

    ImageIcon image1 = new ImageIcon("logo1.png");
    JLabel limage = new JLabel(image1);
    l.add(limage);
    limage.setBounds(10, 50, 190, 130);

    Font f = new Font("ALGERIAN", Font.BOLD, 20);
    linfo.setFont(f);
    linfo.setBounds(40, 10, 420, 30);
    lid.setBounds(210, 50, 70, 30);
    fid.setBounds(290, 50, 150, 30);
    lpass.setBounds(210, 90, 70, 30);
    fpass.setBounds(290, 90, 150, 30);
    blogin.setBounds(210, 130, 100, 50);
    bnewaccount.setBounds(320, 130, 160, 20);
    bforget.setBounds(320, 160, 160, 20);
    blogin.setBackground(Color.green);
    bnewaccount.setBackground(Color.cyan);
    bforget.setBackground(Color.pink);

    blogin.addActionListener(new Login());
    bnewaccount.addActionListener(new Account());
    bforget.addActionListener(new Forget());
  }
Esempio n. 4
0
 public LoginScreen(final Home hm) {
   setSize(600, 550);
   setLayout(null);
   this.hm = hm;
   name = new Label("Username : "******"Password :"******"login");
   login.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           try {
             if (isValidUser()) {
               hm.removeAll();
               hm.userId = nameText.getText();
               hm.p2 = new BaseApplet(hm);
               hm.p2.setBounds(0, 50, 600, 550);
               hm.add(hm.p2);
               hm.revalidate();
             } else {
               JOptionPane.showMessageDialog(
                   null, "Invalid Credentials", "Alert", JOptionPane.OK_OPTION);
             }
           } catch (Exception e1) {
             System.out.println("Error");
           }
         }
       });
   login.setBounds(200, 150, 100, 30);
   add(login);
 }
Esempio n. 5
0
  public Deta_Ventas_r() {
    setBackground(Color.gray);
    setLayout(null);
    setSize(400, 400);
    l1 = new Label(" clave ");
    t1 = new TextField(36);
    l2 = new Label("Vendedor");
    t2 = new TextField(20);

    l3 = new Label("Cliente");
    t3 = new TextField(20);
    l4 = new Label("Fechas");
    t4 = new TextField(5);
    l5 = new Label("monto_final");
    t5 = new TextField(5);
    t4.setEditable(false);
    t5.setEditable(false);
    b = new Button("Registrar");
    add(l1);
    add(t1);
    add(l2);
    add(t2);
    add(l3);
    add(t3);
    add(l4);
    add(t4);
    add(l5);
    add(t5);
    add(b);
    l1.setBounds(24, 75, 71, 23);
    l2.setBounds(24, 103, 90, 23);
    l3.setBounds(24, 131, 90, 23);
    l4.setBounds(24, 159, 90, 23);
    l5.setBounds(24, 185, 90, 23);
    t1.setBounds(114, 75, 270, 23);
    t2.setBounds(114, 103, 270, 23);
    t3.setBounds(114, 131, 270, 23);
    t4.setBounds(114, 159, 270, 23);
    t5.setBounds(114, 185, 270, 23);
    b.setBounds(167, 215, 65, 23);
    b.addActionListener(this);
    setUndecorated(true);
    setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - 200, 50);
    start();
  }
Esempio n. 6
0
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == b) {
     if (makeConnection()) {
       if (!t1.getText().equals("")
           & !t2.getText().equals("")
           & !t3.getText().equals("")
           & !t4.getText().equals("")) {
         det dez = new det();
         if (dez.date(t4.getText())) {
           String a = t1.getText();
           String b = t2.getText();
           String c = t3.getText();
           String d = t4.getText();
           String ef = t5.getText();
           try {
             st = cn.createStatement();
             String sql = "insert into detalle_ventas values('";
             sql += a;
             sql += "', '";
             sql += b + "', '" + c + "', '" + d + "', '" + ef;
             sql += "')";
             int eaz = st.executeUpdate(sql);
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Se han creado " + eaz + " registros en la base de datos",
                 "informacion",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
             start();
           } catch (SQLException exz) {
             javax.swing.JOptionPane.showMessageDialog(
                 null,
                 "Ha ocurrido un error, favor de checar que la clave no ha sido ingresada ya con anterioridad  \n si el problema persiste contacte con el administrador \nError: "
                     + exz.getSQLState()
                     + ""
                     + exz.getMessage(),
                 "Error",
                 javax.swing.JOptionPane.INFORMATION_MESSAGE);
           } catch (Exception ez) {
             System.out.println(ez.getMessage());
           }
         } else {
           javax.swing.JOptionPane.showMessageDialog(
               null,
               "Favor de llenar la fecha con un formato correcto dd/mm/aaaa",
               "Error!!!",
               javax.swing.JOptionPane.ERROR_MESSAGE);
         }
       } else {
         javax.swing.JOptionPane.showMessageDialog(
             null,
             "Favor de llenar todos los datos correctamente",
             "Error!!!",
             javax.swing.JOptionPane.ERROR_MESSAGE);
       }
     } else {
       javax.swing.JOptionPane.showMessageDialog(
           null,
           "Un error ha ocurrido al intentar conectar con la base de datos, \n reinicie el componente o contacte con el administrador",
           "Error",
           javax.swing.JOptionPane.ERROR_MESSAGE);
     }
   }
   try {
     cn.close();
   } catch (Exception esa) {
     System.out.println(esa.getMessage());
   }
 }
Esempio n. 7
0
  public void actionPerformed(ActionEvent ae) {

    String s1 = ae.getActionCommand();

    if (s1.equals("Calendar")) {
      // DatePicker dp=new DatePicker(f);
      // dp.displayDate();
      // f.getContentPane().add(p);

      b3.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              t6.setText(new DatePicker(f).setPickedDate());
            }
          });

    } else if (s1.equals("LogOut")) {
      f.dispose();
      start p = new start();
      p.method();

    } else if (s1.equals("Search")) {

      try {
        String data = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");
        Statement stm = con.createStatement();
        ResultSet rs = stm.executeQuery("select * from mprofile  where Manager_Id='" + data + "' ");
        while (rs.next()) {
          String a2 = rs.getString(1);
          t2.setText(a2);
          String a3 = rs.getString(2);
          t3.setText(a3);
          String a4 = rs.getString(3);
          t4.setText(a4);

          String a5 = rs.getString(4);
          t5.setText(a5);

          String a6 = rs.getString(6);
          t6.setText(a6);

          String a7 = rs.getString(7);
          t7.setText(a7);

          String a8 = rs.getString(8);
          t8.setText(a8);

          String a9 = rs.getString(9);
          t9.setText(a9);

          String a10 = rs.getString(10);
          t10.setText(a10);

          p.add(l3);
          p.add(t2);
          p.add(l4);
          p.add(t3);
          p.add(l5);
          p.add(t4);
          p.add(l6);
          p.add(t5);
          p.add(l7);
          p.add(c1);
          p.add(c2);
          p.add(l8);
          p.add(t6);
          p.add(l9);
          p.add(t7);
          p.add(l10);
          p.add(t8);
          p.add(l11);
          p.add(t9);
          p.add(l12);
          p.add(t10);
          p.add(b2);
          p.add(b3);
          p.add(b4);
        }
      } catch (Exception e) {
      }

    } else if (s1.equals("Update")) {

      String y2 = t2.getText();
      String y3 = t3.getText();
      String update_id = t4.getText();
      String y4 = t5.getText();
      String y6 = t6.getText();
      String y7 = t7.getText();
      String y8 = t8.getText();
      String y9 = t9.getText();
      String y10 = t10.getText();
      try {
        String y = t1.getSelectedItem();
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection("jdbc:odbc:raman1");

        PreparedStatement ps =
            con.prepareStatement(
                "update mprofile  set Location=? , E_Mail_Id=? ,Contact_No =?, Address=?, D_O_B=?,Gender=?, Password=?, Manager_Id=?,manager_father=?,manager_name=? where  Manager_Id='"
                    + y
                    + "'  ");

        ps.setString(1, y10);
        ps.setString(2, y9);
        ps.setString(3, y8);
        ps.setString(4, y7);
        ps.setString(5, y6);
        ps.setString(6, g);
        ps.setString(7, y4);
        ps.setString(8, update_id);
        ps.setString(9, y3);
        ps.setString(10, y2);

        ps.executeUpdate();
        JOptionPane.showMessageDialog(p, "data has been updated");
        f.dispose();
        project p = new project();
        p.method();
      } catch (Exception e) {
        System.out.println(e);
      }
    } else if (s1.equals("Close")) {
      f.dispose();
    } else {
      f.dispose();
      project p = new project();
      p.method();
    }
  }
Esempio n. 8
0
  void launch() {
    f.setSize(800, 800);
    p.setLayout(null);

    l1.setBounds(600, 10, 150, 36);

    l2.setBounds(100, 30, 400, 70);
    l13.setBounds(2, 90, 1200, 20);

    l14.setBounds(80, 150, 250, 30);
    t1.setBounds(330, 150, 150, 30);
    b1.setBounds(500, 150, 100, 30);
    l15.setBounds(2, 200, 1200, 20);

    b6.setBounds(600, 50, 100, 30);
    l3.setBounds(100, 250, 100, 30);
    t2.setBounds(300, 250, 150, 30);
    l4.setBounds(100, 300, 150, 30);
    t3.setBounds(300, 300, 150, 30);
    l5.setBounds(100, 350, 150, 30);
    t4.setBounds(300, 350, 150, 30);
    l6.setBounds(100, 400, 100, 30);
    t5.setBounds(300, 400, 150, 30);
    l7.setBounds(100, 450, 100, 30);
    c1.setBounds(300, 450, 60, 30);
    c2.setBounds(400, 450, 60, 30);
    l8.setBounds(100, 500, 100, 30);
    t6.setBounds(300, 500, 150, 30);
    l9.setBounds(100, 550, 100, 30);
    t7.setBounds(300, 550, 150, 30);
    l10.setBounds(100, 600, 120, 30);
    t8.setBounds(300, 600, 150, 30);

    l11.setBounds(100, 650, 100, 30);
    t9.setBounds(300, 650, 150, 30);
    l12.setBounds(100, 700, 150, 30);
    t10.setBounds(300, 700, 150, 30);
    b2.setBounds(500, 400, 100, 30);
    b3.setBounds(500, 500, 100, 30);
    b4.setBounds(500, 600, 100, 30);
    b5.setBounds(650, 150, 100, 30);

    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b4.addActionListener(this);
    b5.addActionListener(this);
    b6.addActionListener(this);
    c1.addItemListener(this);
    c2.addItemListener(this);

    p.add(l1);
    p.add(l2);
    p.add(l13);
    p.add(l14);
    p.add(t1);
    p.add(b1);
    p.add(l15);
    p.add(b5);
    p.add(b6);

    f.add(p);

    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  public void start(Stage primaryStage) throws Exception {

    // Connecting to Access DB
    connect();

    // Declaration of variable window as primaryStage
    window = primaryStage;
    window.setTitle("Icooköp");
    primaryStage.setTitle("Icooköp");

    // Calls method closeProgram() also when terminating the program
    window.setOnCloseRequest(e -> closeProgram());

    // ---------------------SCENE1--------------------------

    // Scene 1 Welcome Label
    Label labelScene1 = new Label();
    labelScene1.setText("Välkommen till Icooköp beta v0.2!");
    labelScene1.setFont(Font.font("Verdana", 20));

    // Scene 1 left menu with spacing
    VBox scene1leftMenu = new VBox(15);
    scene1leftMenu.setPadding(new Insets(20, 20, 20, 20));

    // Calls closeProgram()
    Button s1q1 = new Button("Avsluta");
    s1q1.setOnAction(e -> closeProgram());

    // Displays all available product types
    Button s1b1 = new Button("Visa produkttyper");
    s1b1.setOnAction(e -> createStatement());

    // TableView object for displaying database data.
    tableview = new TableView();

    // TextField for user input of a selected product.
    Label s1l1 = new Label();
    s1l1.setText("Visa märken till produktgrupp");

    // Calls preparedStatement with product parameter
    choiceBox1 = new ChoiceBox<>();
    getProductTypes();
    choiceBox1
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((v, oldValue, newValue) -> preparedStatement(newValue));

    // Button for switching to scene 2 (insertStamkund)
    Button s1b3 = new Button("Lägg till stamkund");
    s1b3.setOnAction(e -> window.setScene(scene2));

    // Label for drop down menu
    Label s1l2 = new Label();
    s1l2.setText("Se butiksaldo");

    // Creating ChoiceBox (drop down) with all the stores.
    // When choosing a store, storeStock() method is called for that store.
    choiceBox2 = new ChoiceBox<>();
    getStores();
    choiceBox2
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((v, oldValue, newValue) -> storeStock(newValue));

    // Adding buttons, labels, text fields and choicebox (drop down) to left menu
    scene1leftMenu
        .getChildren()
        .addAll(labelScene1, s1q1, s1b1, s1l1, choiceBox1, s1b3, s1l2, choiceBox2);

    // Creating BorderPane object and aligning left and center content
    BorderPane Borderpane1 = new BorderPane();
    Borderpane1.setLeft(scene1leftMenu);
    Borderpane1.setCenter(tableview);

    // Setting scene 1 using BorderPane1. Both scenes have identical dimensions.
    scene1 = new Scene(Borderpane1, 700, 500);

    // ------------------- SCENE2 (insert Stamkund) --------------------

    // HBox for scene 2 created and a Label for it.
    HBox scene2topMenu = new HBox();
    Label labelScene2 = new Label();
    labelScene2.setText("Lägg till stamkund");
    labelScene2.setFont(Font.font("Verdana", 20));

    // Left menu VBox created.
    VBox scene2leftMenu = new VBox(15);

    // Scene 2 Main manu and Quit Button created
    Button s2b1 = new Button("Huvudmeny");
    s2b1.setOnAction(e -> window.setScene(scene1));
    Button s2q1 = new Button("Avsluta");
    s2q1.setOnAction(e -> closeProgram());

    // GridPane for scene 2 created with spacing
    GridPane s2grid = new GridPane();
    s2grid.setPadding(new Insets(10, 10, 10, 10));
    s2grid.setVgap(15);
    s2grid.setHgap(10);

    // Label displaying required input fields
    Label oblLabel = new Label("* = Obligatoriskt fält");
    GridPane.setConstraints(oblLabel, 0, 0);

    // Label for prnParam
    Label pnrLabel = new Label("*Personnummer:");
    GridPane.setConstraints(pnrLabel, 0, 1);

    // pnrParam is forced by regular expression to "6 digits"-"dash"-"4 digits"
    FormattedTextField pnrParam = new FormattedTextField("^\\d{6}-\\d{4}$");
    pnrParam.setPromptText("XXXXXX-XXXX");
    GridPane.setConstraints(pnrParam, 1, 1);

    // Label for fnameParam
    Label fnameLabel = new Label("*Förnamn:");
    GridPane.setConstraints(fnameLabel, 0, 2);

    // First name TextField
    TextField fnameParam = new TextField();
    fnameParam.setPromptText("t.ex. Arne");
    GridPane.setConstraints(fnameParam, 1, 2);

    // Label for snameParam
    Label snameLabel = new Label("*Efternamn:");
    GridPane.setConstraints(snameLabel, 0, 3);

    // Surname TextField
    TextField snameParam = new TextField();
    snameParam.setPromptText("t.ex. Andersson");
    GridPane.setConstraints(snameParam, 1, 3);

    // Label for addrParam
    Label addrLabel = new Label("*Adress:");
    GridPane.setConstraints(addrLabel, 0, 4);

    // Address TextField
    TextField addrParam = new TextField();
    addrParam.setPromptText("t.ex. Storgatan 1");
    GridPane.setConstraints(addrParam, 1, 4);

    // Label for mailParam
    Label mailLabel = new Label("E-post:");
    GridPane.setConstraints(mailLabel, 0, 5);

    // Mail TextField
    TextField mailParam = new TextField();
    mailParam.setPromptText("*****@*****.**");
    GridPane.setConstraints(mailParam, 1, 5);

    // Label for cellParam
    Label cellLabel = new Label("Mobilnummer:");
    GridPane.setConstraints(cellLabel, 0, 6);

    // cellParam is forced by regular expression to "3 digits"-"dash"-"7 digits"
    FormattedTextField cellParam = new FormattedTextField("^\\d{3}-\\d{7}$");
    cellParam.setPromptText("XXX-XXXXXXX");
    GridPane.setConstraints(cellParam, 1, 6);

    // This Label displays user information such as errors and confirmations.
    Label executeLabel = new Label();
    GridPane.setConstraints(executeLabel, 1, 8);

    // Adding Button "Registrera" with a lot of functionality
    Button s2b2 = new Button("Registrera");
    GridPane.setConstraints(s2b2, 1, 7);
    s2b2.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {

            // First if-statement checks for data in required fields.
            // Required: pnrParam, fnameParam, lnameParam and addrParam.
            if ((pnrParam.getText() != null && !pnrParam.getText().isEmpty())
                && (fnameParam.getText() != null && !fnameParam.getText().isEmpty())
                && (snameParam.getText() != null && !snameParam.getText().isEmpty())
                && (addrParam.getText() != null && !addrParam.getText().isEmpty())) {

              // Second if-statement calls checkPnr() to see if pnrParam (Personnummer)
              // is unique in database. If unique, checkPnr() returns False.
              // If !checkPnr = True, all data is valid and we run insertStamkund
              if (!checkPnr(pnrParam.getText())) {

                // Calls insertStamkund() with data from all TextFields.
                // Saves card number to integer cardParam.
                int cardParam =
                    insertStamkund(
                        pnrParam.getText(),
                        fnameParam.getText(),
                        snameParam.getText(),
                        addrParam.getText(),
                        mailParam.getText(),
                        cellParam.getText());

                // Converts cardParam value to String c.
                // Prints a welcoming and customer card number.
                String c = String.valueOf(cardParam);
                executeLabel.setText(
                    "Välkommen som stamkund hos Icooköp!\n" + "Ditt kortnummer är: " + c);

                // Clear TextFields
                pnrParam.clear();
                fnameParam.clear();
                snameParam.clear();
                addrParam.clear();
                mailParam.clear();
                cellParam.clear();
              }

              // If !checkPnr = False, pnrParam is already in database and user is notified.
              else {
                executeLabel.setText(
                    "Personnumret finns redan registrerat!\n" + "Välj ett annat tack.");
              }

            }

            // If any required fields are empty, user is notified.
            else {
              executeLabel.setText("Fyll i alla obligatoriska fält!");
            }
          }
        });

    // Button for clearing data in all TextFields and executeLabel
    Button s2b3 = new Button("Rensa fält");
    GridPane.setConstraints(s2b3, 0, 7);
    s2b3.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            pnrParam.clear();
            fnameParam.clear();
            snameParam.clear();
            addrParam.clear();
            mailParam.clear();
            cellParam.clear();
            executeLabel.setText(null);
          }
        });

    // Adding buttons to left and top menus
    scene2leftMenu.getChildren().addAll(s2b1, s2q1);
    scene2topMenu.getChildren().add(labelScene2);

    // Adding Labels and TextFields to scene 2 center grid
    s2grid
        .getChildren()
        .addAll(
            oblLabel,
            pnrLabel,
            pnrParam,
            fnameLabel,
            fnameParam,
            snameLabel,
            snameParam,
            addrLabel,
            addrParam,
            mailLabel,
            mailParam,
            cellLabel,
            cellParam,
            s2b2,
            s2b3,
            executeLabel);

    // Creating BorderPane object and aligning left, top and center content
    BorderPane Borderpane2 = new BorderPane();
    Borderpane2.setLeft(scene2leftMenu);
    Borderpane2.setTop(scene2topMenu);
    Borderpane2.setCenter(s2grid);

    // Setting scene 2 using BorderPane2. Both scenes have identical dimensions.
    scene2 = new Scene(Borderpane2, 700, 500);

    // Setting primary scene and display window
    window.setScene(scene1);
    window.show();
  }