******************************************************************************************
FUNCTION SSN01() && Actualiza Tipos de Accidentes
******************************************************************************************
LOCAL oDlg ,;
oLbx ,;
oFKey ,;
oButSalir ,;
oButInsert ,;
oButElim ,;
oButModif ,;
oButPrint ,;
bButSalir ,;
bButInsert ,;
bButElim ,;
bButModif ,;
bButPrint ,;
oModif ,;
bModif ,;
bElim ,;
bInsert ,;
nNewCod:=0 ,;
bButEnab ,;
bButDisab ,;
bPrint ,;
uBuffer ,;
aDatos
IF o_files( { "TIPACC" }, .F., .F. )
oFKey:=tvkey():NEW // CLASE TVKEY (control de teclas de funcion)
SETKEY(VK_F9, {|| EVAL(bButPrint )} )
SETKEY(VK_F2, {|| EVAL(bButInsert)} )
SETKEY(VK_F3, {|| EVAL(bButElim )} )
SETKEY(VK_ESCAPE, {|| oDlg:End() } )
TIPACC->(DBSETORDER("ORD1"))
bButInsert:={|| IIF(oButInsert:lActive,EVAL(bInsert),)}
bButPrint :={|| IIF(oButPrint:lActive,EVAL(bPrint) ,)}
bButElim :={|| IIF(oButElim:lActive,EVAL(bElim) ,)}
bButEnab :={|| oButSalir:Enable() ,;
oButElim:Enable() ,;
oButPrint:Enable() ,;
oButInsert:Enable() ,;
oButInsert:lActive:=.T.,;
oButModif:Enable() ,;
oButSalir:lActive:=.t. ,;
oButElim:lActive:=.t. ,;
oButPrint:lActive:=.t. ,;
oButModif:lActive:=.t. }
bButDisab:={|| oButSalir:Disable() ,;
oButElim:Disable() ,;
oButPrint:Disable() ,;
oButInsert:Disable(),;
oButModif:Disable()}
bPrint :={|| Eval(bButDisab),RepAcc(oDlg),eval(bbutenab),oLbx:refresh(),oLbx:setfocus()}
bInsert :={|nCol, cBuffer, lFirstEdit|;
eval(bButDisab) ,;
TipAcc->(dbgobottom()) ,;
nNewcod:=TIPACC->codtipacc+1,;
iif(Add_Reg("TIPACC",1,.f.) ,;
(TIPACC->codtipacc:=nNewCod ,;
oLbx:Refresh() ,;
oLbx:Click() ,;
uBuffer:=SPACE(LEN(TIPACC->NOMTIPACC)),;
IIF(oLbx:lEditCol( 2, @uBuffer, "@!",,CLR_WHITE,CLR_BLUE,,,,,"Coloque Descripción, [Esc]-Sale" ),;
(TIPACC->NOMTIPACC:=AnsiToOem(uBuffer)),),;
tipacc->(dbunlock())),),;
IIF(len(ALLTRIM(TipAcc->NomTipAcc))=0,(delreg("TipAcc"),;
tipacc->(dbunlock())),),;
TipAcc->(dbgobottom()),;
eval(bButEnab),;
oLbx:Refresh()}
bElim :={|nCol, cBuffer, lFirstEdit|;
eval(bButDisab),;
iif(msgYesno("Desea Eliminar"),(delreg("TipAcc"),;
tipacc->(dbunlock())),oButSalir:Enable()),;
eval(bButEnab),;
TipAcc->(dbgobottom()),;
oLbx:Refresh()}
bModif :={|nCol, cBuffer, lFirstEdit|;
eval(bButDisab),;
oLbx:Click(),;
iif(Reg_lock("TIPACC",1,.f.),;
(uBuffer:=OemToAnsi(TIPACC->NOMTIPACC),;
IIF(oLbx:lEditCol( 2, @uBuffer, "@!",,CLR_WHITE,CLR_BLUE,,,,,"Modifique Descripción, [Esc]-Sale" ),;
(TIPACC->NOMTIPACC:=AnsiToOem(uBuffer)),),),MSGALERT("Registro Bloqueado","Atencion...")),;
IIF(len(ALLTRIM(TipAcc->NomTipAcc))=0,(delreg("TipAcc"),;
tipacc->(dbunlock()),;
TipAcc->(dbgobottom())),;
oButSalir:Enable()),;
eval(bButEnab),;
oLbx:Refresh()}
DEFINE DIALOG oDlg RESOURCE "TipAcc";
FONT oWnd:GetFont();
TITLE 'Tipos de Accidentes' OF oWnd
oDlg:lHelpIcon :=.f. && Apago el Icono de Help
REDEFINE LISTBOX oLbx ;
FIELDS transform(tipacc->codtipacc,'99'),OemToAnsi(tipacc->nomtipacc);
ALIAS "tipacc" ;
HEADERS "Codigo","Descripcion";
FIELDSIZES 55,190;
FONT OFONTGEN;
MESSAGE "Doble Click o [Enter], Modifica";
ID 401 OF oDlg
oLbx:Set3DStyle()
oLbx:nHeaderHeight := 31 // Da la altura del header
oLbx:bKeyDown := {|nKey| IIF( nKey == VK_RETURN,EVAL(bModif),)}
oLbx:nLineHeight := 18 // Da la altura de la linea
oLbx:nFreeze := 1 // Congela hasta la primera columna
oLbx:Ajustify := {1,0} // Justificado de Columnas 0=izq, 1=Der, 2=Cent
oLbx:lAutoEdit := .f. // Prende el AutoEdit
oLbx:lCellStyle := .f. // .t.=> Marca por celda, Si=.f. =>Marca por linea
oLbx:lAdjLastCol := .t. // ajusta la ultima columna
REDEFINE BUTTON oButPrint ID 105 OF oDlg;
MESSAGE "Imprime Reporte";
PROMPT "[F9]-Listar";
ACTION eval(bPrint)
REDEFINE BUTTON oButModif ID 104 OF oDlg;
MESSAGE "Modifica Registro";
PROMPT "[Enter]-Modificar";
ACTION eval(bModif)
REDEFINE BUTTON oButElim ID 103 OF oDlg;
MESSAGE "Elimina Registro";
PROMPT "[F3]-Eliminar";
ACTION eval(bElim)
REDEFINE BUTTON oButInsert ID 102 OF oDlg;
MESSAGE "Incluye Registro";
PROMPT "[F2]-Incluir";
ACTION eval(bInsert)
REDEFINE BUTTON oButSalir ID 101 OF oDlg;
MESSAGE "Sale de Esta Pantalla";
PROMPT "[Esc]-&Salir";
ACTION oDlg:End() && Sale de la Rutina, Por Convencion el ID es 101
ACTIVATE DIALOG oDlg CENTER
oFKey:End()
ENDIF
N_CLOSE("TIPACC")
RETURN NIL