Esempio n. 1
0
        /// <summary>
        /// Ya habiendo verificado antes que exista en la base de datos y al ser unica la entidad encontrada, la leerá y me devolverá la informacion
        /// </summary>
        /// <param name="nombre"></param>
        /// <returns></returns>
        public Unidad BuscarUnidad(string nombre)
        {
            try
            {
                string command = "SELECT * FROM EntidadesMilitares where Nombre='" + nombre + "'";

                SqlCommand sqlCommand = new SqlCommand(command, this.sqlConnection);

                sqlConnection.Open();

                SqlDataReader reader = sqlCommand.ExecuteReader();
                reader.Read();
                string nombreUnidad = (string)reader["Nombre"];
                int    comida       = (int)reader["Comida"];
                int    madera       = (int)reader["Madera"];
                int    oro          = (int)reader["Oro"];
                int    piedra       = (int)reader["Piedra"];
                Unidad unidad       = new Unidad(nombreUnidad, madera, comida, oro, piedra);
                return(unidad);
            }
            finally
            {
                if (this.sqlConnection.State == System.Data.ConnectionState.Open)
                {
                    this.sqlConnection.Close();
                }
            }
        }
 public frmAltaAlquilerFinal(Entidades.Propiedad prop, Entidades.Unidad uni, Entidades.Inquilino inq, DateTime fecInicio, DateTime fecFin)
 {
     InitializeComponent();
     this.prop     = prop;
     this.uni      = uni;
     this.inq      = inq;
     this.fechaIni = fecInicio;
     this.fechaFin = fecFin;
     this.LlenarCampos();
 }