Ejemplo n.º 1
0
  private void LogMasuk() {
    SysConfig sc = new SysConfig();
    String pass = "";
    char chrPass[] = txtPass.getPassword();
    for (int i = 0; i < chrPass.length; i++) {
      pass = pass + chrPass[i];
      chrPass[i] = '0';
    }

    // KasirCon conn = new KasirCon("jdbc:postgresql://"+sc.getServerLoc()+":5432/"+sc.getDBName(),
    // txtKasir.getText(), pass, this);

    iCount++;
    if (iCount == 3) {
      System.exit(1);
    }

    try {
      Statement st =
          con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
      // ResultSet rs = st.executeQuery("select usename,usesysid,usesuper from pg_user where
      // usename='"+ txtKasir.getText().trim() +"'");
      String sQry =
          "select user_id, pwd, username, coalesce(profile, -1) as profile "
              + "from m_user "
              + "where username='******' "
              + "and pwd=md5('"
              + pass
              + "') ";

      ResultSet rs = st.executeQuery(sQry);
      // System.out.println(sQry);
      if (rs.next()) {
        sName = rs.getString("username").trim();
        authority = rs.getInt("profile");
        // sKota=lstModel.getElementAt(cmbGudang.getSelectedIndex()).toString();

        timer.cancel();
        setVisible(false);
        fMain = new MainForm();
        fMain.setConn(con);
        fMain.setUserProfile(rs.getInt("profile"));
        fMain.setUserName(sName);
        fMain.setServerLocation(sc.getServerLoc());
        fMain.udfSetUserMenu();

        fMain.setVisible(true);
      } else {
        JOptionPane.showMessageDialog(this, "Silakan masukkan nama user & passwod dengan benar!");
        txtKasir.requestFocus();
        txtKasir.setSelectionStart(0);
        txtKasir.setSelectionEnd(txtKasir.getText().length());
      }
    } catch (SQLException se) {
      JOptionPane.showMessageDialog(this, se.getMessage());
    }
  }
Ejemplo n.º 2
0
  private void formWindowOpened(
      java.awt.event.WindowEvent evt) { // GEN-FIRST:event_formWindowOpened
    // image/Login.jpg
    // String fileImage="image/Login.jpg";
    //   LabelIcon(fileImage,jLabel8);
    //        try {
    //            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    //        } catch (Exception e) {}
    // SystemConfig sc=new SystemConfig();

    conn =
        new KasirCon(
            "jdbc:postgresql://" + sc.getServerLoc() + ":5432/" + sc.getDBName(),
            "postgres",
            "bismillah",
            this);
    // conn = new KasirCon("jdbc:postgresql://"+sc.getServerLoc()+":5432/"+sc.getDBName(), "joss",
    // "123", this);

    if (conn.gettErrLog() == true) {
      con = conn.getCon();
    }
    txtKasir.addFocusListener(txtFoculListener);
    txtPass.addFocusListener(txtFoculListener);

    i = pBar.getX();
    timer = new Timer();
    timer.schedule(new DoTick(), 0, 5);
    java.text.SimpleDateFormat fdate2 = new java.text.SimpleDateFormat("HH:mm");

    Date jamNow = Calendar.getInstance().getTime();
    System.out.println("JAM: " + fdate2.format(jamNow.getTime()));

    // this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    // this.setExtendedState(MAXIMIZED_BOTH);

    //        try{
    //            Statement st=con.createStatement();
    //            ResultSet rs=st.executeQuery("select kode_resort, coalesce(nama_resort, '') as
    // nama_resort from m_Resort");
    //
    //            lstModel.removeAllElements();
    //
    //            int idx=0;
    //            lstModel.add(idx, "");
    //            cmbGudang.addItem("<Semua Resort>");
    //            idx++;
    //
    //            while(rs.next()){
    //                cmbGudang.addItem(rs.getString("nama_resort"));
    //                lstModel.add(idx, rs.getString("kode_resort"));
    //
    //                idx++;
    //            }
    //
    //        }catch(SQLException se){
    //            JOptionPane.showMessageDialog(this, se.getMessage());
    //        }
  } // GEN-LAST:event_formWindowOpened