Páginas

Ejercicio 3

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ejercicio1
{
    public partial class ejercico4 : Form
    {
        public ejercico4()
        {
            InitializeComponent();
        }

        private void ejercico4_Load(object sender, EventArgs e)
        {
           
                cbosuel.Items.Add("gerente");
                cbosuel.Items.Add("admi");
                cbosuel.Items.Add("otros");
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sueldo = 0;
            if (cbosuel.Text == "gerente")
            {
                sueldo = 4500;
            }
            else if (cbosuel.Text == "admi")
            {
                sueldo = 2300;
            }
            else if (cbosuel.Text == "otros")
            {
                sueldo = 1000;
            }
            textBox1.Text = sueldo.ToString();
        }
     
    }

}

Ejercicio 2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ejercicio1
{
    public partial class ejercicio3 : Form
    {
        public ejercicio3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int p, c;
            double sub, igv, total;
            p = int.Parse(textBox1.Text);
            c = int.Parse(textBox2.Text);
            sub = p * c;
            igv = p * 0.18;
            total = sub - igv;

            textBox3.Text = sub.ToString();
            textBox4.Text = igv.ToString();
            textBox5.Text = total.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            textBox5.Text = "";


        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }

}

Ejercicio 1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ejercicio1
{
    public partial class ejercicio2 : Form
    {
        public ejercicio2()
        {
            InitializeComponent();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int sue;
            double boni, des, tot;
            sue = int.Parse(textBox1.Text);
            boni = sue * 0.005;
            des = sue * 0.002;
            tot = (sue + boni) - des;
            textBox2.Text = boni.ToString();
            textBox3.Text = des.ToString();
            textBox4.Text = tot.ToString();
        }
    }

}

Hallar la suma de dos números

Hallar la suma de dos números:
Module Module2
    Dim NUM1, NUM2, SUMA As Integer
    Sub Main()
        Write("Ingrese Primer Número: ")
        NUM1 = ReadLine()
        Write("Ingrese Primer Segundo: ")
        NUM2 = ReadLine()
        SUMA = NUM1 + NUM2
        WriteLine()
        WriteLine("La suma es : " & SUMA)
        WriteLine()
        WriteLine("Pulse Enter para continuar....")
        ReadLine()
    End Sub

End Module

Hallar el promedio de tres notas

Hallar el promedio de tres notas en consola

Imports System.Console
Module Module1
    Dim Nota1, Nota2, Nota3, PROM As Decimal
    Sub Main()
        Title = "ALFONSO"
        SetCursorPosition(15, 2)
        ForegroundColor = ConsoleColor.DarkYellow

        WriteLine("PROMEDIO DE 3 NOTAS")
        WriteLine()
        ResetColor()
        Write("ingrese Nota 1: ")
        Nota1 = ReadLine()
        Write("ingrese Nota 2: ")
        Nota2 = ReadLine()
        Write("ingrese Nota 3: ")
        Nota3 = ReadLine()
        PROM = (Nota1 + Nota2 + Nota3) / 3
        WriteLine()
        If (PROM > 10.5) Then
            ForegroundColor = ConsoleColor.Blue
            WriteLine("APROBADO")
        Else
            WriteLine()
            Console.ForegroundColor = ConsoleColor.Red
            WriteLine("DESAPROBADO")
        End If
        WriteLine()
        Console.ForegroundColor = ConsoleColor.Green
        WriteLine("PULSE ENTER PARA CONTINUAR....")
        ReadLine()
    End Sub
End Module

Encriptar y desencriptar en sql server

Crearemos nuestra base de datos para encriptar nuestra contraseña:


create database userEncriptar
use userEncriptar
go
create table usuario
(
id_usuario INT primary key,
usuario varchar(20) not null,
pass varbinary(500) not null
)
--Luego crearemos una función que nos permita encriptar:

go

 create function ENCRIPTA_PASS
 (
 @clave varchar(50)
 )
 returns VarBinary(500)
 as
 begin
 declare @pass as VarBinary(500)
 set @pass=ENCRYPTBYPASSPHRASE('clave',@clave)
 return @pass
 end

--Insertamos un usuario

insert into usuario values('12 ','CARLOS',dbo.ENCRIPTA_PASS('CARLOS123'))


 Luego crearemos una función que nos permita desencriptar:
 go
  create function desencriptar_pass
  (
  @clave varbinary(500)
  )
  returns varchar(50)
  as
  begin
  declare @pass as varchar(50)
  set @pass=DECRYPTBYPASSPHRASE('clave',@clave)
  return @pass
  end


  select id_usuario,usuario,dbo.desencriptar_pass(pass) from usuario


Ahora visualizamos los campos insertados: