Esempio n. 1
0
        public static Driver GetDriverByID_Driver(int driverID)
        {
            Driver newDriver = new Driver();

            dbconn = new DBConnectionServices("JCIConnection");
            dbconn.SetSqlCommandStoredProcedure("GetDriverByID");
            dbconn.AddParameterToList("DriverID", SqlDbType.Int, driverID);
            dbconn.SetSqlParameters();

            if (dbconn.ExecuteStoredProcedureDataTable().Rows.Count == 1)
            {
                foreach (DataRow driverDR in dbconn.ExecuteStoredProcedureDataTable().Rows)
                {
                    object dropofftime     = ValueValidater.ReturnValue(driverDR["DropOffTime"]);
                    object dropofflocation = ValueValidater.ReturnValue(driverDR["DropOffLocation"]);

                    if (dropofftime != null && dropofflocation != null)
                    {
                        newDriver = new Driver(driverID, driverDR["FirstName"].ToString(),
                                               driverDR["LastName"].ToString(), driverDR["BadgeNumber"].ToString(),
                                               driverDR["StartDate"].ToString(), driverDR["EndDate"].ToString());
                    }
                    else
                    {
                        newDriver = new Driver(driverID, driverDR["FirstName"].ToString(),
                                               driverDR["LastName"].ToString(), driverDR["BadgeNumber"].ToString(),
                                               driverDR["StartDate"].ToString(), driverDR["EndDate"].ToString());
                    }
                }
            }

            return(newDriver);
        }
Esempio n. 2
0
        public static List <Driver> GetDrivers_ListDriver()
        {
            List <Driver> DriverList = new List <Driver>();
            Driver        newDriver  = new Driver();

            dbconn = new DBConnectionServices("JCIConnection");
            dbconn.SetSqlCommandStoredProcedure("GetDrivers");

            foreach (DataRow driverDR in dbconn.ExecuteStoredProcedureDataTable().Rows)
            {
                object dropofftime     = ValueValidater.ReturnValue(driverDR["DropOffTime"]);
                object dropofflocation = ValueValidater.ReturnValue(driverDR["DropOffLocation"]);

                if (dropofftime != null && dropofflocation != null)
                {
                    newDriver = new Driver((int)driverDR["DriverID"], driverDR["FirstName"].ToString(),
                                           driverDR["LastName"].ToString(), driverDR["BadgeNumber"].ToString(),
                                           driverDR["StartDate"].ToString(), driverDR["EndDate"].ToString());
                }
                else
                {
                    newDriver = new Driver((int)driverDR["DriverID"], driverDR["FirstName"].ToString(),
                                           driverDR["LastName"].ToString(), driverDR["BadgeNumber"].ToString(),
                                           driverDR["StartDate"].ToString(), driverDR["EndDate"].ToString());
                }
            }

            return(DriverList);
        }
Esempio n. 3
0
        public static Route GetRouteByID_Route(int routeid)
        {
            Route route = new Route();

            dbconn = new DBConnectionServices("JCIConnection");
            dbconn.SetSqlCommandStoredProcedure("GetRouteByID");
            dbconn.AddParameterToList("routeid", SqlDbType.Int, routeid);

            dbconn.SetSqlParameters();

            if (dbconn.ExecuteStoredProcedureDataTable().Rows.Count == 1)
            {
                foreach (DataRow routeDR in dbconn.ExecuteStoredProcedureDataTable().Rows)
                {
                    object dropofftime     = ValueValidater.ReturnValue(routeDR["DropOffTime"]);
                    object dropofflocation = ValueValidater.ReturnValue(routeDR["DropOffLocation"]);

                    if (dropofftime != null && dropofflocation != null)
                    {
                        route = new Route(routeid, routeDR["PickupTime"].ToString(), routeDR["PickUpLocation"].ToString(),
                                          (Status)routeDR["StatusID"], dropofftime.ToString(), dropofflocation.ToString());
                    }
                    else
                    {
                        route = new Route(routeid, routeDR["PickupTime"].ToString(), routeDR["PickUpLocation"].ToString(),
                                          (Status)routeDR["StatusID"], null, null);
                    }
                }
            }

            return(route);
        }