Exemplo n.º 1
0
        public void Actualizar(EntrevistaEncargado entEnc)
        {
            // SqlConnection requiere el using System.Data.SqlClient;
            SqlConnection conexion = new SqlConnection(Conexion.Cadena);

            try
            {
                conexion.Open(); // un error aca: revisar cadena de conexion
                // El command permite ejecutar un comando en la conexion establecida
                SqlCommand comando = new SqlCommand("PA_ActualizarEntrevistaEncargado", conexion);
                // Como es en Store Procedure se debe indicar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                // Si el SP requeire parametros se le deben asignar al comando

                comando.Parameters.AddWithValue("@Numero", entEnc.Numero);


                // Finalmente ejecutamos el comando
                // al ser un update no requiere retornar un consulta
                comando.ExecuteNonQuery();
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
            }
        }
Exemplo n.º 2
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (cboMotivos.SelectedIndex == -1)
            {
                MessageBox.Show("Debe seleccionar un motivo de atencion ");
                cboMotivos.Focus();
                return;
            }

            if (txtResumen.Text == "")
            {
                MessageBox.Show("Debe digitar un resumen de la situacion encontrada ");
                txtResumen.Focus();
                return;
            }

            if (txtRecomendaciones.Text == "")
            {
                MessageBox.Show("Debe digitar las recomendaciones dadas ");
                txtRecomendaciones.Focus();
                return;
            }


            try
            {
                EntrevistaEncargado entrevista = new EntrevistaEncargado();

                entrevista.ResumenSituacion = txtResumen.Text;
                entrevista.Recomendaciones  = txtRecomendaciones.Text;
                entrevista.Motivo           = (MotivoAtencion)cboMotivos.SelectedItem;

                MessageBox.Show("  Datos guardados con exito ");
                FrmExpediente.entrevistaEncargado.Add(entrevista);
                Limpiar();
                Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Error al ingresar la entrevista con el padre/madre/encargado"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public override void Guardar()
        {
            EntrevistaEncargado ent = new EntrevistaEncargado();

            if (ent.Numero == 0)
            {
                throw new ApplicationException("Debe digitar el nombre");
            }

            EntrevistaEncargadoDatos datos = new EntrevistaEncargadoDatos();

            if (datos.SeleccionarPorId(ent.Numero) == null)
            {
                datos.Insertar(ent);
            }
            else
            {
                datos.Actualizar(ent);
            }
        }
Exemplo n.º 4
0
        //public void Eliminar(int EncargadoId)
        //{
        //    Encargado enc = new Encargado();
        //    enc.Identificacion = EncargadoId.ToString();
        //    this.Eliminar(enc);
        //}
        //public void Eliminar(Encargado enc)
        //{
        //    // SqlConnection requiere el using System.Data.SqlClient;
        //    SqlConnection conexion = new SqlConnection(Conexion.Cadena);
        //    try
        //    {
        //        conexion.Open(); // un error aca: revisar cadena de conexion
        //        // El command permite ejecutar un comando en la conexion establecida
        //        SqlCommand comando = new SqlCommand("PA_EliminarEncargado", conexion);
        //        // Como es en Store Procedure se debe indicar el tipo de comando
        //        comando.CommandType = System.Data.CommandType.StoredProcedure;
        //        // Si el SP requeire parametros se le deben asignar al comando
        //        comando.Parameters.AddWithValue("@Identificacion", enc.Identificacion);

        //        // al ser un update no requiere retornar un consulta
        //        comando.ExecuteNonQuery();
        //    }
        //    catch (Exception)
        //    {
        //        throw;
        //    }
        //    finally
        //    {
        //        conexion.Close();
        //    }
        //}

        public List <EntrevistaEncargado> SeleccionarTodos()
        {
            // SqlConnection requiere el using System.Data.SqlClient;
            SqlConnection conexion           = new SqlConnection(Conexion.Cadena);
            List <EntrevistaEncargado> lista = new List <EntrevistaEncargado>();

            try
            {
                conexion.Open(); // un error aca: revisar cadena de conexion
                // El command permite ejecutar un comando en la conexion establecida
                SqlCommand comando = new SqlCommand("PA_SeleccionarEntrevistaEncargado", conexion);
                // Como es en Store Procedure se debe indicar el tipo de comando
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                // NO recibe parametros
                // Finalmente ejecutamos el comando
                // al ser una consulta debemos usar ExecuteReader
                SqlDataReader reader = comando.ExecuteReader();
                // es necesario recorrer el reader para extraer todos los registros
                while (reader.Read()) // cada vez que se llama el Read retorna una tupla
                {
                    EntrevistaEncargado entEnc = new EntrevistaEncargado();

                    entEnc.Numero = Convert.ToInt32(reader["Numero"]);
                    lista.Add(entEnc);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conexion.Close();
            }

            return(lista);
        }