Hola Henoc.
Segun entiendo el problema se resume a pasar columnas de un
TStringGrid (origen) a un
TStringGrid (destino), para lo cuál debes basarte en la elección previa de un criterio que puede ser:
- Nacidos en la misma fecha.
- Nacidos en fecha previa.
Creo que lo más sencillo es usar un
TEdit para ingresar la fecha y un
TComboBox para seleccionar el criterio y cuyos Items sean:
Entonces podrías hacer:
Código:
#define COL_FENAC 6
void PacientesXFecha(TStringGrid *Orig, TStringGrid *Dest, TDate aDate, char TC)
{
int n = Dest->FixedRows, r;
/* Limpiar destino */
for(r = n; r < Dest->RowCount; r ++) Dest->Rows[r]->Clear();
/* Copiar datos */
for( r = Orig->FixedRows; r < Orig->RowCount; r++) {
// Igual a
if(TC == 0 && StrToDate(Orig->Cells[COL_FENAC][r]) == aDate) {
for(int c= Dest->FixedCols; c < Dest->ColCount; c++)
Dest->Cells[c][n] = Orig->Cells[c][r];
n++;
}
// Menor a
if(TC == 1 && StrToDate(Orig->Cells[COL_FENAC][r]) < aDate) {
for(int c= Dest->FixedCols; c < Dest->ColCount; c++)
Dest->Cells[c][n] = Orig->Cells[c][r];
n++;
}
}
}
Ejemplo de llamada:
Código:
void __fastcall TForm1::btnBuscarClick(TObject *Sender)
{
PacientesXFecha(Form5->StringGrid1,
Form15->StringGrid1,
StrToDate(Edit1->Text),
ComboBox1->ItemIndex);
}
Saludos.