I need help! I'm working with inheritance. Client: Person and I need to insert from the Client class, where the methods are (register, modify, delete, list). I need you to insert yourself in a method! The idea that I have is to identify the id of the person to insert the client, and identify the client type.
public void Registrar()
{
string sql = string.Format("Insert into Persona (Nombre, ApPaterno, ApMaterno, FechaNac, Documento, Direccion, Telefono, Sexo, Email)
values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}')", this.Nombre, this.ApPaterno, this.ApMaterno, this.FechaNac, this.Documento, this.Direccion, this.Telefono, this.Sexo, this.Email);
//("Insert into Cliente(Id, codigo, TipoCliente) values({0})", this.ID, this.codigo, this.TipoCliente)
Conexion.EjecutarComando(sql);
}
My database is the following:
create table Persona(
Id int not null identity(1,1),
Nombre varchar(50) not null,
ApPaterno varchar(50),
ApMaterno varchar(50),
FechaNac date not null,
Documento varchar(20) not null,
Direccion varchar(50),
Telefono varchar(20),
Sexo varchar(20) not null,
Email varchar(50),
constraint pk_persona primary key(Id),
)
create table TipoCliente(
Id int identity(1,1) not null,
Nombre varchar(50) not null,
constraint pk_TipoCliente primary key(Id),
)
create table Cliente(
Id int not null,
codigo int not null,
TipoCliente int not null,
constraint pk_cliente primary key(Id),
constraint fk_persona_Cliente foreign key(Id)
references Persona(Id) on delete cascade on update cascade,
constraint fk_Cliente_TipoCliente foreign key(TipoCliente)
references TipoCliente(Id) on delete cascade on update cascade
)