Пример #1
0
        public void Update(CapaEntidad.Estructura.Institucion pDatos)
        {
            try
            {
                string vSQL = string.Empty;

                vSQL += " UPDATE dbo.Institucion ";
                vSQL += "   SET ";
                vSQL += "      NombreInstitucion = @NombreInstitucion";
                vSQL += "      ,IdLote = @IdLote";
                vSQL += "  WHERE IdInstitucion = @IdInstitucion ";

                AbrirConexion();
                vcmd = new SqlCommand(vSQL, vConnection);
                vcmd.Parameters.Add("@IdInstitucion", SqlDbType.Int).Value         = pDatos.IdInstitucion;
                vcmd.Parameters.Add("@NombreInstitucion", SqlDbType.VarChar).Value = pDatos.NombreInstitucion;
                vcmd.Parameters.Add("@IdLote", SqlDbType.Int).Value = pDatos.IdLote;
                vcmd.ExecuteNonQuery();
                CerrarConexion();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #2
0
 public void Delete(CapaEntidad.Estructura.Institucion pDatos)
 {
     CapaDatos.Institucion vNegocio = new CapaDatos.Institucion();
     try
     {
         vNegocio.Delete(pDatos);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex);
     }
 }
Пример #3
0
        public void Delete(CapaEntidad.Estructura.Institucion pDatos)
        {
            DataTable dtResultado = new DataTable();

            try
            {
                string vSQL = string.Empty;

                vSQL += "DELETE FROM dbo.Institucion  ";
                vSQL += " WHERE IdInstitucion = @IdInstitucion ";

                AbrirConexion();
                vcmd = new SqlCommand(vSQL, vConnection);
                vcmd.Parameters.Add("@IdInstitucion", SqlDbType.Int, 32).Value = pDatos.IdInstitucion;
                vcmd.ExecuteNonQuery();
                CerrarConexion();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #4
0
        public void Insert(CapaEntidad.Estructura.Institucion pDatos)
        {
            try
            {
                string vSQL = string.Empty;
                vSQL += "DECLARE @Id INT ";
                vSQL += "SELECT @Id = ISNULL(MAX(IdInstitucion),0) + 1 FROM dbo.Institucion ";

                vSQL += " INSERT INTO dbo.Institucion(IdInstitucion, NombreInstitucion, IdLote) ";
                vSQL += " VALUES(@Id, @NombreInstitucion, @IdLote)";

                AbrirConexion();
                vcmd = new SqlCommand(vSQL, vConnection);
                vcmd.Parameters.Add("@NombreInstitucion", SqlDbType.VarChar).Value = pDatos.NombreInstitucion;
                vcmd.Parameters.Add("@IdLote", SqlDbType.Int).Value = pDatos.IdLote;
                vcmd.ExecuteNonQuery();
                CerrarConexion();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }
Пример #5
0
        private void Aceptar()
        {
            CapaEntidad.Estructura.Institucion vEntidad;
            CapaNegocios.Institucion           vNegociosCreditos = new CapaNegocios.Institucion();
            try
            {
                if (Validar())
                {
                    vEntidad = new CapaEntidad.Estructura.Institucion()
                    {
                        IdInstitucion     = Convert.ToInt32(lblId.Text),
                        NombreInstitucion = txtNombre.Text,
                        IdLote            = Convert.ToInt32(txtLote.Text)
                    };

                    switch (vModo)
                    {
                    case "A":
                        vNegociosCreditos.Insert(vEntidad);
                        break;

                    case "B":
                        vNegociosCreditos.Delete(vEntidad);
                        break;

                    case "M":
                        vNegociosCreditos.Update(vEntidad);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }