Advertisement
Advertisement
| 06.15.2008 at 09:57PM PDT, ID: 23487133 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: |
@Override
public void setValueAt(Object value, int row, int column) {
if(column==0)
{
System.out.println(value.toString());
PreparedStatement stmt=null;
ResultSet rs=null;
try
{
stmt=conn.prepareStatement("SELECT RawMaterialID, RawMaterialName, RawMaterialCode, RawMaterialUnitPrice, RawMaterialUnit" +
" FROM RawMaterial "+
"WHERE RawMaterialCode=?");
stmt.setString(1,value==null?null:value.toString());
rs=stmt.executeQuery();
if(rs.next())
{
super.setValueAt(value, row, column);
setValueAt(rs.getString(2),row,1);
setValueAt(rs.getString(5),row,3);
setValueAt(rs.getDouble(4),row,4);
}
else
{
super.setValueAt(null, row, column);
JOptionPane.showMessageDialog(BatchSheetInternalFrame.this,"Sorry there are not products with id \""+value+"\"","Information",JOptionPane.INFORMATION_MESSAGE);
int[] columns=new int[]{1,3};
for(int i:columns)
{
setValueAt(null,row,i);
}
setValueAt(0.0,row,4);
}
calculateTotal(row);
} catch (SQLException SQLEx) {
GUITools.displayErrorInformation(BatchSheetInternalFrame.this,SQLEx);
SQLEx.printStackTrace();
}finally
{
rs=DBTools.clearRes(rs);
stmt=DBTools.clearRes(stmt);
}
}
else if(column == 1)
{
System.out.println(value.toString());
System.out.println(Integer.toString(rawMaterialIds.get(rawMaterialNameCB.getSelectedIndex())));
int index = rawMaterialIds.get(rawMaterialNameCB.getSelectedIndex());
PreparedStatement stmt=null;
ResultSet rs=null;
try
{
stmt=conn.prepareStatement("SELECT RawMaterialID, RawMaterialName, RawMaterialCode, RawMaterialUnitPrice, RawMaterialUnit" +
" FROM RawMaterial "+
"WHERE RawMaterialID=?");
stmt.setInt(1,value==null?null:index);
rs=stmt.executeQuery();
if(rs.next())
{
super.setValueAt(value, row, column);
setValueAt(rs.getString(3),row,0);
setValueAt(rs.getString(5),row,3);
setValueAt(rs.getDouble(4),row,4);
}
else
{
super.setValueAt(null, row, column);
JOptionPane.showMessageDialog(BatchSheetInternalFrame.this,"Sorry there are not products with id \""+value+"\"","Information",JOptionPane.INFORMATION_MESSAGE);
int[] columns=new int[]{1,3};
for(int i:columns)
{
setValueAt(null,row,i);
}
setValueAt(0.0,row,4);
}
calculateTotal(row);
} catch (SQLException SQLEx) {
GUITools.displayErrorInformation(BatchSheetInternalFrame.this,SQLEx);
SQLEx.printStackTrace();
}finally
{
rs=DBTools.clearRes(rs);
stmt=DBTools.clearRes(stmt);
}
}
else
{
super.setValueAt(value, row, column);
if(column==2)
{
calculateTotal(row);
}
}
}
}
|