//--------------------------------------------------------------------------- #include #include #pragma hdrstop #include "Inicio1.h" #include "Inicializador.h" #include "TpvProductos.h" #include "TpvStockActual1.h" #include "TpvVentas.h" #include "TpvCmp.h" #include "TpvVntClt.h" #include "TpvVntProd.h" #include "TpvBlcDVnt.h" #include "TpvVntEmpl.h" #include "TpvBlcMVnt.h" #include "TpvCmpProv.h" #include "TpvAccessControl.h" #include "TpvSelectActiveUser.h" #ifdef EXIST_CFG #include "TpvCFG.h" #endif //#include "AcercaDe.h" //--------------------------------------------------------------------------- #pragma resource "*.dfm" TMenuInicio *MenuInicio; //--------------------------------------------------------------------------- #define _PRODUCTOS #define _STOCKACTUAL #define _VENTAS #define _COMPRAS #define _VNTPROD #define _VNTCLT #define _CMPPROV #define _BLDVNT #define _VENTASEMPL #define _ACCESSCONTROL // #define _PROVINFO // #define _INFOEMPL // #define _CLIENTES // #define _CCCtbl // #define _VNTEMPL // #define _PARTECTBL // #define _CMPPROV // #define _VNTCLT // #define _INFCTBL //--------------------------------------------------------------------------- __fastcall TMenuInicio::TMenuInicio(TComponent* Owner) : TForm(Owner) { short i, j; ApartadoActual = 0; for ( j = 0; j<9; j++ ) for ( i = 0; i<10; i++ ) { ApartadoMenu[j].Disable[i] = 0; ApartadoMenu[j].IBoton[i] = "imerro"; } /* 0 5 1 6 2 7 3 8 4 9 */ ApartadoMenu[0].NombreApartado = "Menú de Inicio"; ApartadoMenu[0].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iindx.bmp"; RellenaBotonApartado( 0, 0, "Articulos", "imArtc" ); RellenaBotonApartado( 0, 5, "Compras", "imCmps" ); RellenaBotonApartado( 0, 1, "Proveedores", "imProv" ); RellenaBotonApartado( 0, 6, "Empleados", "imEmpl" ); RellenaBotonApartado( 0, 2, "Clientes", "imClts" ); RellenaBotonApartado( 0, 7, "Ventas", "imVnts" ); RellenaBotonApartado( 0, 3, "Contabilidad", "imCntb" ); RellenaBotonApartado( 0, 4, "Miscelanea", "imMisc" ); RellenaBotonApartado( 0, 9, "Soporte Técnico", "imAcer" ); ApartadoMenu[1].NombreApartado = "Articulos"; ApartadoMenu[1].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iprod.bmp"; RellenaBotonApartado( 1, 5, "Referencias", "imRefs" ); RellenaBotonApartado( 1, 6, "Stock Actual", "imStck" ); RellenaBotonApartado( 1, 8, "Ventas/Articulo", "imVtRf" ); ApartadoMenu[2].NombreApartado = "Proveedores"; ApartadoMenu[2].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iprov.bmp"; RellenaBotonApartado( 2, 5, "Información", "imInfProv" ); RellenaBotonApartado( 2, 7, "Cartera de Prov.", "imCtrProv" ); RellenaBotonApartado( 2, 8, "Compras a...", "imCmpProv" ); ApartadoMenu[3].NombreApartado = "Empleados"; ApartadoMenu[3].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iempl.bmp"; RellenaBotonApartado( 3, 5, "Fichas", "imInfEmp" ); RellenaBotonApartado( 3, 6, "Permisos de Acceso","imPwdEmp" ); RellenaBotonApartado( 3, 8, "Ventas/Empleado", "imVtEmp" ); RellenaBotonApartado( 3, 9, "Graficas Ventas", "imGrEmp" ); ApartadoMenu[4].NombreApartado = "Clientes"; ApartadoMenu[4].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iclts.bmp"; RellenaBotonApartado( 4, 5, "Gestion de...", "imInfClt" ); RellenaBotonApartado( 4, 7, "Cartera de Clts.", "imCtrClt" ); RellenaBotonApartado( 4, 8, "Ventas a Clientes", "imVntClt" ); RellenaBotonApartado( 4, 9, "Informes Varios", "imMisClt" ); ApartadoMenu[5].NombreApartado = "Compras"; ApartadoMenu[5].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\icmps.bmp"; RellenaBotonApartado( 5, 5, "Comprar", "imCmpCmp" ); RellenaBotonApartado( 5, 6, "Informe Facturas", "imInfCmp" ); RellenaBotonApartado( 5, 9, "Lista de Compra", "imLstCmp" ); ApartadoMenu[6].NombreApartado = "Ventas"; ApartadoMenu[6].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\ivnts.bmp"; RellenaBotonApartado( 6, 5, "Caja del Día", "imCajVnt" ); RellenaBotonApartado( 6, 7, "Balance Diario", "imBlDVnt" ); RellenaBotonApartado( 6, 8, "Balance Mensual", "imBlMVnt" ); ApartadoMenu[7].NombreApartado = "Contabilidad"; ApartadoMenu[7].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\icntb.bmp"; RellenaBotonApartado( 7, 5, "Cuentas Contables", "imCCCtbl" ); RellenaBotonApartado( 7, 7, "Parte Contable", "imPteCtbl" ); RellenaBotonApartado( 7, 8, "Informes Contables.", "imIfmCtbl" ); ApartadoMenu[8].NombreApartado = "Miscelanea"; ApartadoMenu[8].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\imisc.bmp"; RellenaBotonApartado( 8, 5, "Configuración", "imCFG" ); ApartadoMenu[9].NombreApartado = "Soporte Técnico"; ApartadoMenu[9].ImagenApartado = ExtractFilePath(Application->ExeName) + "systm\\iacer.bmp"; RellenaBotonApartado( 9, 9, "Acerca de...", "imAcer" ); MuestraApartado( ApartadoActual ); TChangeUserName *User; User = new TChangeUserName( this ); Visible = false; User->ShowModal(); #ifndef DEM001 if ( FileExists( "C:\\msdos.--" ) ) #endif { for ( i=0; i<10; i++ ) for ( j=0; j<10; j++ ) TablaDeAcceso[i][j] = User->TablaDeAcceso[i][j]; } Visible = true; delete User; } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn1Click(TObject *Sender) { Close(); } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::FormCreate(TObject *Sender) { // Cargamos el inicializador... TInitBDE *Inicializador; Inicializador = new TInitBDE(this); Inicializador -> ShowModal(); delete Inicializador; } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::RellenaBotonApartado( short Apartado, short Boton, AnsiString nBoton, AnsiString iBoton ) { ApartadoMenu[Apartado].Disable[Boton] = true; ApartadoMenu[Apartado].NBoton[Boton] = nBoton; ApartadoMenu[Apartado].IBoton[Boton] = iBoton; } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn3Click(TObject *Sender) { ApartadoActual ++; if ( ApartadoActual > 9 ) ApartadoActual = 0; MuestraApartado( ApartadoActual ); } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn2Click(TObject *Sender) { ApartadoActual --; if ( ApartadoActual < 0 ) ApartadoActual = 9; MuestraApartado( ApartadoActual ); } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::MuestraApartado( short Apartado ) { // Cambiamos el nombre, foto y botones... Label1 -> Caption = ApartadoMenu[ Apartado ].NombreApartado; try { Image1 -> Picture -> LoadFromFile( ApartadoMenu[ Apartado ].ImagenApartado ); } catch(...) { // Error cargando imagen. Image1 -> Picture -> LoadFromFile( ExtractFilePath(Application->ExeName) + "systm//ierro.bmp" ); } if ( Apartado == 9 ) { Animate1 -> FileName = ExtractFilePath(Application->ExeName) + "systm\\JDsoft.avi"; Animate1 -> Visible = true; Animate1 -> Active = true; } else { Animate1 -> Active = false; Animate1 -> Visible = false; Animate1 -> FileName = ""; } MuestraBotones( BitBtn4, 0, Apartado ); MuestraBotones( BitBtn5, 1, Apartado ); MuestraBotones( BitBtn6, 2, Apartado ); MuestraBotones( BitBtn7, 3, Apartado ); MuestraBotones( BitBtn8, 4, Apartado ); MuestraBotones( BitBtn9, 5, Apartado ); MuestraBotones( BitBtn10, 6, Apartado ); MuestraBotones( BitBtn11, 7, Apartado ); MuestraBotones( BitBtn12, 8, Apartado ); MuestraBotones( BitBtn13, 9, Apartado ); } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::MuestraBotones( TBitBtn *Sender, short nBoton, short Apartado ) { Sender -> Visible = ApartadoMenu[ Apartado ].Disable[nBoton]; if ( Sender -> Visible ) { Sender -> Caption = ApartadoMenu[ Apartado ].NBoton[nBoton]; try { Sender -> Glyph -> LoadFromFile( ExtractFilePath(Application->ExeName) + "systm\\" + ApartadoMenu[ Apartado ].IBoton[nBoton] + ".bmp" ); } catch(...) { Sender -> Glyph -> LoadFromFile( ExtractFilePath(Application->ExeName) + "systm\\imerro.bmp" ); } } } void __fastcall TMenuInicio::BitBtn4Click(TObject *Sender) { switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 1; MuestraApartado( ApartadoActual ); break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn5Click(TObject *Sender) { switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 2; MuestraApartado( ApartadoActual ); break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn6Click(TObject *Sender) { switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 4; MuestraApartado( ApartadoActual ); break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn7Click(TObject *Sender) { switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 7; MuestraApartado( ApartadoActual ); break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn8Click(TObject *Sender) { switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 8; MuestraApartado( ApartadoActual ); break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn9Click(TObject *Sender) { if ( !TablaDeAcceso[ApartadoActual][5] && ApartadoActual != 0 ) return; switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 5; MuestraApartado( ApartadoActual ); break; case 1: #ifdef _PRODUCTOS TProductos *Productos; Visible = false; Productos = new TProductos(this); Productos -> ShowModal(); Visible = true; delete Productos; #endif break; case 2: #ifdef _PROVINFO TTpvProv *ProvInfo; Visible = false; ProvInfo = new TTpvProv(this); ProvInfo -> ShowModal(); Visible = true; delete ProvInfo; #endif break; case 3: #ifdef _INFOEMPL TTpvEmpl *InfoEmpl; Visible = false; InfoEmpl = new TTpvEmpl(this); InfoEmpl -> ShowModal(); Visible = true; delete InfoEmpl; #endif break; case 4: #ifdef _CLIENTES TTpvClt *TpvClt; Visible = false; TpvClt = new TTpvClt(this); TpvClt -> ShowModal(); Visible = true; delete TpvClt; #endif break; case 5: #ifdef _COMPRAS TTpvCmp1 *TpvCmp1; Visible = false; TpvCmp1 = new TTpvCmp1(this); TpvCmp1 -> ShowModal(); Visible = true; delete TpvCmp1; #endif break; case 6: #ifdef _VENTAS TVentas *Ventas; Visible = false; Ventas = new TVentas(this); Ventas -> ShowModal(); Visible = true; delete Ventas; #endif break; case 7: #ifdef _CCCtbl TCCCtbl *CCCtbl; Visible = false; CCCtbl = new TCCCtbl(this); CCCtbl -> ShowModal(); Visible = true; delete CCCtbl; #endif break; #ifdef EXIST_CFG case 8: Visible = false; CFG -> ShowModal(); Visible = true; break; #endif } } void __fastcall TMenuInicio::RunInDLL( AnsiString dll_File, AnsiString dll_Funcion ) { /* typedef VOID (*MYPROC)(void); HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary( dll_File.c_str() ); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcAdd = (MYPROC)GetProcAddress(hinstLib, dll_Funcion.c_str() ); // If the function address is valid, call the function. if (fRunTimeLinkSuccess = (ProcAdd != NULL)) { Visible = false; (ProcAdd) (); Visible = true; } // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); } // If unable to call the DLL function, use an alternative. if (! fRunTimeLinkSuccess) ShowMessage("Módulo corrupto, ó, no incluido en el paquete.\nPongase en contacto con su suministrador."); */ } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn10Click(TObject *Sender) { if ( !TablaDeAcceso[ApartadoActual][6] && ApartadoActual != 0 ) return; switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 3; MuestraApartado( ApartadoActual ); break; case 1: #ifdef _STOCKACTUAL // RunInDLL( "Prod.dll", "DStock" ); TStockActual *StockActual; Visible = false; StockActual = new TStockActual(this); StockActual -> ShowModal(); Visible = true; delete StockActual; #endif break; case 3: #ifdef _ACCESSCONTROL TAccessControl *Access; Visible = false; Access = new TAccessControl(this); Access->ShowModal(); Visible = true; delete Access; #endif break; case 5: #ifdef _CMPPROV TCmpProv *CmpProv; Visible = false; CmpProv = new TCmpProv(this); CmpProv -> ShowModal(); Visible = true; delete CmpProv; #endif break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn11Click(TObject *Sender) { if ( !TablaDeAcceso[ApartadoActual][7] && ApartadoActual != 0 ) return; switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 6; MuestraApartado( ApartadoActual ); break; case 2: #ifdef _CMPPROV TCmpProv *CtrProv; Visible = false; CtrProv = new TCmpProv(this); CtrProv -> ImpagFactClick(0); CtrProv -> ShowModal(); Visible = true; delete CtrProv; #endif break; case 3: #ifdef _VNTEMPL TVntEmpl *VentasEmpl; Visible = false; VentasEmpl = new TVntEmpl(this); VentasEmpl -> ImpagFactClick(0); VentasEmpl -> ShowModal(); Visible = true; delete VentasEmpl; #endif break; case 4: #ifdef _VNTCLT TVntClt *VntClt; Visible = false; VntClt = new TVntClt(this); VntClt -> ImpagFactClick(0); VntClt -> ShowModal(); Visible = true; delete VntClt; #endif break; case 6: #ifdef DEM001 ShowMessage( "Esta función ha sido deshabilitada para esta versión.\nPongase en contacto con el autor, si desea\nel módulo correspondiente: Jose-David.Guillen@cs.us.es" ); #else #ifdef _BLDVNT TTpvBlDVnt *TpvBlDVnt; Visible = false; TpvBlDVnt = new TTpvBlDVnt(this); TpvBlDVnt -> ShowModal(); Visible = true; delete TpvBlDVnt; #endif #endif break; case 7: #ifdef _PARTECTBL TParteCtbl *ParteCtbl; Visible = false; ParteCtbl = new TParteCtbl(this); ParteCtbl -> ShowModal(); Visible = true; delete ParteCtbl; #endif break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn12Click(TObject *Sender) { if ( !TablaDeAcceso[ApartadoActual][8] && ApartadoActual != 0 ) return; switch ( ApartadoActual ) { // Menú Principal case 0: break; case 1: #ifdef DEM001 ShowMessage( "Esta función ha sido deshabilitada para esta versión.\nPongase en contacto con el autor, si desea\nel módulo correspondiente: Jose-David.Guillen@cs.us.es" ); #else #ifdef _VNTPROD // Usamos la libreria TVntProd *TpvVntProd; Visible = false; TpvVntProd = new TVntProd(this); TpvVntProd -> ShowModal(); Visible = true; delete TpvVntProd; #endif #endif break; case 2: #ifdef _CMPPROV TCmpProv *CmpProv; Visible = false; CmpProv = new TCmpProv(this); CmpProv -> ShowModal(); Visible = true; delete CmpProv; #endif break; case 3: #ifdef _VENTASEMPL TVntEmpl *VentasEmpl; Visible = false; VentasEmpl = new TVntEmpl(this); VentasEmpl -> ShowModal(); Visible = true; delete VentasEmpl; #endif break; case 4: #ifdef DEM001 ShowMessage( "Esta función ha sido deshabilitada para esta versión.\nPongase en contacto con el autor, si desea\nel módulo correspondiente: Jose-David.Guillen@cs.us.es" ); #else #ifdef _VNTCLT TVntClt *VntClt; Visible = false; VntClt = new TVntClt(this); VntClt -> ShowModal(); Visible = true; delete VntClt; #endif #endif break; case 6: #ifdef DEM001 ShowMessage( "Esta función ha sido deshabilitada para esta versión.\nPongase en contacto con el autor, si desea\nel módulo correspondiente: Jose-David.Guillen@cs.us.es" ); #else #ifdef _BLDVNT TBlMVnt *BlMVnt; Visible = false; BlMVnt = new TBlMVnt(this); BlMVnt -> ShowModal(); Visible = true; delete BlMVnt; #endif #endif break; case 7: #ifdef _INFCTBL TInfCtbl *InfCtbl; Visible = false; InfCtbl = new TInfCtbl(this); InfCtbl -> ShowModal(); Visible = true; delete InfCtbl; #endif break; } } //--------------------------------------------------------------------------- void __fastcall TMenuInicio::BitBtn13Click(TObject *Sender) { if ( !TablaDeAcceso[ApartadoActual][9] && ApartadoActual != 0 ) return; switch ( ApartadoActual ) { // Menú Principal case 0: ApartadoActual = 9; MuestraApartado( ApartadoActual ); break; case 9: /// TAbout *About; /// Visible = false; /// About = new TAbout(this); /// /***************************************************/ /// /**/About -> Nombre -> Caption = "TPV for Windows"; /// /**/About -> Descripcion -> Caption = "Gestión integral, multipuesto"; /// /**/About -> Registro -> Caption = "VERSION DEMO"; /// /**/try { /// /**/ About -> Icono -> Picture -> LoadFromFile(ExtractFilePath(Application->ExeName) + "systm\\about.ico"); /// /**/} catch(...) {//nothing /// /**/} /// /***************************************************/ /// About -> ShowModal(); /// Visible = true; /// delete About; /// break; } } //--------------------------------------------------------------------------- /// 1 2 4 7 8 5 3 6 9 void __fastcall TMenuInicio::Image1Click(TObject *Sender) { if ( ApartadoActual != 0 ) { ApartadoActual = 0; MuestraApartado( ApartadoActual ); } } //---------------------------------------------------------------------------