Esempio n. 1
0
 protected Vehicle CreateVehicle()
 {
     try
     {
         //Creating the vehicle
         Vehicle vehicle = new Vehicle();
         VehicleType vehicleType = new VehicleType();
         vehicle.VehiclePlate = textboxLicense.Value;
         if (hiddenTypeValue.Value.Equals(string.Empty))
         {
             vehicleType.Id = Convert.ToInt32(selectType.Items[0].Value);
             vehicleType.Name = selectType.Items[0].Text;
         }
         else
         {
             vehicleType.Id = Convert.ToInt32(hiddenTypeValue.Value);
             vehicleType.Name = selectType.Items.FindByValue(hiddenTypeValue.Value).Text;
         }
         vehicle.Type = vehicleType;
         return vehicle;
     }
     catch (FormatException)
     {
         return null;
     }
 }
Esempio n. 2
0
 public void InsertVehicleType(VehicleType vehicleType)
 {
     SqlConnection connection = ManageDatabaseConnection("Open");
     using (SqlCommand insert = new SqlCommand(@"InsertVehicleType", connection))
     {
         insert.CommandType = CommandType.StoredProcedure;
         insert.Parameters.Add("@Name", SqlDbType.VarChar).Value = vehicleType.Name;
         insert.ExecuteNonQuery();
     }
     connection = ManageDatabaseConnection("Close");
 }
Esempio n. 3
0
 public void UpdateVehicleType(VehicleType vehicleType)
 {
     SqlConnection connection = ManageDatabaseConnection("Open");
     using (SqlCommand update = new SqlCommand(@"UpdateVehicleType", connection))
     {
         update.CommandType = CommandType.StoredProcedure;
         update.Parameters.Add("@Id", SqlDbType.Int).Value = vehicleType.Id;
         update.Parameters.Add("@Name", SqlDbType.VarChar).Value = vehicleType.Name;
         update.ExecuteNonQuery();
     }
     connection = ManageDatabaseConnection("Close");
 }
Esempio n. 4
0
 protected VehicleType CreateVehicleType()
 {
     VehicleType vehicleType = new VehicleType();
     try
     {
         vehicleType.Name = textboxVehicleType.Value;
         return vehicleType;
     }
     catch (FormatException)
     {
         buttonStyle.buttonStyleRed(buttonErrors, "Invalid data, please check it or contact with us.");
         return null;
     }
 }
 public int UpdateVehicleType(VehicleType vehicleType)
 {
     try
     {
         if (vehicleType.Name.Equals(string.Empty))
         {
             return 1;
         }
         else
         {
             vehicleTypeData.UpdateVehicleType(vehicleType);
             return 0;
         }
     }
     catch (SqlException)
     {
         return 2;
     }
 }
Esempio n. 6
0
        protected void UpdateVehicleType(VehicleType vehicleType)
        {
            if (vehicleType != null)
            {
                switch (vehicleTypeRules.UpdateVehicleType(vehicleType))
                {
                    case 0:
                        textboxVehicleType.Value = "";
                        buttonStyle.buttonStyleBlue(buttonErrors, "Vehicle type updated successful.");
                        break;
                    case 1:
                        buttonStyle.buttonStyleWhite(buttonErrors, "Vehicle type name field is empty.");
                        break;
                    case 2:
                        buttonStyle.buttonStyleRed(buttonErrors, "An error ocurred updating the Vehicle type, please check data or contact we us.");
                        break;

                }
            }
        }