//Get car type public List <CarTypeDTO> GetCartypes() { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "select * from type_of_car"; cmd.CommandType = CommandType.Text; List <CarTypeDTO> carTypeDtoList = new List <CarTypeDTO>(); reader = cmd.ExecuteReader(); while (reader.Read()) { carTypeDtoList.Add(new CarTypeDTO { CarTypeId = reader.GetInt32(0), CarTypeDescription = reader.GetString(1), CarTypeStatus = (bool)reader["status"] }); } reader.Close(); conexion.CerrarConexion(); return(carTypeDtoList); }
public UserDTO ValidateLoggin(String userCard, String userClave) { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "select * from users where user_name = '" + userCard + "' and user_password = '******'"; cmd.CommandType = CommandType.Text; //Remember to encode the password reader = cmd.ExecuteReader(); if (reader.HasRows)//Exite el carro! { reader.Read(); status = (bool)reader["user_status"]; if (!status) { user = new UserDTO { Message = "Usuario desactivado! favor contactar al administrador..." }; reader.Close(); conexion.CerrarConexion(); return(user); } else { user = new UserDTO { UserId = reader.GetInt32(0), EmployeeId = reader.GetInt32(1), RolCode = reader.GetString(2), IdentificationCard = reader.GetString(3), UserName = reader.GetString(4), Password = reader.GetString(5), Status = status, Message = "OK" }; reader.Close(); conexion.CerrarConexion(); return(user); } } else { user = new UserDTO { Message = "Usuario o Clave erronea, favor validar o contactar al administrador!" }; reader.Close(); conexion.CerrarConexion(); return(user); } }
//Searchs... //Add public void ADD(EmployeeDTO dto) { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "insert into employees values(@dominicanCard, @employeeCard, @workSession, @name, @lastName, getDate(), @workPosition, @comission, @status)"; cmd.CommandType = CommandType.Text; FillEmployeeDtoParams(cmd, dto); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); conexion.CerrarConexion(); }
//Add public void ADD(CustomerDTO dto) { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "insert into customers values(@name, @lastName, @cedula, @type, @creditCard, @creditLimit, @status, @RNC)"; cmd.CommandType = CommandType.Text; FillCustomerDtoParams(cmd, dto); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); conexion.CerrarConexion(); }
//Add public void ADD(CarDTO carDTO) { if (GetCarById(carDTO.LicensePlate, carDTO.ChasisNum, carDTO.EngineNum)) { MessageBox.Show("ERROR : No se acepta duplicidad de registros. Este vehiculo, ya esta en el sistema! favor validar la placa: " + carDTO.LicensePlate + ", el chasis: " + carDTO.ChasisNum + " o el numero de motor: " + carDTO.EngineNum); } else { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "insert into carInfo values (@Base64Photo, @CarType, @CarBrand, @CarModel, @CarFabYear, @CarChasisNum, @CarEngineNum, @CarLicensePlate, @CarColor, @FuelType, @QuantityOfFuel, @CarNumberOfDoors, @CarCapacityOfPassangers, @CarConditions, @CarUseInKM, @CarInvComment, GETDATE(), null, @CarStatus)"; cmd.CommandType = CommandType.Text; FillCarDtoParams(cmd, carDTO); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); conexion.CerrarConexion(); } }
//Add public bool AddNewModel(CarModelDTO carModelDTO) { //Validate duplicates if (GetModelByDes(carModelDTO.ModelDescription)) { MessageBox.Show("Este modelo " + carModelDTO.ModelDescription + " ya existe en el sistema"); return(false); } else { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "insert into car_model values (@CarModelDes, @CarBrandId, @CarBrand, @status)"; cmd.CommandType = CommandType.Text; FillCarModelDtoParams(carModelDTO); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); conexion.CerrarConexion(); return(true); } }
public List <RentDTO> GetActiveRents() { cmd.Connection = conexion.AbrirConexion(); cmd.CommandText = "select * from rents where state = 1"; cmd.CommandType = CommandType.Text; reader = cmd.ExecuteReader(); List <RentDTO> ListaGenerica = new List <RentDTO>(); while (reader.Read()) { ListaGenerica.Add(new RentDTO { Id = reader.GetInt32(0), InspectionId = reader.GetInt32(1), EmployeeInfo = reader.GetString(2), CarId = reader.GetInt32(3), //can not be null reader.GetInt32(4) CarInfo = reader.GetString(4), CustomerInfo = reader.GetString(5), RentDate = reader.GetString(6), DevolutionDate = reader.GetString(7), MontPerDay = reader.GetInt32(8), QuantityOfDays = reader.GetInt32(9), Comment = reader.GetString(10),//reader.GetString(18) State = (bool)reader["state"] }); } conexion.CerrarConexion(); reader.Close(); return(ListaGenerica); }