void __fastcall TForm1::nuevo_registro(TStringGrid * grid, TTable * tabla)
{
String grueso, ancho, largo, def, clase;
int i,piezas,pt;
double volm3;
tabla->TableName="inventario";
tabla->Open();
for(i=1;i<grid->RowCount;i++)
{
grueso=grid->Cells[1][i];
ancho=grid->Cells[2][i];
largo=grid->Cells[3][i];
if(!grid->Cells[4][i].IsEmpty())
piezas=grid->Cells[4][i].ToInt();
else piezas=0;
if(!grid->Cells[5][i].IsEmpty())
pt=grid->Cells[5][i].ToInt();
else pt=0;
if(!grid->Cells[6][i].IsEmpty())
volm3=grid->Cells[6][i].ToDouble();
else volm3=0;
if((grueso.IsEmpty()==true)||(ancho.IsEmpty()==true)||(piezas==0)||(volm3==0))
NULL;
else
{
tabla->Insert();
tabla->FieldByName("Grueso")->Value=grueso;
tabla->FieldByName("Ancho")->Value=ancho;
tabla->FieldByName("Largo")->Value=largo;
tabla->FieldByName("Piezas")->Value=piezas;
tabla->FieldByName("Volpt")->Value=pt;
tabla->FieldByName("Volmc")->Value=volm3;
tabla->FieldByName("Definicion")->Value="Madera aserrada";
tabla->FieldByName("Especie")->Value="Pino";
tabla->FieldByName("Clase")->Value="Producto primario";
tabla->Post();
}
}
tabla->Close();
}