home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 16
/
CD_ASCQ_16_0994.iso
/
news
/
4611
/
fw16d.ins
/
SAMPLES
/
TECH.PRG
< prev
next >
Wrap
Text File
|
1994-06-11
|
23KB
|
600 lines
/*┌─ Program ────────────────────────────────────────────────────────────────┐
│ Application: WinDesk Desktop Organizer! │
│ File Name: WINDESK.PRG │
│ Author: John H. Stolte, Sr. & Jon Kilburn │
│ Date created: 11-28-93 │
│ Mod. Date: 06-03-94 │
│ Time created: 06:32:40pm │
│ Copyright: Released into the Public Domain │
└──────────────────────────────────────────────────────────────────────────┘*/
#include "FIVEWIN.CH"
#INCLUDE "Tech.ch"
STATIC oWnd
STATIC aContact := { "Compuserve" , "Phone" , "FAX" , "BBS" }
STATIC aAssign := { "Antonio Linares" , "Jon Kilburn" , "John Stolte", "Mark Lussier" }
STATIC oName,oSource,oType,oDateIn,oDateOut,oAssigned,oComplete,oProblem,oSolution,oContact,oWhere,oNotes,oFilter
STATIC cName,cSource,cType,dDateIn,dDateOut,cAssigned,lComplete,mProblem,mSolution,cContact,cWhere,mNotes,lFilter := .f.
static adding := .f.
FUNCTION Main()
/*
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ Function : Main()--> NIL │▒
│ Programmer : John H. Stolte │▒
│ Date : November 28, 1993 │▒
│ Modified : April 17, 1994 -- Jon Kilburn (Dr. Jon) │▒
│ Purpose : Main procedure for the Windesk program. Note.. This is just │▒
│ the same as you would handle it in DOS. The windows objects │▒
│ handle there events transparently to the Clipper program. │▒
│ Parameters : None │▒
│ Returns : NIL │▒
│ Libraries : FiveWin │▒
│ DataBases : None │▒
│ │▒
└─────────────────────────────────────────────────────────────────────────────┘▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/
LOCAL ;
oBrush, ;
oBar, ;
hBorland
/*
Important! Since the program uses Borland custom controls the borland
DLL must be loaded by the program.
*/
hBorland := loadlibrary("BWCC.DLL")
SET DELETED ON
SET 3DLOOK ON
/*
This command sets our resources to the windesk DLL. What this means
is that any dialogs we load using the DEFINE DIALOG .. RESOURCE
command will be automatically read in from the Windesk DLL. Pretty
cool huh?
*/
SET RESOURCES TO "TECH.DLL"
//─────────── Set the background wallpaper to a "Bricks" style ────────────//
DEFINE BRUSH oBrush STYLE BRICKS
/*
Defines the main program window. Assigns it a caption (or Title) using
the TITLE option. Then sets the background (wallpaper) of the window
to the "Bricks". Finally it attaches a menu to the window.
*/
DEFINE WINDOW oWnd FROM 1, 5 TO 20, 75 ;
TITLE "FiveWin Tech Support System" ;
BRUSH oBrush ;
MENU BuildMenu()
@ 10, 25 BITMAP FILENAME "..\bitmaps\clipLogo.bmp" OF oWnd // logo
//──────────── Window message bar added to display the text ───────────────//
SET MESSAGE OF oWnd TO "FiveWin Tech Support System"
//─────── Display the window now that we have initialized everything ──────//
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT Support() //JHS this causes weird stuff to happen!
//─────────────────────────── Close the resources ─────────────────────────//
SET RESOURCES TO
SET 3DLOOK OFF
freelibrary(hBorland)
RETURN nil
STATIC FUNCTION BuildMenu()
/*
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ Function : BuildMenu()--> oMenu │▒
│ Programmer : John H. Stolte & Jon Kilburn │▒
│ Date : November 28, 1993 │▒
│ Modified : April 17, 1994 │▒
│ Purpose : Umm....Build the main menu (Don't you just hate those │▒
│ Rotten confusing function names... │▒
│ Parameters : None │▒
│ Returns : NIL │▒
│ Libraries : None │▒
│ DataBases : None │▒
│ │▒
└─────────────────────────────────────────────────────────────────────────────┘▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/
LOCAL ;
oMenu
//───── Create the top level menu bar object and attach all sub menus ─────//
MENU oMenu
MENUITEM "&Support"
MENU
MENUITEM "&Support" ;
MESSAGE "Add/Edit Data in The Database" ;
ACTION Support()
MENUITEM "&Calculator" ;
MESSAGE "Popup Calculator" ;
ACTION Winexec("calc")
MENUITEM "Calen&dar" ;
MESSAGE "Popup Calendar" ;
ACTION Winexec("Calendar")
MENUITEM "&NotePad" ;
MESSAGE "Popup Note Pad" ;
ACTION Winexec("NotePad")
MENUITEM "&Write" ;
MESSAGE "Write - WordProcessor" ;
ACTION Winexec("Write")
MENUITEM "&Browser" ;
MESSAGE "Generic Database Browser" ;
ACTION BrowseFile()
SEPARATOR
MENUITEM "&Close..." ;
MESSAGE "Exit this Program" ;
ACTION oWnd:end()
ENDMENU
MENUITEM "&About"
MENU
MENUITEM "&About" ;
MESSAGE "About FiveWIn Tech SUpport" ;
ACTION About()
ENDMENU
ENDMENU
RETURN oMenu
STATIC FUNCTION About()
/*
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ Function : About()--> NIL │▒
│ Programmer : John H. Stolte & Jon Kilburn │▒
│ Date : November 28, 1993 │▒
│ Modified : April 18, 1994 │▒
│ Purpose : Another confusing function designed to do nothing more than │▒
│ thoroughly confuse the user and any programmers who might be │▒
│ looking at this code. As you can tell we use cryptic names │▒
│ and _NEVER_ comment our code.... │▒
│ Parameters : None │▒
│ Returns : NIL │▒
│ Libraries : FiveWin │▒
│ DataBases : None │▒
│ │▒
└─────────────────────────────────────────────────────────────────────────────┘▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/
LOCAL ;
oDlg
DEFINE DIALOG oDlg RESOURCE "About"
REDEFINE SAY ID 10 OF oDlg
REDEFINE SAY ID 20 OF oDlg
REDEFINE SAY ID 30 OF oDlg
REDEFINE SAY ID 40 OF oDlg
ACTIVATE DIALOG oDlg CENTERED
RETURN nil
STATIC FUNCTION BrowseFile()
/*
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ Function : BrowseFile()--> NIL │▒
│ Programmer : Jon Kilburn │▒
│ Date : April 18, 1994 │▒
│ Modified : │▒
│ Purpose : Generic Browser for any database file....Please pay attention │▒
│ Now boys and girls cause I'm only gonna do this as many times │▒
│ as you want...I'll build the dialog, browse and buttons for │▒
│ For you... │▒
│ Parameters : None │▒
│ Returns : NIL │▒
│ Libraries : None │▒
│ DataBases : None │▒
│ │▒
└─────────────────────────────────────────────────────────────────────────────┘▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/
LOCAL ;
oDlg, ;
oLbx, ;
cFile, ;
nSel, ;
btnNew, ;
btnModify, ;
btnDelete, ;
btnSearch, ;
btnList, ;
btnEnd
nSel := select()
cFile := cGetFile("*.dbf", "Open a database")
IF ! empty(cFile) .and. cfile <> "*.dbf"
USE (cFile) ALIAS FILE1 SHARED NEW
SELECT FILE1
IF neterr()
MsgAlert("File is currently locked by another user!", "File Error")
RETURN nil
ENDIF
DEFINE DIALOG oDlg FROM 3, 3 TO 26, 79 TITLE cFile
@ 0, 1 SAY "Fields" OF oDlg
@ 1, 1 LISTBOX oLbx FIELDS ;
SIZE 284, 137 OF oDlg
/*
Please take note..I only created one button to call the delete
function as an example. You may add and define more of buttons
if you wish.
*/
@ 13, 1 BUTTON btnNew PROMPT "&New" OF oDlg SIZE 40, 12 ;
Action(msgStop("Add Your Own ADD Function"))
@ 13, 8 BUTTON btnModify PROMPT "&Modify" OF oDlg SIZE 40, 12 ;
Action(msgStop("Add Your Own EDIT Function"))
@ 13, 15 BUTTON btnDelete PROMPT "&Delete" OF oDlg SIZE 40, 12 ;
ACTION (FILE1->(DeleteOne()), oLbx:setfocus(.T.))
@ 13, 22 BUTTON btnSearch PROMPT "&Search" OF oDlg SIZE 40, 12 ;
Action(msgStop("Add Your Own SEARCH Function"))
@ 13, 29 BUTTON btnList PROMPT "&Print" OF oDlg SIZE 40, 12 ;
Action(msgStop("Add Your Own PRINT Function"))
@ 13, 36 BUTTON btnEnd PROMPT "&Exit" OF oDlg SIZE 40, 12 ;
ACTION (oDlg:end(), FILE1->(dbclosearea()))
ACTIVATE DIALOG oDlg CENTERED
ENDIF
if nSel <> 0
select(nSel)
endif
RETURN nil
STATIC FUNCTION DeleteOne()
/*┌─ Function ───────────────────────────────────────────────────────────────┐
│ Function: DeleteOne() │
│ Description: A Yes/No Messagebox with a 3d Look To Prompt the user for │
│ Delete/Recall of a Record │
├──────────────────────────────────────────────────────────────────────────┤
│ Arguments: None │
│ Return Value: Nil │
│ See Also: │
└──────────────────────────────────────────────────────────────────────────┘*/
IF ! deleted()
IF MsgYesNo("Delete this Record?", "Delete")
rlock()
dbdelete()
dbunlock()
ENDIF
ELSE
IF MsgYesNo("Recall this Record?", "Recall")
rlock()
dbrecall()
dbunlock()
ENDIF
ENDIF
RETURN nil
STATIC FUNCTION Exit()
/*
┌─────────────────────────────────────────────────────────────────────────────┐
│ │
│ Function : Exit()--> NIL │▒
│ Programmer : John H. Stolte │▒
│ Date : February 22, 1994 │▒
│ Modified : April 18, 1994 -- Dr. Jon │▒
│ Purpose : Make sure the user wishes to exit the windesk program... │▒
│ Parameters : None │▒
│ Returns : NIL │▒
│ Libraries : FiveWin │▒
│ DataBases : None │▒
│ │▒
└─────────────────────────────────────────────────────────────────────────────┘▒
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
*/
LOCAL ;
oDlg
DEFINE DIALOG oDlg RESOURCE "Exit"
REDEFINE SAY ID 10 OF oDlg
REDEFINE BITMAP ID 110 OF oDlg RESOURCE "Question"
REDEFINE BUTTON ID IDYES OF oDlg ;
ACTION (oDlg:end(), oWnd:end())
REDEFINE BUTTON ID IDNO OF oDlg ;
ACTION oDlg:end()
ACTIVATE DIALOG oDlg CENTERED
RETURN nil
//=============================
function support
LOCAL aStru_
IF ! file("tech.DBF")
aStru_ := { ;
{"Name", "C", 30, 0}, ;
{"Source", "C", 30, 0}, ;
{"Type", "C", 30, 0}, ;
{"DateIn", "D", 8, 0}, ;
{"DateOut", "D", 8, 0}, ;
{"Assigned","C", 20, 0}, ;
{"Complete","L", 1, 0}, ;
{"Problem", "M", 10, 0}, ;
{"Solution","M", 10, 0}, ;
{"Notes", "M", 10, 0}, ;
{"Contact", "C", 30, 0}, ;
{"Where", "C", 30, 0} }
dbcreate("TECH", aStru_)
ENDIF
IF ! file("TECH" + indexext())
USE TECH NEW EXCLUSIVE
INDEX ON upper(TECH->Name) TO TECH
ENDIF
CLOSE ALL
USE TECH NEW SHARED
SET INDEX TO TECH
cName := tech->name
cSource := tech->source
cType := tech->type
dDateIn := tech->datein
dDateOut := tech->dateout
cAssigned := tech->assigned
lComplete := tech->complete
mProblem := tech->problem
mSolution := tech->solution
mNotes := tech->notes
cContact := tech->contact
cWhere := tech->where
DEFINE DIALOG oDlg RESOURCE "TECHSUPP"
//────────────────── Handle the gets (Edit) controls ──────────────────────//
REDEFINE GET oNAME VAR cName ID ID_NAME OF oDlg PICTURE "@!" VALID !empty(cname)
REDEFINE GET oSOURCE VAR cSOURCE ID ID_SOURCE OF oDlg PICTURE "@!"
REDEFINE GET oTYPE VAR cTYPE ID ID_TYPE OF oDlg PICTURE "@!"
REDEFINE GET oDATEIN VAR dDATEIN ID ID_DATEIN OF oDlg
REDEFINE GET oDATEOUT VAR dDATEOUT ID ID_DATEOUT OF oDlg
REDEFINE GET oPROBLEM VAR mPROBLEM MEMO ID ID_PROBLEM OF oDlg
REDEFINE GET oSOLUTION VAR mSOLUTION MEMO ID ID_SOLUTION OF oDlg
REDEFINE GET oNotes VAR mNotes MEMO ID ID_NOTES OF oDlg
REDEFINE GET oWHERE VAR cWHERE ID ID_WHERE OF oDlg PICTURE "@!"
//─────────────────── Handle the combobox for states ──────────────────────//
REDEFINE COMBOBOX oContact VAR cContact ITEMS aContact ID ID_CONTACT OF oDlg
REDEFINE COMBOBOX oAssigned VAR cAssigned ITEMS aAssign ID ID_ASSIGNED OF oDlg
//─────────────────── Handle the checkbox for active ──────────────────────//
REDEFINE CHECKBOX oComplete VAR lComplete ID ID_COMPLETE OF oDlg ;
ON CLICK fixdate()
REDEFINE CHECKBOX oFilter VAR lFilter ID ID_FILT OF oDlg
//─────────────────── Handle the Scroll Bar for Next Previous ──────────────────────//
REDEFINE SCROLLBAR HORIZONTAL ID ID_NEXT OF oDlg RANGE 1, RecCount() ;
ON DOWN ( DbSkip(),;
If( EoF(), DbGoBottom(),),;
freshen() );
ON UP ( DbSkip( -1 ), ;
freshen() )
REDEFINE BUTTON ID ID_ADD OF oDlg ;
ACTION Addone()
REDEFINE BUTTON ID ID_SAVE OF oDlg ;
ACTION saveone()
REDEFINE BUTTON ID ID_DELETE OF oDlg ;
ACTION Delone()
REDEFINE BUTTON ID ID_SEARCH OF oDlg ;
ACTION ( SearchOne(), freshen() )
REDEFINE BUTTON ID ID_ABORT OF oDlg ;
ACTION ( If( MsgYesNo( "Quit this Database ?", "Select" ),oDlg:End(),) )
REDEFINE BUTTON ID ID_ALL OF oDlg ;
ACTION turnon("ALL")
REDEFINE BUTTON ID ID_OPEN OF oDlg ;
ACTION turnon("OPEN")
REDEFINE BUTTON ID ID_CLOSED OF oDlg ;
ACTION turnon("CLOSED")
REDEFINE BUTTON ID ID_PRINT OF oDlg ;
ACTION WinExec("g:\caret\caret.exe")
ACTIVATE DIALOG oDLG CENTERED NOWAIT
close data
return nil
FUNCTION FIXDATE
iif(lcomplete,dDateOut := date(),dDateout := ctod(" / / "))
oDateOut:Refresh()
RETURN NIL
FUNCTION ADDONE
adding := .t.
cName := space(30) ; oName:refresh()
cSource := space(30) ; oSource:refresh()
cType := space(30) ; oType:refresh()
dDateIn := ctod(" / / ") ; oDateIn:refresh()
dDateOut := ctod(" / / ") ; oDateOut:refresh()
cAssigned := space(20) ; oAssigned:refresh()
lComplete := .f. ; oComplete:refresh()
mProblem := space(512) ; oProblem:refresh()
mSolution := space(512) ; oSolution:refresh()
mNotes := space(512) ; oNotes:refresh()
cContact := space(30) ; oContact:refresh()
cWhere := space(30) ; oWhere:refresh()
return nil
STATIC FUNCTION SearchOne()
LOCAL oDlg, oBmp, cSearch, nRec
nRec := TECH->(recno())
cSearch := space(30)
DEFINE DIALOG oDlg FROM 5,5 TO 11, 38 TITLE "Search"
@ 0.2, 5 SAY "Search for Name.." OF oDlg
@ 1.2, 5 GET cSearch OF oDlg PICTURE "@!"
//──────────── Check to see if the spyglass BMP is in the current directory
IF file("GLASS.BMP")
@ 0.5, 1 BITMAP oBmp FILE "GLASS.BMP" SIZE 20,20 NO BORDER OF oDlg
ENDIF
//────────────────────────── Define the Action Associated to the OK Button
@ 2.7, 3 BUTTON "&Ok" OF oDlg SIZE 44,12 ;
ACTION (TECH->(dbseek(cSearch,.t.)), ;
IF(TECH->(eof()), MsgInfo("Name Not Found!", "Search Failed"),), ;
oDlg:end())
//────────────────────── Define the Action Associated to the Cancel Button
@ 2.7, 11 BUTTON "&Cancel" OF oDlg SIZE 44, 12 ACTION oDlg:end()
ACTIVATE DIALOG oDlg CENTERED
IF TECH->(eof())
TECH->(dbgoto(nRec))
freshen()
ENDIF
RETURN nil
function saveone
If MsgYesNo( "Save This Record ?", "Select" )
if adding
dbappend()
adding := .f.
endif
dbrlock(recno())
tech->name := cName
tech->source := cSource
tech->type := cType
tech->datein := dDateIn
tech->dateout := dDateOut
tech->assigned := cAssigned
tech->complete := lComplete
tech->problem := mProblem
tech->solution := mSolution
tech->notes := mNotes
tech->contact := cContact
tech->where := cWhere
dbunlock(recno())
ENDIF
return nil
FUNCTION DELONE
If MsgYesNo( "Are you SURE you Want to Delete This Record ?", "Select" )
dbrlock(recno())
dbdelete()
dbunlock(recno())
if ! bof()
dbskip(+1)
else
dbskip(-1)
endif
freshen()
ENDIF
return nil
Function turnon(what)
local counter := 0
DO CASE
CASE WHAT = "ALL"
dbClearFilter()
lFilter := .f.
oFilter:refresh()
freshen()
CASE WHAT = "OPEN"
DBSETFILTER( {|| lComplete == .f.}, "lComplete == .f." )
lFilter := .t.
oFilter:refresh()
freshen()
count to counter
if counter == 0
MsgStop("No Records Match That Filter")
dbClearFilter()
lFilter := .f.
oFilter:refresh()
freshen()
endif
CASE WHAT = "CLOSED"
DBSETFILTER( {|| lComplete == .t.}, "lComplete == .t." )
lFilter := .t.
oFilter:refresh()
freshen()
count to counter
if counter == 0
MsgStop("No Records Match That Filter")
dbClearFilter()
lFilter := .f.
oFilter:refresh()
freshen()
endif
ENDCASE
return NIL
STATIC FUNCTION Freshen
cName := tech->name ; oName:refresh()
cSource := tech->source ; oSource:refresh()
cType := tech->type ; oType:refresh()
dDateIn := tech->datein ; oDateIn:refresh()
dDateOut := tech->dateout ; oDateOut:refresh()
cAssigned := tech->assigned ; oAssigned:refresh()
lComplete := tech->complete ; oComplete:refresh()
mProblem := tech->problem ; oProblem:refresh()
mSolution := tech->solution ; oSolution:refresh()
mNotes := tech->notes ; oNotes:refresh()
cContact := tech->contact ; oContact:refresh()
cWhere := tech->where ; oWhere:refresh()
return nil