コード例 #1
0
ファイル: Waypoints.aspx.cs プロジェクト: achenxu/CarPool
    protected void btnSelectDates_Click(object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;

        page.ClientScript.RegisterStartupScript(typeof(Page), "Test", "calcRoute();return false;");

        RoutesEntity    rEntity = new RoutesEntity();
        DataAccessLayer DALayer = new DataAccessLayer();

        rEntity.CarId = DALayer.ReadCarId(ddlCarInfo.SelectedItem.Text);
        //Modlog Start: Seema
        rEntity.StartPnt = txtStartPoint.Value.Substring(0, txtStartPoint.Value.IndexOf(',', txtStartPoint.Value.IndexOf(',') + 1));
        rEntity.EndPnt   = txtEndPoint.Value.Substring(0, txtEndPoint.Value.IndexOf(',', txtEndPoint.Value.IndexOf(',') + 1));
        //rEntity.StartPnt = txtStartPoint.Value;
        //rEntity.EndPnt = txtEndPoint.Value;
        //Modlog End: Seema
        List <string> intermediatePntsLst = new List <string>();
        var           items = hdnLstWayPoints.Value.Split(';');

        for (int i = 0; i < items.Count() - 1; i++)
        {
            intermediatePntsLst.Add(items[i]);
        }
        rEntity.IntermediatePnts = intermediatePntsLst;
        Session["RouteInfo"]     = rEntity;
        Response.Redirect("SelectDates.aspx");
    }
コード例 #2
0
ファイル: SelectDates.aspx.cs プロジェクト: achenxu/CarPool
    public RoutesEntity FillRouteEntity()
    {
        RoutesEntity rEntity = ((RoutesEntity)Session["RouteInfo"]);

        rEntity.StartDate = Convert.ToDateTime(txtStartDate.Text);
        rEntity.EndDate   = Convert.ToDateTime(txtEndDate.Text);
        return(rEntity);
    }
コード例 #3
0
ファイル: MyRoutes.aspx.cs プロジェクト: LetsCarPool/CarPool
 protected void grdRoutesInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     RoutesEntity rEntInfo = new RoutesEntity();
     rEntInfo.RouteID =Convert.ToInt32( ((Label)grdRoutesInfo.Rows[e.RowIndex].FindControl("lblrtIdEdit")).Text);
     rEntInfo.StartPnt = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtStartPoint")).Text;
     rEntInfo.EndPnt = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtEndPnt")).Text;
     rEntInfo.StartDt = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtStartDt")).Text;
     rEntInfo.EndDt = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtEndDt")).Text;
     rEntInfo.RunningDays = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtRunningDays")).Text;
     rEntInfo.AllWayPoints = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtWayPoints")).Text;
     dalRegisteredCars.UpdateRouteInfo(rEntInfo);
     grdRoutesInfo.EditIndex = -1;
     FillGrdRouresDetails(userId);
 }
コード例 #4
0
ファイル: MyRoutes.aspx.cs プロジェクト: achenxu/CarPool
    protected void grdRoutesInfo_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        RoutesEntity rEntInfo = new RoutesEntity();

        rEntInfo.RouteID      = Convert.ToInt32(((Label)grdRoutesInfo.Rows[e.RowIndex].FindControl("lblrtIdEdit")).Text);
        rEntInfo.StartPnt     = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtStartPoint")).Text;
        rEntInfo.EndPnt       = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtEndPnt")).Text;
        rEntInfo.StartDt      = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtStartDt")).Text;
        rEntInfo.EndDt        = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtEndDt")).Text;
        rEntInfo.RunningDays  = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtRunningDays")).Text;
        rEntInfo.AllWayPoints = ((TextBox)grdRoutesInfo.Rows[e.RowIndex].FindControl("txtWayPoints")).Text;
        dalRegisteredCars.UpdateRouteInfo(rEntInfo);
        grdRoutesInfo.EditIndex = -1;
        FillGrdRouresDetails(userId);
    }
コード例 #5
0
ファイル: SelectDates.aspx.cs プロジェクト: achenxu/CarPool
    public RoutesEntity FillRouteEntitySTrip()
    {
        RoutesEntity rEntity = ((RoutesEntity)Session["RouteInfo"]);

        rEntity.StartDate = Convert.ToDateTime(txtStartDate.Text);
        rEntity.EndDate   = Convert.ToDateTime(txtStartDate.Text);
        DayOfWeek dayOfTravel = Convert.ToDateTime(txtStartDate.Text).DayOfWeek;
        string    runningDays = "";

        if (DayOfWeek.Monday == dayOfTravel)
        {
            runningDays = "1000000";
        }
        else if (DayOfWeek.Tuesday == dayOfTravel)
        {
            runningDays = "0100000";
        }
        else if (DayOfWeek.Wednesday == dayOfTravel)
        {
            runningDays = "0010000";
        }
        else if (DayOfWeek.Thursday == dayOfTravel)
        {
            runningDays = "0001000";
        }
        else if (DayOfWeek.Friday == dayOfTravel)
        {
            runningDays = "0000100";
        }
        else if (DayOfWeek.Saturday == dayOfTravel)
        {
            runningDays = "0000010";
        }
        else if (DayOfWeek.Sunday == dayOfTravel)
        {
            runningDays = "0000001";
        }
        rEntity.RunningDays = runningDays;
        return(rEntity);
    }
