Exemplo n.º 1
0
        public static List <EmployeeFuel> GetEmployeeFuelList(int employeeId)
        {
            List <EmployeeFuel> list = new List <EmployeeFuel>();

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

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

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    EmployeeFuel employeeFuel = new EmployeeFuel();
                    employeeFuel.EmployeeFuelId    = Convert.ToInt32(dataReader["EmployeeFuelId"]);
                    employeeFuel.EmployeeVehicleId = Convert.ToInt32(dataReader["EmployeeVehicleId"]);
                    employeeFuel.EmployeeId        = Convert.ToInt32(dataReader["EmployeeId"]);
                    employeeFuel.DateOfFuel        = Convert.ToDateTime(dataReader["DateOfFuel"]);
                    employeeFuel.PaymentType       = dataReader["PaymentType"].ToString();
                    employeeFuel.Value             = Convert.ToDouble(dataReader["Value"]);
                    employeeFuel.Litres            = Convert.ToDouble(dataReader["Litres"]);
                    employeeFuel.KMReading         = Convert.ToDouble(dataReader["KMReading"]);

                    employeeFuel.Registration = dataReader["Registration"].ToString();
                    employeeFuel.Type         = dataReader["Type"].ToString();
                    employeeFuel.VINNumber    = dataReader["VINNumber"].ToString();
                    employeeFuel.Model        = dataReader["Model"].ToString();
                    employeeFuel.Attachment   = dataReader["Attachment"].ToString();

                    list.Add(employeeFuel);
                }
            }
            return(list);
        }
Exemplo n.º 2
0
        public static EmployeeFuel GetEmployeeFuelByEmployeeFuelId(int employeeFuelId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeFuelByEmployeeFuelId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@EmployeeFuelId", DbType.Int32, employeeFuelId);
            db.AddOutParameter(dbCommand, "@EmployeeId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@EmployeeVehicleId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@VehicleId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@DateOfFuel", DbType.DateTime, 8);
            db.AddOutParameter(dbCommand, "@PaymentTypeId", DbType.Int32, 4);
            db.AddOutParameter(dbCommand, "@Value", DbType.Double, 8);
            db.AddOutParameter(dbCommand, "@Litres", DbType.Double, 8);
            db.AddOutParameter(dbCommand, "@KMReading", DbType.Double, 8);
            db.AddOutParameter(dbCommand, "@Attachment", DbType.String, 1000);
            db.ExecuteNonQuery(dbCommand);
            EmployeeFuel employeeFuel = new EmployeeFuel();

            employeeFuel.EmployeeFuelId    = employeeFuelId;
            employeeFuel.EmployeeId        = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeId"));
            employeeFuel.EmployeeVehicleId = Convert.ToInt32(db.GetParameterValue(dbCommand, "EmployeeVehicleId"));
            employeeFuel.VehicleId         = Convert.ToInt32(db.GetParameterValue(dbCommand, "VehicleId"));
            employeeFuel.DateOfFuel        = Convert.ToDateTime(db.GetParameterValue(dbCommand, "DateOfFuel"));
            employeeFuel.PaymentTypeId     = Convert.ToInt32(db.GetParameterValue(dbCommand, "PaymentTypeId"));
            employeeFuel.Value             = Convert.ToDouble(db.GetParameterValue(dbCommand, "Value"));
            employeeFuel.Litres            = Convert.ToDouble(db.GetParameterValue(dbCommand, "Litres"));
            employeeFuel.KMReading         = Convert.ToDouble(db.GetParameterValue(dbCommand, "KMReading"));
            employeeFuel.Attachment        = db.GetParameterValue(dbCommand, "Attachment").ToString();

            return(employeeFuel);
        }
Exemplo n.º 3
0
        public static EmployeeFuel GetEmployeeFuelByVehicleIdEmployeeId(int vehicleId, int employeeId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("Spar-StoreRep");
            string    sqlCommand = "GetEmployeeFuelByVehicleIdEmployeeId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

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

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