示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int travelDetailsId = int.Parse(Session["travelDetailsId"].ToString());

        travelDetailsIdHidden.Value = travelDetailsId.ToString();

        travelDetails    travelDetailsObj = new travelDetails();
        travelDetailsDAO travelDao        = new travelDetailsDAO();

        travelDetailsObj = travelDao.getTravelDetailsData(travelDetailsId);

        if (travelDetailsObj != null)
        {
            tripNameLbl.Text      = travelDetailsObj.tripNameClass;
            startDateLblVer2.Text = travelDetailsObj.startDateClass.ToString();
            endDateLbl.Text       = travelDetailsObj.endDateClass.ToString();
            countryLbl.Text       = travelDetailsObj.countryClass;
            stateLbl.Text         = travelDetailsObj.stateClass;
            descriptionLbl.Text   = travelDetailsObj.descriptionClass;
        }
        else
        {
            errorMsg = "No details";
        }
    }
    public travelDetails getTravelDetailsData(int travelDetailsId)
    {
        //Get data to see which user is is

        SqlDataAdapter da;
        DataSet        ds = new DataSet();

        //Create Adapter
        //WRITE SQL Statement to retrieve all columns from Customer by customer Id using query parameter
        StringBuilder sqlCommand = new StringBuilder();

        sqlCommand.AppendLine("Select * from travelDetails where");
        sqlCommand.AppendLine("Id = @paraTravelDetailsId");

        travelDetails obj = new travelDetails();

        SqlConnection myConn = new SqlConnection(DBConnect);

        da = new SqlDataAdapter(sqlCommand.ToString(), myConn);
        da.SelectCommand.Parameters.AddWithValue("paraTravelDetailsId", travelDetailsId);

        da.Fill(ds, "travelTable");
        int rec_cnt = ds.Tables["travelTable"].Rows.Count;

        if (rec_cnt > 0)
        {
            DataRow row = ds.Tables["travelTable"].Rows[0];
            obj.userIdClass           = row["Id"].ToString();
            obj.tripNameClass         = row["tripName"].ToString();
            obj.startDateClass        = DateTime.Parse(row["startDate"].ToString());
            obj.endDateClass          = DateTime.Parse(row["endDate"].ToString());
            obj.countryClass          = row["country"].ToString();
            obj.descriptionClass      = row["description"].ToString();
            obj.expectedExpensesClass = double.Parse(row["expectedExpense"].ToString());
            obj.stateClass            = row["state"].ToString();
            obj.userIdClass           = row["userId"].ToString();
            obj.currentTimeClass      = row["dateEntered"].ToString();
        }
        else
        {
            obj = null;
        }

        return(obj);
    }
示例#3
0
    protected void editTravelDetailsButton_Click(object sender, EventArgs e)
    {
        Thread.Sleep(5000);

        string   tripName, country, state, description;
        DateTime startDate, endDate;

        try
        {
            tripName    = tripNameDetailsTextBox.Text;
            country     = countryTextBox.Text;
            state       = stateTextBox.Text;
            description = descriptionDetails.InnerText;
            startDate   = DateTime.Parse(startDateInput.Text);
            endDate     = DateTime.Parse(endDateInput.Text);

            if (String.IsNullOrEmpty(tripName))
            {
                errorMsg += "Please Enter A Trip Name!\n";
            }
            else if (String.IsNullOrEmpty(country))
            {
                errorMsg += "Please Enter A Country!\n";
            }
            else if (String.IsNullOrEmpty(description))
            {
                errorMsg += "Please Enter A Description!\n";
            }
            //else if (startDate > endDate)
            //{
            //    errorMsg += "Please Pick A Start Date Earlier Than End Date!\n";
            //}
            //else if (endDate < startDate)
            //{
            //    errorMsg += "Please Pick A End Date Later Than Start Date!\n";
            //}
            else
            {
                travelDetailsDAO travelDetailsDao = new travelDetailsDAO();
                travelDetails    travelObj        = new travelDetails();

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

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

                int insCnt = travelDetailsDao.updateTravelDetails(travelDetailsId, tripName, startDate, endDate, country, description, 0.00, state);
                if (insCnt == 1)
                {
                    Response.Redirect("itineraryHomepage.aspx");
                    System.Diagnostics.Debug.WriteLine("No error!");
                }
                else
                {
                    errorMsg   += "Error While Updating Data!";
                    status.Text = errorMsg;
                    System.Diagnostics.Debug.WriteLine(errorMsg);
                }
            }
        }
        catch (Exception ex)
        {
            errorMsg += ex.ToString();
        }
    }