示例#1
0
        public static List <EmployeeVehicle> GetEmployeeVehicleListByEmployeeId(int employeeId)
        {
            List <EmployeeVehicle> list = new List <EmployeeVehicle>();

            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeVehicleListByEmployeeId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeVehicle employeeVehicle = new EmployeeVehicle();
                    employeeVehicle.EmployeeVehicleId = Convert.ToInt32(dataReader["EmployeeVehicleId"]);
                    employeeVehicle.VehicleId         = Convert.ToInt32(dataReader["VehicleId"]);
                    employeeVehicle.Registration      = dataReader["Registration"].ToString();
                    employeeVehicle.Type      = dataReader["Type"].ToString();
                    employeeVehicle.VINNumber = dataReader["VINNumber"].ToString();
                    employeeVehicle.Model     = dataReader["Model"].ToString();
                    employeeVehicle.IsMapped  = Convert.ToInt32(dataReader["isMapped"]);

                    list.Add(employeeVehicle);
                }
            }
            return(list);
        }
示例#2
0
        public static EmployeeVehicle GetEmployeeVehicleByEmployeeIdVehicleId(int employeeId, int vehicleId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeVehicleByEmployeeIdVehicleId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeId", DbType.Int32, employeeId);
            db.AddInParameter(dbCommand, "@VehicleId", DbType.Int32, vehicleId);
            db.AddOutParameter(dbCommand, "@EmployeeVehicleId", DbType.Int32, 4);
            db.ExecuteNonQuery(dbCommand);
            EmployeeVehicle employeeVehicle = new EmployeeVehicle();

            employeeVehicle.EmployeeVehicleId = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeVehicleId"));
            return(employeeVehicle);
        }