コード例 #6
0
ファイル: Waypoints.aspx.cs プロジェクト: LetsCarPool/CarPool
    protected void btnSelectDates_Click(object sender, EventArgs e)
    {
        Page page = HttpContext.Current.CurrentHandler as Page;
        page.ClientScript.RegisterStartupScript(typeof(Page), "Test", "calcRoute();return false;");

        RoutesEntity rEntity = new RoutesEntity();
        DataAccessLayer DALayer = new DataAccessLayer();
        rEntity.CarId = DALayer.ReadCarId(ddlCarInfo.SelectedItem.Text);
        //Modlog Start: Seema
        rEntity.StartPnt = txtStartPoint.Value.Substring(0, txtStartPoint.Value.IndexOf(',', txtStartPoint.Value.IndexOf(',') + 1));
        rEntity.EndPnt = txtEndPoint.Value.Substring(0, txtEndPoint.Value.IndexOf(',', txtEndPoint.Value.IndexOf(',') + 1));
        //rEntity.StartPnt = txtStartPoint.Value;
        //rEntity.EndPnt = txtEndPoint.Value;
        //Modlog End: Seema
        List<string> intermediatePntsLst = new List<string>();
        var items = hdnLstWayPoints.Value.Split(';');
        for (int i = 0; i < items.Count() - 1; i++)
        {
            intermediatePntsLst.Add(items[i]);
        }
        rEntity.IntermediatePnts = intermediatePntsLst;
        Session["RouteInfo"] = rEntity;
        Response.Redirect("SelectDates.aspx");
    }
コード例 #7
0
    /*************************************************************************************
      * Method Name      :  ReadRoutesInfo
      * Return Value     :  List<MyRoutesEntity>
      * Input Parameters :  Owner
      * Description      :  This method is used to read all routes for the registered cars to a specific owner
      *************************************************************************************/
    public List<RoutesEntity> ReadRoutesInfo(int Owner)
    {
        List<RoutesEntity> myRoutes = new List<RoutesEntity>();
        SqlCommand cmd = new SqlCommand("select cd.VehicleNumber ,rt.StartDate,rt.EndDate, rt.Startpoint,rt.Destination,rt.RunningDays,rt.Intermediatepoint1,rt.Intermediatepoint2,rt.Intermediatepoint3,rt.Intermediatepoint4,rt.Intermediatepoint5,rt.Intermediatepoint6,rt.Intermediatepoint7,rt.Intermediatepoint8,rt.Intermediatepoint9,rt.Intermediatepoint10,rt.RouteID from tbl_CarDetails cd inner join tbl_RouteTable rt on cd.CarId=rt.CarID and cd.Owner="+Owner , Con);
        try
        {
            Con.Open();
            //Execute the Query

            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                RoutesEntity rEnt=new RoutesEntity
                {
                    VehicleNumber = Convert.ToString(dr[0]),
                    StartDt = Convert.ToDateTime(dr[1]).ToShortDateString(),EndDt = Convert.ToDateTime(dr[2]).ToShortDateString(),
                    StartPnt =Convert.ToString(dr[3]),EndPnt =Convert.ToString(dr[4]),RunningDays=Convert.ToString(dr[5]), RouteID=Convert.ToInt32(dr[16])
                };
             rEnt.AllWayPoints= Convert.ToString(dr[6]);
             if(Convert.ToString(dr[7])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[7]);
             }
             if(Convert.ToString(dr[8])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[8]);
             }
             if(Convert.ToString(dr[9])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[9]);
             }
             if(Convert.ToString(dr[10])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[10]);
             }
                  if(Convert.ToString(dr[11])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[11]);
             }
                  if(Convert.ToString(dr[12])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[12]);
             }
                  if(Convert.ToString(dr[13])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[13]);
             }
                  if(Convert.ToString(dr[14])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[14]);
             }
                  if(Convert.ToString(dr[15])!=string.Empty)
             {
                 rEnt.AllWayPoints+=", "+Convert.ToString(dr[15]);
             }
                myRoutes.Add(rEnt);
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            //Close the Connection from the Database
            Con.Close();
        }

        return myRoutes;
    }
