public void excluirLote(List<JobLote> listaExcluir) { Connection conn = null; PreparedStatement stmt = null; String sql = "delete from joblote where job = ? and operacao = ? and lote =? "; try { conn = GerenciaConexaoSQLServer.abreConexao(); conn.setAutoCommit(false); for (int i = 0; i <= listaExcluir.size() - 1; i++) { JobLote job = listaExcluir.get(i); stmt = conn.prepareStatement(sql); stmt.setString(1, job.getJob().trim().replace(".", "")); stmt.setInt(2, job.getOperNum()); stmt.setInt(3, job.getLote()); stmt.executeUpdate(); alteraJobAposExclusao(conn, job); gravaJobsExcluidos( conn, job.getJob().trim().replace(".", ""), job.getOperNum(), job.getLote()); } // adiciona a op na tela inicial for (int i = 0; i <= listaExcluir.size() - 1; i++) { JobLote job = listaExcluir.get(i); JobProtheus jobProtheus = retornaJob(conn, job); adicionaOPTelaInicial(conn, jobProtheus, job); } JOptionPane.showMessageDialog(this, "Job Excluido com Sucesso!"); conn.commit(); } catch (SQLException e) { if (conn != null) { try { conn.rollback(); conn.setAutoCommit(true); JOptionPane.showMessageDialog(null, "Não foi possivel excluir! Descrição: " + e); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "Erro ao fazer o rollback! Descrição: " + ex); } } } finally { GerenciaConexaoSQLServer.closeConexao(conn, stmt); } }
public void gravaJobsExcluidos(Connection conn, String job, int operacao, int lote) throws SQLException { PreparedStatement stmt = null; String insert = "insert into joblotesexcluidos (job, operacao, lote) values (?,?,?)"; stmt = conn.prepareStatement(insert); stmt.setString(1, job.trim()); stmt.setInt(2, operacao); stmt.setInt(3, lote); stmt.executeUpdate(); }
public static int retornaQtdTotal(Connection conn, JobProtheus job) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; int qtdTotal = 0; int qtdSucata = 0; String sqlVerQtd = "select job, sum(qtd_transf), sum(hr_tot), sum(qtd_sucata) from jobLote where job = ? and operacao = ? group by job"; stmt = conn.prepareStatement(sqlVerQtd); stmt.setString(1, job.getJob().trim()); stmt.setInt(2, job.getOperacao()); rs = stmt.executeQuery(); String qtdJob = ""; double totHora = 0; while (rs.next()) { qtdJob = rs.getString(1); // numero job qtdTotal = rs.getInt(2); // quantidade total totHora = rs.getInt(3); // hora total em minutos qtdSucata = rs.getInt(4); } return qtdTotal + qtdSucata; }
public ValoresAtualizaJob retornaNovosValores(Connection conn, JobLote job) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; ValoresAtualizaJob obj = null; String sql = " select sum(qtd_transf) qtd_transf, sum(qtd_sucata) qtd_sucata, sum(hr_tot) hr_tot from joblote\n" + " where job = ? and operacao = ? "; stmt = conn.prepareStatement(sql); stmt.setString(1, job.getJob().trim().replace(".", "")); stmt.setInt(2, job.getOperNum()); rs = stmt.executeQuery(); if (rs.next()) { obj = new ValoresAtualizaJob(); obj.setQtdTransf(rs.getDouble("qtd_transf")); obj.setQtdSucata(rs.getDouble("qtd_sucata")); obj.setHoraTotal(rs.getDouble("hr_tot")); } return obj; }
/** * Get Restriction Lines * * @param reload reload data * @return array of lines */ public MGoalRestriction[] getRestrictions(boolean reload) { if (m_restrictions != null && !reload) return m_restrictions; ArrayList<MGoalRestriction> list = new ArrayList<MGoalRestriction>(); // String sql = "SELECT * FROM PA_GoalRestriction " + "WHERE PA_Goal_ID=? AND IsActive='Y' " + "ORDER BY Org_ID, C_BPartner_ID, M_Product_ID"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, get_Trx()); pstmt.setInt(1, getPA_Goal_ID()); rs = pstmt.executeQuery(); while (rs.next()) list.add(new MGoalRestriction(getCtx(), rs, get_Trx())); } catch (Exception e) { log.log(Level.SEVERE, sql, e); } finally { DB.closeStatement(pstmt); DB.closeResultSet(rs); } // m_restrictions = new MGoalRestriction[list.size()]; list.toArray(m_restrictions); return m_restrictions; } // getRestrictions
public JobIniciado retornaUltimoLote(Connection conn, String job, int operacao) throws SQLException { String sql = " select job, operacao, tripulacao,recurso, max(data_fim) \n" + "from joblote where job = ? and operacao = ? \n" + "group by job, operacao, tripulacao, recurso "; PreparedStatement stmt = null; ResultSet rs = null; JobIniciado iniciado = null; stmt = conn.prepareStatement(sql); stmt.setString(1, job.trim().replace(".", "")); stmt.setInt(2, operacao); rs = stmt.executeQuery(); if (rs.next()) { iniciado = new JobIniciado(); iniciado.setJob(rs.getString(1)); iniciado.setOperacao(rs.getInt(2)); iniciado.setTripulacao(rs.getDouble(3)); iniciado.setRecurso(rs.getString(4)); Timestamp data = rs.getTimestamp(5); iniciado.setData(Validacoes.getDataHoraString(data)); } return iniciado; }
public void desativaIniciado(Connection conn, String op, int operacao) throws SQLException { String sql = "update jobsiniciados set ativo = 0 where job = ? and operacao = ? "; PreparedStatement stmt = null; stmt = conn.prepareStatement(sql); stmt.setString(1, op.trim().replace(".", "")); stmt.setInt(2, operacao); stmt.executeUpdate(); }
/** * Get User Goals * * @param ctx context * @param AD_User_ID user * @return array of goals */ public static MGoal[] getUserGoals(Ctx ctx) { int AD_Role_ID = ctx.getAD_Role_ID(); MRole role = MRole.get(ctx, AD_Role_ID); int AD_User_ID = ctx.getAD_User_ID(); if (AD_User_ID < 0) return getTestGoals(ctx); ArrayList<MGoal> list = new ArrayList<MGoal>(); String sql = "SELECT * FROM PA_Goal g " + "WHERE IsActive='Y'" + " AND AD_Client_ID=?" // #1 + " AND ("; if (!role.isWebStoreRole()) sql += " (AD_User_ID IS NULL AND AD_Role_ID IS NULL) OR "; sql += " AD_User_ID=?" // #2 + " OR EXISTS (SELECT * FROM AD_User_Roles ur " + "WHERE ?=ur.AD_User_ID AND g.AD_Role_ID=ur.AD_Role_ID AND ur.IsActive='Y')) " + "ORDER BY SeqNo"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, (Trx) null); pstmt.setInt(1, ctx.getAD_Client_ID()); pstmt.setInt(2, AD_User_ID); pstmt.setInt(3, AD_User_ID); rs = pstmt.executeQuery(); while (rs.next()) { MGoal goal = new MGoal(ctx, rs, null); goal.updateGoal(false); list.add(goal); } } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeResultSet(rs); DB.closeStatement(pstmt); } MGoal[] retValue = new MGoal[list.size()]; list.toArray(retValue); return retValue; } // getUserGoals
public JobProtheus retornaJob(Connection conn, JobLote lote) throws SQLException { ResultSet rs = null; PreparedStatement stmt = null; JobProtheus job = null; String sql = "select job , B1_DESC, operacao , produto, "; sql += " dt_release, job_start_date , qtd_release, setor, qtd_transf "; sql += " from job left join " + DB_PROTHEUS.trim() + ".dbo.SB1000 SB1 "; sql += " on(produto collate SQL_Latin1_General_CP1_CI_AS = B1_COD) "; sql += " where job = ? and operacao = ? and SB1.D_E_L_E_T_ = '' "; sql += " order by dt_release, produto "; stmt = conn.prepareStatement(sql); stmt.setString(1, lote.getJob().trim()); stmt.setInt(2, lote.getOperNum()); rs = stmt.executeQuery(); while (rs.next()) { String nJob = rs.getString("job"); int operacao = rs.getInt("operacao"); String produto = rs.getString("produto"); Date dataEmissao = rs.getDate("dt_release"); Date dataPrevisaoInicio = rs.getDate("job_start_date"); String descricaoProduto = rs.getString("B1_DESC"); double quantidade = rs.getDouble("qtd_release"); String wc = rs.getString("setor"); String emissao = dataEmissao != null ? getDateToString(dataEmissao) : ""; String previsaoInicio = dataPrevisaoInicio != null ? getDateToString(dataPrevisaoInicio) : ""; job = new JobProtheus(); job.setStatus(""); job.setJob(nJob); job.setOperacao(operacao); job.setProduto(produto.trim()); job.setDataEmissao(emissao); job.setQuantidadeLiberada(quantidade); job.setDescricaoProduto(descricaoProduto); job.setCentroTrabalho(wc); double qtdTotal = retornaQtdTotal(conn, job); // calcula o total transferido para o job job.setQuantidadeCompleta(qtdTotal); job.setDataPrivisaoInicio(previsaoInicio); job.setQuantidadeFaltando(quantidade - qtdTotal); // seta o valor qtd faltando } return job; // retorna lista de jobs }
public static void add(String a, String b, File x, String s) throws Exception { fis = new FileInputStream(x); pa.setString(1, "" + dt); pa.setInt(2, pid); pa.setString(3, pfnm); pa.setString(4, pmnm); pa.setString(5, plnm); pa.setString(6, gen); pa.setInt(7, age); pa.setString(8, wt); pa.setString(9, a); pa.setString(10, cno); pa.setString(11, dnm); pa.setString(12, b); pa.setString(13, dig); pa.setInt(14, fee); pa.setString(15, bg); pa.setString(17, s); pa.setBinaryStream(16, (InputStream) fis, (int) (x.length())); pa.executeUpdate(); }
public void incluiIniciado(Connection conn, JobIniciado job) throws SQLException { String sql = "insert into jobsiniciados(job, operacao, data, tripulacao, ativo, recurso) values(?,?,?,?,?,?) "; PreparedStatement stmt = null; stmt = conn.prepareStatement(sql); stmt.setString(1, job.getJob().trim().replace(".", "")); stmt.setInt(2, job.getOperacao()); stmt.setTimestamp(3, Validacoes.converteDataStringEmFormatoTimeStamp(job.getData().trim())); stmt.setDouble(4, job.getTripulacao()); stmt.setBoolean(5, true); stmt.setString(6, job.getRecurso().trim()); stmt.executeUpdate(); }
public static void mod(File x, String s) throws Exception { try { System.out.println(x); fis = new FileInputStream(x); // tmp=con.prepareStatement("update patient set // dt=?,pfnm=?,pmnm=?,plnm=?,gen=?,age=?,wt=?,addr=?,cno=?,dnnm=?,sym=?,dig=?,fee=? where // pid=1"); tmp = con.prepareStatement( "update patient set dt=?,pfnm=?,pmnm=?,plnm=?,gen=?,age=?,wt=?,addr=?,cno=?,dnm=?,sym=?,dig=?,fee=?,bg=?,i=?,path=? where pid=" + pid); // tmp.setString(1,pfnm); tmp.setString(1, "" + dt); tmp.setString(2, pfnm); tmp.setString(3, pmnm); tmp.setString(4, plnm); tmp.setString(5, gen); tmp.setInt(6, age); tmp.setString(7, wt); tmp.setString(8, addr); tmp.setString(9, cno); tmp.setString(10, dnm); tmp.setString(11, sym); tmp.setString(12, dig); tmp.setInt(13, fee); tmp.setString(14, bg); tmp.setString(16, s); tmp.setBinaryStream(15, (InputStream) fis, (int) (x.length())); tmp.executeUpdate(); } catch (Exception ee) { System.out.println("mod123 " + ee); } }
public void alteraIniciado(Connection conn, JobIniciado job) throws SQLException { String sql = " update jobsiniciados set data = ?, ativo = ?, tripulacao = ?, recurso = ? " + " where job = ? and operacao = ? "; PreparedStatement stmt = null; stmt = conn.prepareStatement(sql); stmt.setTimestamp(1, Validacoes.converteDataStringEmFormatoTimeStamp(job.getData().trim())); stmt.setBoolean(2, true); stmt.setDouble(3, job.getTripulacao()); stmt.setString(4, job.getRecurso().trim()); stmt.setString(5, job.getJob().trim().replace(".", "")); stmt.setInt(6, job.getOperacao()); stmt.executeUpdate(); }
public void alteraJobAposExclusao(Connection conn, JobLote job) throws SQLException { ValoresAtualizaJob valores = retornaNovosValores(conn, job); PreparedStatement stmt = null; String update = "update job set qtd_transf = ?, hr_tot = ?, qtd_sucata = ?, status = ? where job = ? and operacao = ? "; stmt = conn.prepareStatement(update); stmt.setDouble(1, valores.getQtdTransf()); stmt.setDouble(2, valores.getHoraTotal()); stmt.setDouble(3, valores.getQtdSucata()); stmt.setString(4, "R"); stmt.setString(5, job.getJob().trim().replace(".", "")); stmt.setInt(6, job.getOperNum()); stmt.executeUpdate(); }
public boolean verificarSeJobEstaTabelaIniciado(Connection conn, String job, int operacao) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; String update = "select ativo from jobsiniciados where job = ? and operacao = ?"; stmt = conn.prepareStatement(update); stmt.setString(1, job.trim().replace(".", "")); stmt.setInt(2, operacao); rs = stmt.executeQuery(); if (rs.next()) { return true; } return false; }
/** * Get Goals with Measure * * @param ctx context * @param PA_Measure_ID measure * @return goals */ public static MGoal[] getMeasureGoals(Ctx ctx, int PA_Measure_ID) { ArrayList<MGoal> list = new ArrayList<MGoal>(); String sql = "SELECT * FROM PA_Goal WHERE IsActive='Y' AND PA_Measure_ID=? " + "ORDER BY SeqNo"; PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = DB.prepareStatement(sql, (Trx) null); pstmt.setInt(1, PA_Measure_ID); rs = pstmt.executeQuery(); while (rs.next()) list.add(new MGoal(ctx, rs, null)); } catch (Exception e) { s_log.log(Level.SEVERE, sql, e); } finally { DB.closeStatement(pstmt); DB.closeResultSet(rs); } MGoal[] retValue = new MGoal[list.size()]; list.toArray(retValue); return retValue; } // getMeasureGoals
public void actionPerformed(ActionEvent ae) { try { Integer num1 = Integer.parseInt(tfdid.getText()); if (num1.equals(null)) { System.out.println("num"); throw new BlankException(); } String name1 = tfname.getText(); int a; a = name1.charAt(0); if (name1.equals("") || a == 32) { throw new BlankException(); } else { for (int i = 0; i < name1.length(); i++) { boolean check = Character.isLetter(name1.charAt(i)); a = name1.charAt(i); System.out.print(" " + a); if (!((a >= 65 && a <= 90) || (a >= 97 && a <= 122) || (a == 32) || (a == 46))) { throw new NameEx(); } } } String addr1 = taadd.getText(); if (addr1.equals(null)) { System.out.println("addr"); throw new BlankException(); } String contact1 = tftel.getText(); String spec1 = taspecial.getText(); String workf1 = tfworkf.getText(); String workt1 = tfworkt.getText(); String str = "UPDATE DOC SET name=?,address=?,contact=?,specialization=?,workfrom=?,workto=? WHERE did=?"; Statement st1 = cn.createStatement(); PreparedStatement psmt = cn.prepareStatement(str); psmt.setString(1, name1); psmt.setString(2, addr1); psmt.setString(3, contact1); psmt.setString(4, spec1); psmt.setString(5, workf1); psmt.setString(6, workt1); psmt.setInt(7, num1); psmt.executeUpdate(); JOptionPane.showMessageDialog( new JFrame(), "Data Modified successfully!", "Done!", JOptionPane.INFORMATION_MESSAGE); } catch (SQLException sq) { String message = "Enter Valid Doctor ID and Contact."; JOptionPane.showMessageDialog(new JFrame(), message, "ERROR!", JOptionPane.ERROR_MESSAGE); System.out.println(sq); } catch (BlankException be) { JOptionPane.showMessageDialog( new JFrame(), "Please Enter All The Fields", "ERROR!", JOptionPane.ERROR_MESSAGE); } catch (NumberFormatException nfe) { JOptionPane.showMessageDialog( new JFrame(), "Patient Number and Contact Number Must Contain Digits.", "ERROR!", JOptionPane.ERROR_MESSAGE); } catch (NameEx ne) { JOptionPane.showMessageDialog( new JFrame(), "Invalid Name", "ERROR!", JOptionPane.ERROR_MESSAGE); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog( new JFrame(), "Enter Valid Date", "Error", JOptionPane.ERROR_MESSAGE); } }
public synchronized void insertData(String name, long modified, int type, DLNAMediaInfo media) { Connection conn = null; PreparedStatement ps = null; try { conn = getConnection(); ps = conn.prepareStatement( "INSERT INTO FILES(FILENAME, MODIFIED, TYPE, DURATION, BITRATE, WIDTH, HEIGHT, SIZE, CODECV, FRAMERATE, ASPECT, ASPECTRATIOCONTAINER, ASPECTRATIOVIDEOTRACK, REFRAMES, AVCLEVEL, BITSPERPIXEL, THUMB, CONTAINER, MODEL, EXPOSURE, ORIENTATION, ISO, MUXINGMODE, FRAMERATEMODE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); ps.setString(1, name); ps.setTimestamp(2, new Timestamp(modified)); ps.setInt(3, type); if (media != null) { if (media.getDuration() != null) { ps.setDouble(4, media.getDurationInSeconds()); } else { ps.setNull(4, Types.DOUBLE); } int databaseBitrate = 0; if (type != Format.IMAGE) { databaseBitrate = media.getBitrate(); if (databaseBitrate == 0) { LOGGER.debug("Could not parse the bitrate from: " + name); } } ps.setInt(5, databaseBitrate); ps.setInt(6, media.getWidth()); ps.setInt(7, media.getHeight()); ps.setLong(8, media.getSize()); ps.setString(9, left(media.getCodecV(), SIZE_CODECV)); ps.setString(10, left(media.getFrameRate(), SIZE_FRAMERATE)); ps.setString(11, left(media.getAspect(), SIZE_ASPECT)); ps.setString(12, left(media.getAspect(), SIZE_ASPECTRATIO_CONTAINER)); ps.setString(13, left(media.getAspect(), SIZE_ASPECTRATIO_VIDEOTRACK)); ps.setByte(14, media.getReferenceFrameCount()); ps.setString(15, left(media.getAvcLevel(), SIZE_AVC_LEVEL)); ps.setInt(16, media.getBitsPerPixel()); ps.setBytes(17, media.getThumb()); ps.setString(18, left(media.getContainer(), SIZE_CONTAINER)); if (media.getExtras() != null) { ps.setString(19, left(media.getExtrasAsString(), SIZE_MODEL)); } else { ps.setString(19, left(media.getModel(), SIZE_MODEL)); } ps.setInt(20, media.getExposure()); ps.setInt(21, media.getOrientation()); ps.setInt(22, media.getIso()); ps.setString(23, left(media.getMuxingModeAudio(), SIZE_MUXINGMODE)); ps.setString(24, left(media.getFrameRateMode(), SIZE_FRAMERATE_MODE)); } else { ps.setString(4, null); ps.setInt(5, 0); ps.setInt(6, 0); ps.setInt(7, 0); ps.setLong(8, 0); ps.setString(9, null); ps.setString(10, null); ps.setString(11, null); ps.setString(12, null); ps.setString(13, null); ps.setByte(14, (byte) -1); ps.setString(15, null); ps.setInt(16, 0); ps.setBytes(17, null); ps.setString(18, null); ps.setString(19, null); ps.setInt(20, 0); ps.setInt(21, 0); ps.setInt(22, 0); ps.setString(23, null); ps.setString(24, null); } ps.executeUpdate(); ResultSet rs = ps.getGeneratedKeys(); int id = -1; while (rs.next()) { id = rs.getInt(1); } rs.close(); if (media != null && id > -1) { PreparedStatement insert = null; if (media.getAudioTracksList().size() > 0) { insert = conn.prepareStatement( "INSERT INTO AUDIOTRACKS VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); } for (DLNAMediaAudio audio : media.getAudioTracksList()) { insert.clearParameters(); insert.setInt(1, id); insert.setInt(2, audio.getId()); insert.setString(3, left(audio.getLang(), SIZE_LANG)); insert.setString(4, left(audio.getFlavor(), SIZE_FLAVOR)); insert.setInt(5, audio.getAudioProperties().getNumberOfChannels()); insert.setString(6, left(audio.getSampleFrequency(), SIZE_SAMPLEFREQ)); insert.setString(7, left(audio.getCodecA(), SIZE_CODECA)); insert.setInt(8, audio.getBitsperSample()); insert.setString(9, left(trimToEmpty(audio.getAlbum()), SIZE_ALBUM)); insert.setString(10, left(trimToEmpty(audio.getArtist()), SIZE_ARTIST)); insert.setString(11, left(trimToEmpty(audio.getSongname()), SIZE_SONGNAME)); insert.setString(12, left(trimToEmpty(audio.getGenre()), SIZE_GENRE)); insert.setInt(13, audio.getYear()); insert.setInt(14, audio.getTrack()); insert.setInt(15, audio.getAudioProperties().getAudioDelay()); insert.setString(16, left(trimToEmpty(audio.getMuxingModeAudio()), SIZE_MUXINGMODE)); insert.setInt(17, audio.getBitRate()); try { insert.executeUpdate(); } catch (JdbcSQLException e) { if (e.getErrorCode() == 23505) { LOGGER.debug( "A duplicate key error occurred while trying to store the following file's audio information in the database: " + name); } else { LOGGER.debug( "An error occurred while trying to store the following file's audio information in the database: " + name); } LOGGER.debug("The error given by jdbc was: " + e); } } if (media.getSubtitleTracksList().size() > 0) { insert = conn.prepareStatement("INSERT INTO SUBTRACKS VALUES (?, ?, ?, ?, ?)"); } for (DLNAMediaSubtitle sub : media.getSubtitleTracksList()) { if (sub.getExternalFile() == null) { // no save of external subtitles insert.clearParameters(); insert.setInt(1, id); insert.setInt(2, sub.getId()); insert.setString(3, left(sub.getLang(), SIZE_LANG)); insert.setString(4, left(sub.getFlavor(), SIZE_FLAVOR)); insert.setInt(5, sub.getType().getStableIndex()); try { insert.executeUpdate(); } catch (JdbcSQLException e) { if (e.getErrorCode() == 23505) { LOGGER.debug( "A duplicate key error occurred while trying to store the following file's subtitle information in the database: " + name); } else { LOGGER.debug( "An error occurred while trying to store the following file's subtitle information in the database: " + name); } LOGGER.debug("The error given by jdbc was: " + e); } } } close(insert); } } catch (SQLException se) { if (se.getErrorCode() == 23001) { LOGGER.debug( "Duplicate key while inserting this entry: " + name + " into the database: " + se.getMessage()); } else { LOGGER.error(null, se); } } finally { close(ps); close(conn); } }
public Summary(int patient_id) { this.patient_id = patient_id; setTitle("Summary"); setSize( (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth()), (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight()) - 40); setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); head = new JLabel("MEDI_SCAN DIAGNOSTIC LAB SERVICES", SwingConstants.CENTER); head.setForeground(Color.WHITE); Font f2 = new Font("Papyrus", Font.BOLD, 36); head.setFont(f2); res = new JLabel("RESULT SUMMARY", SwingConstants.CENTER); res.setForeground(Color.WHITE); Font f3 = new Font("Papyrus", Font.BOLD, 28); res.setFont(f3); Font f1 = new Font("Goudy Old Style", Font.BOLD, 16); hello = new JLabel("Hello Mr./Miss "); hello.setForeground(new Color(54, 34, 174)); hello.setFont(f1); fin = new JLabel("Your Medical Test Is Finished"); fin.setFont(f1); fin.setForeground(new Color(54, 34, 174)); pname = new JLabel("Patient Name"); pname.setForeground(new Color(54, 34, 174)); pname.setFont(f1); ldate = new JLabel("Test Date"); ldate.setForeground(new Color(54, 34, 174)); ldate.setFont(f1); age = new JLabel("Age"); age.setForeground(new Color(54, 34, 174)); age.setFont(f1); sex = new JLabel("Sex"); sex.setForeground(new Color(54, 34, 174)); sex.setFont(f1); tname = new JLabel("Test Name"); tname.setForeground(new Color(54, 34, 174)); tname.setFont(f1); nvalue = new JLabel("Normal Value"); nvalue.setForeground(new Color(54, 34, 174)); nvalue.setFont(f1); trate = new JLabel("Test Rate"); trate.setForeground(new Color(54, 34, 174)); trate.setFont(f1); tresult = new JLabel("Test Result"); tresult.setForeground(new Color(54, 34, 174)); tresult.setFont(f1); tamt = new JLabel("Total Amout"); tamt.setForeground(new Color(54, 34, 174)); tamt.setFont(f1); exit = new JButton("EXIT"); exit.setFont(f1); pHead = new JPanel(new GridLayout(2, 1)); pHead.setBackground(new Color(134, 134, 234)); pCenter = new JPanel(new GridBagLayout()); pCenter.setBackground(new Color(211, 248, 253)); pCom = new JPanel(new BorderLayout()); pCom.setBackground(new Color(211, 248, 253)); pSouth = new JPanel(new FlowLayout(FlowLayout.RIGHT)); pSouth.setBackground(new Color(211, 248, 253)); // Adding Icon on top-left. ImageIcon img = new ImageIcon("pics/logo.jpg"); this.setIconImage(img.getImage()); try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement( "Select first_name,last_name,age,sex,test_id,tdate from patientreg where patient_id=?"); pstmt.setInt(1, this.patient_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { first_name = rs.getString("first_name"); lname = rs.getString("last_name"); name = new JLabel(first_name + " " + lname); name1 = new JLabel(first_name + " " + lname); p_age = rs.getInt("age"); pAge = new JLabel(p_age + ""); p_sex = rs.getString("sex"); psex = new JLabel(p_sex); t_id = rs.getInt("test_id"); t_date = rs.getString("tdate"); date1 = new JLabel(t_date); } } catch (SQLException s) { s.printStackTrace(); } try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement("Select test_result from reportbydoctor where patient_id=?"); pstmt.setInt(1, this.patient_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { te_res = rs.getString("test_result"); result = new JLabel(te_res); } } catch (SQLException s) { s.printStackTrace(); } try { Connection con = JDBCConnection.getConnection(); PreparedStatement pstmt = con.prepareStatement("select normal_val,rate,test_name from addtest where test_id=?"); pstmt.setInt(1, t_id); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { n_value = rs.getInt("normal_val"); normal_value1 = new JLabel(n_value + ""); te_rate = rs.getInt("rate"); rate1 = new JLabel(te_rate + ""); rate2 = new JLabel(te_rate + ""); te_name = rs.getString("test_name"); testname = new JLabel(te_name); } } catch (SQLException a) { a.printStackTrace(); } content = getContentPane(); // for label hello GridBagConstraints gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 50, 20, 0); pCenter.add(hello, gc); // for label name1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 0); pCenter.add(name1, gc); // for label fin gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 2; gc.gridy = 1; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(fin, gc); // for label pname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 2; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(pname, gc); // for label name gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 2; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(name, gc); // for label ldate gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 3; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(ldate, gc); // for label date1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 3; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(date1, gc); // for label age gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 4; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(age, gc); // for label pAge gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 4; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(pAge, gc); // for label sex gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 5; gc.ipadx = 125; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(sex, gc); // for label psex gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 5; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(psex, gc); // for label tname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tname, gc); // for label nvalue gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(nvalue, gc); // for label trate gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(trate, gc); // for label tresult gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 6; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tresult, gc); // for label testname gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 1; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(testname, gc); // for label normal_value1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 2; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(normal_value1, gc); // for label rate1 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(rate1, gc); // for label result gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 7; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(result, gc); // for label tamt gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 3; gc.gridwidth = 1; gc.gridy = 8; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(tamt, gc); // for label rate2 gc = new GridBagConstraints(); gc.fill = GridBagConstraints.NONE; gc.gridx = 4; gc.gridwidth = 1; gc.gridy = 8; gc.ipadx = 0; gc.ipady = 10; gc.weightx = 0; gc.weighty = 0; gc.anchor = GridBagConstraints.WEST; gc.insets = new Insets(0, 0, 20, 20); pCenter.add(rate2, gc); exit.addActionListener(this); pSouth.add(exit); content.add(pSouth, BorderLayout.SOUTH); pHead.add(head); pHead.add(res); content.add(pHead, BorderLayout.NORTH); content.add(pCenter, BorderLayout.CENTER); setVisible(true); }
public static void del() throws Exception { pd.setInt(1, pid); pd.executeUpdate(); }
public static boolean psearch(int n) throws Exception { pps.setInt(1, n); rs = pps.executeQuery(); return rs.next(); }
public ArrayList<DLNAMediaInfo> getData(String name, long modified) { ArrayList<DLNAMediaInfo> list = new ArrayList<DLNAMediaInfo>(); Connection conn = null; ResultSet rs = null; PreparedStatement stmt = null; try { conn = getConnection(); stmt = conn.prepareStatement("SELECT * FROM FILES WHERE FILENAME = ? AND MODIFIED = ?"); stmt.setString(1, name); stmt.setTimestamp(2, new Timestamp(modified)); rs = stmt.executeQuery(); while (rs.next()) { DLNAMediaInfo media = new DLNAMediaInfo(); int id = rs.getInt("ID"); media.setDuration(toDouble(rs, "DURATION")); media.setBitrate(rs.getInt("BITRATE")); media.setWidth(rs.getInt("WIDTH")); media.setHeight(rs.getInt("HEIGHT")); media.setSize(rs.getLong("SIZE")); media.setCodecV(rs.getString("CODECV")); media.setFrameRate(rs.getString("FRAMERATE")); media.setAspect(rs.getString("ASPECT")); media.setAspectRatioContainer(rs.getString("ASPECTRATIOCONTAINER")); media.setAspectRatioVideoTrack(rs.getString("ASPECTRATIOVIDEOTRACK")); media.setReferenceFrameCount(rs.getByte("REFRAMES")); media.setAvcLevel(rs.getString("AVCLEVEL")); media.setBitsPerPixel(rs.getInt("BITSPERPIXEL")); media.setThumb(rs.getBytes("THUMB")); media.setContainer(rs.getString("CONTAINER")); media.setModel(rs.getString("MODEL")); if (media.getModel() != null && !FormatConfiguration.JPG.equals(media.getContainer())) { media.setExtrasAsString(media.getModel()); } media.setExposure(rs.getInt("EXPOSURE")); media.setOrientation(rs.getInt("ORIENTATION")); media.setIso(rs.getInt("ISO")); media.setMuxingMode(rs.getString("MUXINGMODE")); media.setFrameRateMode(rs.getString("FRAMERATEMODE")); media.setMediaparsed(true); PreparedStatement audios = conn.prepareStatement("SELECT * FROM AUDIOTRACKS WHERE FILEID = ?"); audios.setInt(1, id); ResultSet subrs = audios.executeQuery(); while (subrs.next()) { DLNAMediaAudio audio = new DLNAMediaAudio(); audio.setId(subrs.getInt("ID")); audio.setLang(subrs.getString("LANG")); audio.setFlavor(subrs.getString("FLAVOR")); audio.getAudioProperties().setNumberOfChannels(subrs.getInt("NRAUDIOCHANNELS")); audio.setSampleFrequency(subrs.getString("SAMPLEFREQ")); audio.setCodecA(subrs.getString("CODECA")); audio.setBitsperSample(subrs.getInt("BITSPERSAMPLE")); audio.setAlbum(subrs.getString("ALBUM")); audio.setArtist(subrs.getString("ARTIST")); audio.setSongname(subrs.getString("SONGNAME")); audio.setGenre(subrs.getString("GENRE")); audio.setYear(subrs.getInt("YEAR")); audio.setTrack(subrs.getInt("TRACK")); audio.getAudioProperties().setAudioDelay(subrs.getInt("DELAY")); audio.setMuxingModeAudio(subrs.getString("MUXINGMODE")); audio.setBitRate(subrs.getInt("BITRATE")); media.getAudioTracksList().add(audio); } subrs.close(); audios.close(); PreparedStatement subs = conn.prepareStatement("SELECT * FROM SUBTRACKS WHERE FILEID = ?"); subs.setInt(1, id); subrs = subs.executeQuery(); while (subrs.next()) { DLNAMediaSubtitle sub = new DLNAMediaSubtitle(); sub.setId(subrs.getInt("ID")); sub.setLang(subrs.getString("LANG")); sub.setFlavor(subrs.getString("FLAVOR")); sub.setType(SubtitleType.valueOfStableIndex(subrs.getInt("TYPE"))); media.getSubtitleTracksList().add(sub); } subrs.close(); subs.close(); list.add(media); } } catch (SQLException se) { LOGGER.error(null, se); return null; } finally { close(rs); close(stmt); close(conn); } return list; }