lunes, 4 de marzo de 2013

COMO CREAR UNA TABLA CON SUS RELACIONES EN SQL SERVER 2008


COMO CREAR UNA TABLA CON SUS RELACIONES EN SQL SERVER 2008



create database BBOnline;
use BBOnline;

create table Categorias(
IdCategoria bigint not null identity,
Nombre nvarchar (50) not null,
Descripcion nvarchar (100) not null,
primary key (IdCategoria)
);


create table Usuarios(
IdUsuario bigint not null identity,
Nombre  nvarchar (50) not null,
Apellido  nvarchar (50) not null,
Direccion  nvarchar (50) not null,
Telefono  nvarchar (50) not null,
Contraseña nvarchar (50) not null,
TipoUsuario nvarchar (50) not null,
primary key (IdUsuario)
);

create table Editoriales(
IdEditorial bigint not null identity,
Nombre nvarchar (50) not null,
pais nvarchar (50) not null,
Telefono nvarchar (50) not null,
primary key (IdEditorial)
);

create table Autores(
IdAutor bigint not null identity,
Nombre nvarchar (50) not null,
Apellido nvarchar (50) not null,
pais nvarchar (50) not null,
AñoNacimiento int not null,
primary key (IdAutor)
);


create table Libros(
IdLibro bigint not null identity,
Titulo nvarchar (100) not null,
IdAutor bigint not null,
IdEditorial bigint  not null,
Fecha date not null,
IdUsuario bigint not null,
Descripcion nvarchar (100) not null,
IdCategoria bigint not null,
AñoPublicacion int not null,
Edición int not null,
NumerodeVisitas int not null,
ArchivoLibro nvarchar (200) not null,
primary key (IdLibro),
foreign key(IdCategoria)references Categorias(IdCategoria),
foreign key(IdAutor)references Autores(IdAutor),
foreign key(IdEditorial)references Editoriales(IdEditorial),
foreign key(IdUsuario)references Usuarios(IdUsuario),
);

create table Comentarios(
IdComentario bigint not null identity,
Nombre nvarchar (50) not null,
Fecha date not null,
DescripcionCom nvarchar (200) not null,
IdUsuario  bigint not null,
primary key (IdComentario),
foreign key(IdUsuario)references Usuarios(IdUsuario),
);




miércoles, 26 de septiembre de 2012

CALCULADORA


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

namespace calcualdora
{
    public partial class Form1 : Form
    {
        Double x,y, resultados;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(txtprimernumero.Text);
            y = Convert.ToDouble(txtsegundonumero.Text);
            TxtResultado.Text = string.Format("{0:f2}", x + y);
            txtExprecion.Text = Convert.ToString(Convert.ToDouble(txtprimernumero.Text)+"+" + Convert.ToDouble(txtsegundonumero.Text));
            MessageBox.Show("Usted ha realizado una Suma");
      }

        private void button2_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(txtprimernumero.Text);
            y = Convert.ToDouble(txtsegundonumero.Text);
            TxtResultado.Text = string.Format("{0:f2}", x - y);
            txtExprecion.Text = Convert.ToString(Convert.ToDouble(txtprimernumero.Text) +"-" + Convert.ToDouble(txtsegundonumero.Text));
            MessageBox.Show("Usted ha realizado una Resta");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(txtprimernumero.Text);
            y = Convert.ToDouble(txtsegundonumero.Text);
            TxtResultado.Text = string.Format("{0:f2}", x * y);
            txtExprecion.Text = Convert.ToString(Convert.ToDouble(txtprimernumero.Text) + "*" + Convert.ToDouble(txtsegundonumero.Text));
            MessageBox.Show("Usted ha realizado una Multiplicacion");

        }

        private void button4_Click(object sender, EventArgs e)
        {
            x = Convert.ToDouble(txtprimernumero.Text);
            y = Convert.ToDouble(txtsegundonumero.Text);
            TxtResultado.Text = string.Format("{0:f2}", x / y);
            txtExprecion.Text = Convert.ToString(Convert.ToDouble(txtprimernumero.Text) + "/" + Convert.ToDouble(txtsegundonumero.Text));
            MessageBox.Show("Usted ha realizado una Divicion");

        }

        private void button5_Click(object sender, EventArgs e)
        {
            txtprimernumero.Text = "";
            txtsegundonumero.Text = "";
            TxtResultado.Text = "";
            txtExprecion.Text = "";
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
   }

HACI QUEDA EL DICEÑO