コード例 #8
0
    /*************************************************************************************
      * Method Name      :  FillTripDetails
      * Return Value     :  int
      * Input Parameters :  RoutesEntity
      * Description      :  This method is used to insert all vehical trip details in to Database
      *************************************************************************************/
    public int FillTripDetails(RoutesEntity rEnt)
    {
        SqlCommand cmdCreateRoute = new SqlCommand("usp_InsertRoute", Con);
        cmdCreateRoute.CommandType = CommandType.StoredProcedure;

        cmdCreateRoute.Parameters.AddWithValue("@carId", rEnt.CarId);
        cmdCreateRoute.Parameters.AddWithValue("@startPoint", rEnt.StartPnt);
        //Modlog : Seema - 22/10/2013 - Modified parameter names to align with table column names
        cmdCreateRoute.Parameters.AddWithValue("@Destination", rEnt.EndPnt);
        cmdCreateRoute.Parameters.AddWithValue("@StartDate", rEnt.StartDate);
        cmdCreateRoute.Parameters.AddWithValue("@EndDate", rEnt.EndDate);
        cmdCreateRoute.Parameters.AddWithValue("@runningDays", rEnt.RunningDays);
        int i = 1;
        foreach (var item in rEnt.IntermediatePnts )
        {
            var pnts = item.Substring(0, item.IndexOf(',', item.IndexOf(',') + 1));
            cmdCreateRoute.Parameters.AddWithValue("@Intermediatepoint" + i.ToString(), pnts);
            i++;
        }

        SqlParameter ret = new SqlParameter();
        ret.SqlDbType = SqlDbType.Int;
        ret.Direction = ParameterDirection.ReturnValue;
        cmdCreateRoute.Parameters.Add(ret);

        try
        {
            Con.Open();
            cmdCreateRoute.ExecuteNonQuery();

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            Con.Close();
        }
        return Convert.ToInt32(ret.Value);
    }
コード例 #9
0
    /*************************************************************************************
    * Method Name      :  UpdateRouteInfo
    * Return Value     :  void
    * Input Parameters :  RoutesEntity rentity
    * Description      :  This method is used to update route info for a registered vehical & route
    *************************************************************************************/
    public void UpdateRouteInfo(RoutesEntity rentity)
    {
        try
        {
            string[] iMPnts = rentity.AllWayPoints.Split(new string[] { ", " }, StringSplitOptions.None);
            int i = 1;
            string query = "";

            foreach (var item in iMPnts)
            {
                if (i < iMPnts.Count())
                {
                    query += "intermediatepoint" + i.ToString() + "='" + item + "', ";
                }
                else
                {
                    query += "intermediatepoint" + i.ToString() + "='" + item+"'";
                }
                i++;
            }
            SqlCommand cmd = new SqlCommand("update tbl_RouteTable set startpoint ='" + rentity.StartPnt + "',Destination='"
            + rentity.EndPnt + "',startdate='"+rentity.StartDt +"',enddate='"+rentity.EndDt +"', runningDays='" + rentity.RunningDays + "'," + query + " where routeid=" + rentity.RouteID, Con);
            Con.Open();
            cmd.ExecuteNonQuery();
            return;

        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            Con.Close();
        }
    }
コード例 #10
0
ファイル: SelectDates.aspx.cs プロジェクト: achenxu/CarPool
    protected void btnBook_Click(object sender, EventArgs e)
    {
        if ((rbSingleTrip.Checked == false) && (rbRegularTrips.Checked == false))
        {
            lblMsg.Visible = true;
        }
        DataAccessLayer dalCarPool = new DataAccessLayer();

        if (rbSingleTrip.Checked == true)
        {
            lblMsg.Visible = false;
            RoutesEntity rEntSingleTrp = FillRouteEntitySTrip();

            dalCarPool.FillTripDetails(rEntSingleTrp);

            // Response.Write("<script>alert('Booking is done successfully')</script>");
        }
        else if (rbRegularTrips.Checked)
        {
            lblMsg.Visible = false;
            RoutesEntity rEntMultiTrp = FillRouteEntity();
            string       runningDays  = "";
            if (ChkMon.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkTue.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkWed.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkThu.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkFri.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkSat.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            if (ChkSun.Checked)
            {
                runningDays += "1";
            }
            else
            {
                runningDays += "0";
            }
            rEntMultiTrp.RunningDays = runningDays;

            dalCarPool.FillTripDetails(rEntMultiTrp);
        }
        ClientScript.RegisterStartupScript(this.GetType(), "result", "alert('Registered vehicle Successfully..')", true);
    }