private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Connection conn = null;
PreparedStatement pstm = null;
String url = "jdbc:mysql://localhost:3306/sale?useUnicode=true&characterEncoding=big5";
String user = "testuser";
String password = "test623";
// Calendar date = Calendar.getInstance();
// SimpleDateFormat dateformatter = new SimpleDateFormat("yyyy-MM-dd");
try{
conn = DriverManager.getConnection(url, user, password);
Statement st = conn.createStatement();
for (int i=0 ;i
try {
String Shift_Data = Shift_jComboBox2.getSelectedItem().toString();
String Data_Year = Year_jComboBox2.getSelectedItem().toString();
String Data_Month = Month_jComboBox3.getSelectedItem().toString();
String Data_Day = Day_jComboBox4.getSelectedItem().toString();
String Date_Data = Data_Year +"-"+ Data_Month +"-"+ Data_Day;
String Goods_name_Data = jTable1.getValueAt(i,0).toString();
String Unit_price_Data = jTable1.getValueAt(i,1).toString();
String Stocks_DataC = jTable1.getValueAt(i,2).toString();
String Good_in_stock_DataD = jTable1.getValueAt(i,3).toString();
String Ship_DataE = jTable1.getValueAt(i,4).toString();
String Balance_DataF = jTable1.getValueAt(i,5).toString();
String Selling_goods_DataG = jTable1.getValueAt(i,6).toString();
String Subtotal_DataH = jTable1.getValueAt(i,7).toString();
String Space_reserve_DataI = jTable1.getValueAt(i,8).toString();
String query = "update total_calc set Stocks= ?, Good_in_stock= ?, Ship= ?, Balance= ?, Selling_goods= ?, Subtotal= ?, Space_reserve= ? where Date = ? and Shift = ? and Goods_name= ? " ;
//綠色 是要變更的項目 藍色 是 所選擇的項目 選項越多 越精準
// green color is the item which we want to change. Blue color is the item which we want green color //item to change. More condition is better. Between item and item use "and".
// System.out.println(Data);
pstm = conn.prepareStatement(query);
System.out.println(Date_Data);
pstm.setString(1,Stocks_DataC);//按照上面?的順序 (follow the question mark on the //above.)
pstm.setString(2,Good_in_stock_DataD);
pstm.setString(3,Ship_DataE);
pstm.setString(4,Balance_DataF);
pstm.setString(5,Selling_goods_DataG);
pstm.setString(6,Subtotal_DataH);
pstm.setString(7,Space_reserve_DataI);
pstm.setString(8, Date_Data );
pstm.setString(9,Shift_Data);
pstm.setString(10,Goods_name_Data);
System.out.println(Goods_name_Data);
System.out.println("happy");
pstm.executeUpdate();
}catch(NullPointerException e){
// jTable1.setValueAt(0, i, j);
// JOptionPane.showMessageDialog(null,("第"+ (i+1) + "行 \n 第"+ (j+1)+ "行 \n 沒有輸入資料" ) );
}
}
pstm.close();
st.close();
conn.close();
}catch (SQLException ex) {
System.out.println(ex.getMessage());
}
JOptionPane.showMessageDialog(null,("資料傳送到 資料庫 完成" ) );
}
2011年8月8日 星期一
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言