1 PackageCom.zq.www.mis.dao;2 //import Java.text.SimpleDateFormat;3 //import java.util.Date;4 5 ImportOrg.hibernate.Query;6 Importorg.springframework.stereotype.Repository;7 8 ImportCom.zq.www.common.BaseDAO;9 ImportCom.zq.www.mis.entity.Discount;Ten @Repository One Public classDiscountdaoextendsBasedao<discount> { A Publicstring Search (String Dis,discount Discount) - { -String result =NULL; the - /*SimpleDateFormat Bartdateformat = - new SimpleDateFormat ("Yyyy-mm-dd"); - String datestringtoparse = "date"; + try { - java.util.Date date1 = Bartdateformat.parse (datestringtoparse); + java.sql.Date sqldate = new Java.sql.Date (Date1.gettime ()); A System.out.println (Sqldate.gettime ()); at } - catch (Exception ex) { - System.out.println (Ex.getmessage ()); - }*/ - - if(Dis.tostring (). Equals ("Discount")) in { - /*java.sql.Date SD; to sd = new Java.sql.Date (Date.gettime ());*/ +String sql= "Select Discount as a from discount where id=1"; -Query q =GS (). createsqlquery (SQL); theresult=q.tostring (); * //price=double.valueof (Q.tostring ()). Doublevalue (); $ //price=double.valueof (q.tostring ()) *price;Panax Notoginseng } - Else if(Dis.tostring (). Equals ("Children")) the { +String sql1= "Select Children as b from discount where id=1"; AQuery q1 =GS (). Createsqlquery (SQL1); the //price=double.valueof (q.tostring ()) *price; + - } $ Else if(Dis.tostring (). Equals ("adult")) $ { -String sql2= "Select Adult as C from discount where id=1"; -Query q2 =GS (). Createsqlquery (SQL2); the //price=double.valueof (q.tostring ()) *price; - }Wuyi Else if(Dis.tostring (). Equals ("golden"))) the { -String sql3= "Select Golden as D from discount where id=1"; WuQuery q3 =GS (). Createsqlquery (SQL3); - //price=double.valueof (q.tostring ()) *price; About } $ Else if(Dis.tostring (). Equals ("Silver")) - { -String sql4= "Select silver from discount where id=1"; -Query Q4 =GS (). Createsqlquery (SQL4); A //price=double.valueof (q.tostring ()) *price; + } the returnresult; - } $}
Code summary for calculating fares in the project