我想从数据库中恢复数据,该数据依赖于同一个表的ID,并且由某些条件的另一个函数恢复;
这是我的代码,但它不起作用,我不知道如何解决它:(
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult actionName(Model pModel){
HttpPostedFileBase File = Request.Files["File1"];
if (File != null && File.ContentLength != 0){
//do what you want
return Content("OK");
}
else{
Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
return Content("Error Messages", System.Net.Mime.MediaTypeNames.Text.Plain);
}
}
@Override
public List<Float> findMontantByIdDetail(BigDecimal numCaisCais, int codDevDev)
{
System.out.println("Debut Fonction findMontantByIdDetail");
DetailCaisse detail=new DetailCaisse();
detail=findElementById( numCaisCais, codDevDev);
System.out.println(detail);
List<Float> montants=new ArrayList<Float>() ;
montants.add(detail.getMontToteDsc() );
montants.add(detail.getMontTotsDsc() );
System.out.println(montants.get(0) );
System.out.println(montants.get(1));
return montants;
}
<h:outputText>Code Devise</h:outputText>
<p:inputText value="#{detailCtr.codDevDev}" />
<h:outputText>code Caisse</h:outputText>
<p:inputText value="#{detailCtr.numCaisCais}" />
<h:commandButton value="Submit" action="#{detailCtr.findMontant()}"
update="cc">
</h:commandButton>
<p:dataTable value="#{detailCtr.findMontant()}" var="detail"
style="width:50px" id="crsvente">
<p:column headerText="Montant total entrée" style="width:150px">
<h:outputText value="#{detailCtr.montants.get(0)}" id="cc" />
</p:column>
<p:column headerText="Montant total Sortie" style="width:150px">
<h:outputText value="#{detailCtr.montants.get(1)}" id="cc" />
</p:column>
你可以帮我吗:)
答案 0 :(得分:0)
我已经解决了,我会提出解决方案:)
@Override
public DetailCaisse findElementById(BigDecimal numCaisCais, int codDevDev) {
Connection conn = null;
String sql = "select d.num_dsc_dsc , d.mont_tote_dsc , d.mont_tots_dsc from DETAIL_CAISSE d ,Devise dev, Caisse c where d.num_cais_cais=c.num_cais_cais and d.cod_dev_dev= dev.cod_dev_dev and c.num_cais_cais=? and dev.cod_dev_dev=?";
DetailCaisse detail = new DetailCaisse();
try {
conn = dataSource.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ps.setBigDecimal(1, numCaisCais);
ps.setInt(2, codDevDev);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
detail.setNumDscDsc(rs.getBigDecimal("num_dsc_dsc"));
detail.setMontToteDsc(rs.getFloat("mont_tote_dsc"));
detail.setMontTotsDsc(rs.getFloat("mont_tots_dsc"));
}
rs.close();
ps.close();
}
catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
}
}
return detail;
}
@Override
public List<Float> findMontantByIdDetail(BigDecimal numCaisCais,
int codDevDev) {
DetailCaisse detail = new DetailCaisse();
detail = findElementById(numCaisCais, codDevDev);
System.out.println(detail);
List<Float> montants = new ArrayList<Float>();
montants.add(detail.getMontToteDsc());
montants.add(detail.getMontTotsDsc());
System.out.println(montants);
System.out.println(detail.getMontToteDsc() + ""
+ detail.getMontTotsDsc());
return montants;
}
<h:form id="form">
<h:outputText>Code Devise</h:outputText>
<p:inputText value="#{detailCtr.codDevDev}" />
<h:outputText>code Caisse</h:outputText>
<p:inputText value="#{detailCtr.numCaisCais}" />
<h:commandButton value="Submit" action="#{detailCtr.findMontant()}"
update="cc">
</h:commandButton>
<p:dataTable value="#{detailCtr.findMontant()}" var="detail"
style="width:50px" id="crsvente">
<p:column headerText="Montant" style="width:150px">
<h:outputText value="#{detail}" id="cc" />
</p:column>
</p:dataTable>
</h:form>
祝大家好运:)