protected void saveBtn_Click(object sender, EventArgs e)
    {
        string test        = html.Value;
        string currentTime = DateTime.Now.ToShortTimeString();

        Thread.Sleep(5000);

        int travelId = int.Parse(travelDetailsId.Value);

        itineraryDetailsDAO itineraryDao = new itineraryDetailsDAO();

        System.Diagnostics.Debug.WriteLine("travel id = " + travelId);
        int insCnt = itineraryDao.insertDetails(2, test, travelId, currentTime);

        if (insCnt == 1)
        {
            errorMsg    = "Succesfully Saved!";
            Label1.Text = errorMsg;
            Response.Redirect("itineraryCreatorStep3.aspx");
        }
        else
        {
            errorMsg    = "Unable to save itinerary details, please inform system administrator!";
            Label1.Text = errorMsg;
        }
    }
    protected void delete_Click(object sender, EventArgs e)
    {
        Button refBtn = (Button)(sender);

        int testTravelDetailsId = 30;

        itineraryDetailsDAO itineraryDao = new itineraryDetailsDAO();
        travelDetailsDAO    travelDao    = new travelDetailsDAO();

        int insCnt = itineraryDao.deleteItineraryDetailsInfo(testTravelDetailsId);

        if (insCnt == 1)
        {
            System.Diagnostics.Debug.WriteLine("Itinerary Details Removed!");
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("Itinerary Details Removing Failed!");
        }

        int insCntVer2 = travelDao.deleteTravelDetailsInfo(testTravelDetailsId);

        if (insCntVer2 == 1)
        {
            System.Diagnostics.Debug.WriteLine("Travel Details Removed!!");
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("Travel Details Removing Failed!");
        }
    }
    //public string tablesData()
    //{
    //    string html = "";
    //    itineraryDetailsDAO travelItineraryDao = new itineraryDetailsDAO();
    //    List<itineraryDetails> userList = new List<itineraryDetails>();

    //    userList = travelItineraryDao.getTravelDetails("2");
    //    if (userList != null)
    //    {
    //        foreach (var i  in userList)
    //        {
    //            html += "<tr><td class='column1'>" + "12/09/2000" + "</td><td class='column2'>" +  i.travelDetailsId + "</td><td class='column3'>" + i.tripNameClass + "</td><td class='column4'>" + i.startDateClass + "</td><td class='column5'>" + i.endDateClass + "</td><td class='column6'>" + i.countryClass + "</td><td class='column7'>" + i.stateClass + "</td><td class='column8'><asp:Button ID='button" + i.travelDetailsId + "' runat='server' class='btn btn-info' Text='Button' onclick='editItinerary_Click'/>" + "</td></tr>";
    //        }
    //        return html;
    //    }
    //    else
    //    {
    //        html = "<p>No details found!</p>";
    //        return html;
    //    }
    //}

    //void editItinerary_Click(object sender, EventArgs e)
    //{
    //    userNameLbl.Text = "worked!";
    //}

    public List <itineraryDetails> details()
    {
        itineraryDetailsDAO     travelItineraryDao = new itineraryDetailsDAO();
        List <itineraryDetails> userList           = new List <itineraryDetails>();

        userList = travelItineraryDao.getTravelDetails("2");
        if (userList != null)
        {
            return(userList);
        }
        else
        {
            return(userList);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        itineraryDetailsDAO     travelItineraryDao = new itineraryDetailsDAO();
        List <itineraryDetails> userList           = new List <itineraryDetails>();

        userList = travelItineraryDao.getTravelDetails("2");
        if (userList != null)
        {
            gv1.DataSource = userList;
            gv1.DataBind();
        }
        else
        {
            errorMsg = "null";
        }
    }
Пример #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int travelDetailsId = int.Parse(Session["travelDetailsId"].ToString());
        itineraryDetailsDAO itineraryDetailsDao = new itineraryDetailsDAO();
        itineraryDetails    itiObj = new itineraryDetails();

        itiObj = itineraryDetailsDao.getItineraryDetailsData(travelDetailsId);

        travellID.Value = travelDetailsId.ToString();

        travelId.Value = (itiObj.itineraryHtmlClass).ToString();

        if (itiObj != null)
        {
            System.Diagnostics.Debug.WriteLine("html is = " + itiObj.itineraryHtmlClass + " and travelid is = " + travelDetailsId);
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("nth is shown");
        }
    }
    protected void deleteAndEditRow(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "editButton")
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = gv1.Rows[index];

            int testTravelDetailsId = int.Parse(row.Cells[1].Text);

            Session["travelDetailsId"] = testTravelDetailsId;

            Response.Redirect("edit.aspx");
        }

        else if (e.CommandName == "deleteButton")
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = gv1.Rows[index];

            int testTravelDetailsId = int.Parse(row.Cells[1].Text);

            System.Diagnostics.Debug.WriteLine("row removed = " + testTravelDetailsId);

            itineraryDetailsDAO itineraryDao = new itineraryDetailsDAO();
            travelDetailsDAO    travelDao    = new travelDetailsDAO();

            int insCnt = itineraryDao.deleteItineraryDetailsInfo(testTravelDetailsId);
            if (insCnt == 1)
            {
                System.Diagnostics.Debug.WriteLine("Itinerary Details Removed!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Itinerary Details Removing Failed!");
            }

            int insCntVer2 = travelDao.deleteTravelDetailsInfo(testTravelDetailsId);
            if (insCntVer2 == 1)
            {
                System.Diagnostics.Debug.WriteLine("Travel Details Removed!!");
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Travel Details Removing Failed!");
            }

            Response.Redirect("itineraryHomepage.aspx");
        }

        else if (e.CommandName == "editItinerary")
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = gv1.Rows[index];

            int testTravelDetailsId = int.Parse(row.Cells[1].Text);

            Session["travelDetailsId"] = testTravelDetailsId;

            System.Diagnostics.Debug.WriteLine("travel id is =" + testTravelDetailsId);

            Response.Redirect("editItinerary.aspx");
        }
    }
    protected void addTravelDetails_Click(object sender, EventArgs e)
    {
        Thread.Sleep(5000);
        status.Text = "";

        // Initialize all variables
        string   tripName, email, country, description, state, currentTime;
        DateTime startDate, endDate;
        double   expectedExpense;
        string   userId;

        //Getting information from textBoxes <need to add validations>
        tripName        = tripNameDetails.Text.ToString();
        email           = emailDetails.Text.ToString();
        country         = countryTextBox.Text.ToString();
        description     = descriptionDetails.InnerText; // Will change once textarea bug is fixed
        startDate       = DateTime.Parse(startDateInput.Text);
        endDate         = DateTime.Parse(endDateInput.Text);
        expectedExpense = 0.00;
        state           = stateTextBox.Text.ToString();
        currentTime     = DateTime.Now.ToString("yyyy, MM, dd, hh, mm, ss");
        userId          = "2";


        //Validate
        string errorMessage;

        try
        {
            travelDetailsDAO tdDAO = new travelDetailsDAO();
            int insCnt             = tdDAO.insertTravelDetailsInfo(tripName, startDate, endDate, country, description, expectedExpense, state, userId, currentTime);
            if (insCnt == 1)
            {
                itineraryDetailsDAO     travelItineraryDao = new itineraryDetailsDAO();
                List <itineraryDetails> userList           = new List <itineraryDetails>();

                userList = travelItineraryDao.getTravelDetails("2");

                foreach (var i in userList)
                {
                    if (i.tripNameClass == tripName)
                    {
                        Session["travelId"] = i.travelDetailsId;
                    }
                }

                status.Text = "Data Successfully Added! Redirecting you to the next page.";
                Thread.Sleep(5000);
                Response.Redirect("itineraryCreatorStep2.aspx");
            }
            else
            {
                errorMessage = "Unable to insert travel details, please inform system administrator!";

                status.Text = errorMessage;
                Thread.Sleep(5000);
                Response.Redirect("itineraryCreatorStep1.aspx");
            }
        }
        catch (FormatException)
        {
            errorMessage = "Reached Catch!";
        }
    }