Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////MySQL.CLass//////////////////////
- package helloworld.hello;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.*;
- import com.mysql.jdbc.PreparedStatement;
- import com.mysql.jdbc.ResultSetMetaData;
- public class MySQL {
- public static void insertComponent(String name){
- Connection con=null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- Statement st = con.createStatement();
- st.executeUpdate("insert into component (name) values ('"+name+"')");
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- }
- public static void insertSprint(String name, java.sql.Date start, java.sql.Date end,long duration, int proj_ID){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Insert into sprints (Title,Start_Date,End_Date,Duration,Proj_ID) values (?,?,?,?,?)";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- pstmt.setString(1, name); // set input parameter 1
- pstmt.setDate(2, start); // set input parameter 2
- pstmt.setDate(3, end);
- pstmt.setLong(4, duration); // set input parameter 3
- pstmt.setInt(5, proj_ID);
- pstmt.executeUpdate();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- }
- public static void EditProject(String name, String objective, String framework, int effort_Estimation){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Update project Set Objective=?, Framework=?, Effort_estimation=? where Title=? ";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- pstmt.setString(1, objective); // set input parameter 1
- pstmt.setString(2, framework); // set input parameter 2
- pstmt.setInt(3, effort_Estimation);
- pstmt.setString(4, name); // set input parameter 3
- pstmt.executeUpdate();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- }
- public static boolean CheckProject (String name){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Select Title from project ";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- ResultSet rs = pstmt.executeQuery();
- while (rs.next())
- {
- String s=rs.getString(1);
- if(s.equals(name))
- {
- return true;
- }
- }
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- return false;
- }
- public static void insertSprints(String name, int proj_Id){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Insert into sprints (Title,Proj_ID) values (?,?)";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- pstmt.setString(1, name); // set input parameter 1
- pstmt.setInt(2, proj_Id);
- pstmt.executeUpdate();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- }
- public static boolean CheckSprint (String name){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Select Title from sprints ";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- ResultSet rs = pstmt.executeQuery();
- while (rs.next())
- {
- String s=rs.getString(1);
- if(s.equals(name))
- {
- return true;
- }
- }
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- return false;
- }
- public static void UpdateSprint(String name, java.sql.Date start, java.sql.Date end,long duration){
- Connection con=null;
- PreparedStatement pstmt = null;
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- String query ="Update sprints set Start_date=?, End_Date=?, Duration=? where Title = ?";
- pstmt = (PreparedStatement) con.prepareStatement(query);
- pstmt.setString(4,name ); // set input parameter 1
- pstmt.setDate(1, start); // set input parameter 2
- pstmt.setDate(2, end);
- pstmt.setLong(3, duration); // set input parameter 3
- System.out.println(pstmt);
- pstmt.executeUpdate();
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){
- }
- }
- }
- }
- ////////////////////////////////////////ShowSprint.class/////////////////////////////////
- package helloworld.hello;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import java.util.ArrayList;
- import java.util.List;
- public class ShowSprint {
- static List entries;
- static Connection con=null;
- public static ShowSprint x= new ShowSprint();
- static{
- try{
- Class.forName("com.mysql.jdbc.Driver");
- con=DriverManager.getConnection("jdbc:mysql://localhost:3306/Collabsoft","root","");
- Statement st = con.createStatement();
- ResultSet rs=st.executeQuery("Select * from sprints");
- while(rs.next())
- {
- x.addEntry(new Sprint(rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5)));
- }
- }
- catch(Exception e){
- e.printStackTrace();
- }
- finally{
- try{
- if(con != null)
- con.close();
- }
- catch(Exception e){}
- }
- }
- public ShowSprint(){
- entries=new ArrayList();
- }
- public static ShowSprint getSprints() {
- return x;
- }
- public static void addEntry(Sprint entry){
- entries.add(entry);
- }
- public List getEntries(){
- return entries;
- }
- }
- /////////////////////////////////Sprint.class///////////////////////////////////////////
- package helloworld.hello;
- public class Sprint {
- private String title;
- private String start_Date;
- private String end_Date;
- private String duration;
- public Sprint(String title, String start_Date, String end_Date, String duration)
- {
- this.title = title;
- this.start_Date = start_Date;
- this.end_Date = end_Date;
- this.duration = duration;
- }
- public String getTitle()
- {
- return title;
- }
- public String getStart_Date()
- {
- return start_Date;
- }
- public String getEnd_Date()
- {
- return end_Date;
- }
- public String getDuration()
- {
- return duration;
- }
- }
- ///////////////////////////EditSprint.class////////////////////////////
- package helloworld.hello;
- import java.sql.Date;
- import java.util.Calendar;
- import org.apache.wicket.AttributeModifier;
- import org.apache.wicket.extensions.yui.calendar.DatePicker;
- import org.apache.wicket.markup.html.WebPage;
- import org.apache.wicket.markup.html.basic.Label;
- import org.apache.wicket.markup.html.form.Form;
- import org.apache.wicket.markup.html.form.TextField;
- import org.apache.wicket.markup.html.list.ListItem;
- import org.apache.wicket.markup.html.list.ListView;
- import org.apache.wicket.markup.html.panel.FeedbackPanel;
- import org.apache.wicket.model.CompoundPropertyModel;
- import org.apache.wicket.model.Model;
- public class EditSprint extends WebPage {
- private Model sprint;
- private Model start_Date;
- private Model end_Date;
- public EditSprint(){
- ListView eachEntry = new ListView("eachEntry",
- ShowSprint.getSprints().getEntries()) {
- protected void populateItem(ListItem item) {
- item.setModel(new CompoundPropertyModel(item.getModelObject()));
- item.add(new AttributeModifier("class", true, new Model(item
- .getIndex() % 2 == 0 ? "even" : "odd")));
- item.add(new Label("title"));
- item.add(new Label("start_Date"));
- item.add(new Label("end_Date"));
- item.add(new Label("duration"));
- }
- };
- FeedbackPanel feedback = new FeedbackPanel("msgs");
- add(feedback);
- Form form = new Form("f"){
- protected void onSubmit()
- {
- String s_Name=(String)sprint.getObject();
- java.sql.Date s_Date=(java.sql.Date)start_Date.getObject();
- java.sql.Date e_Date=(java.sql.Date)end_Date.getObject();
- long diff = e_Date.getTime()-s_Date.getTime();
- long days = diff/(1000 * 60 * 60 * 24);
- int proj_id=1;
- if(s_Date.getTime()>e_Date.getTime())
- {
- error("You can't end the sprint before it starts");
- }
- else if(s_Name==null)
- {
- error("Please fill the required fields");
- }
- else if(MySQL.CheckSprint(s_Name)==false)
- {
- error("No Sprint with this name");
- }
- else
- {
- MySQL.UpdateSprint(s_Name, s_Date, e_Date, days);
- SprintResult sprintResult = new SprintResult(s_Name,days);
- setResponsePage(sprintResult);
- }
- }
- };
- Calendar cal = Calendar.getInstance();
- sprint= new Model("");
- TextField s = new TextField("title",sprint);
- start_Date = new Model(cal.getTime());
- TextField start = new TextField("Start Date",start_Date,Date.class);
- end_Date = new Model(cal.getTime());
- TextField end = new TextField("End Date",end_Date, Date.class);
- start.add(new DatePicker());
- end.add(new DatePicker());
- form.add(s);
- form.add(start);
- form.add(end);
- add(eachEntry);
- add(form);
- }
- }
- //////////////////////////////////EditSprint.html//////////////////////
- <html>
- <head></head>
- <body>
- <div style="position: absolute; width: 632px; height: 22px; z-index: 4; left: 20px; top: 155px" id="layer10">
- <head>
- <style type="text/css">
- tr.odd {background-color: Grey}
- tr.even {background-color: Red}
- </style>
- </head>
- <body>
- <table border="1" width="632" bordercolorlight="#000000" bordercolordark="#000000" style="border-collapse: collapse">
- <tr><th>Title</th><th>Start Date</th><th>End Date</th><th>Duration</th></tr>
- <tr wicket:id="eachEntry">
- <td wicket:id="title">1</td>
- <td wicket:id="start_Date">Britney</td>
- <td wicket:id="end_Date">Spears</td>
- <td wicket:id="duration">376926</td>
- </tr>
- </table></body></div>
- <div style="position: absolute; width: 237px; height: 22px; z-index: 4; left: 347px; top: 324px" id="layer5">
- <span wicket:id="msgs"></span></div>
- <form wicket:id="f">
-
- <body bgcolor="#C0C0C0"></body>
- <div style="position: absolute; width: 61px; height: 25px; z-index: 8; left: 268px; top: 454px" id="layer9">
- End Date</div>
- <div style="position: absolute; width: 183px; height: 24px; z-index: 7; left: 364px; top: 454px" id="layer8">
- <input type="text" wicket:id="End Date" name="T2" size="20">
- </div>
- <div style="position: absolute; width: 83px; height: 35px; z-index: 6; left: 268px; top: 416px" id="layer7">
- Start Date</div>
- <div style="position: absolute; width: 191px; height: 26px; z-index: 5; left: 361px; top: 418px" id="layer6">
- <input type="text" wicket:id="Start Date">
- </div>
- <div style="position: absolute; width: 571px; height: 22px; z-index: 4; left: 24px; top: 55px" id="layer4">
- <font size="6" color="#FF0000">Edit Start Date and End Date of a Sprint</font></div>
- <div style="position: absolute; width: 43px; height: 22px; z-index: 3; left: 271px; top: 371px" id="layer3">
- Title:</div>
- <div style="position: absolute; width: 38px; height: 26px; z-index: 2; left: 707px; top: 500px" id="layer2">
- <input type="submit" value="Edit"></div>
- <div style="position: absolute; width: 145px; height: 20px; z-index: 1; left: 364px; top: 372px" id="layer1">
- <input type="text" wicket:id="title" name="T1" size="27"></div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement