Mini Kabibi Habibi

Current Path : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/forms/
Upload File :
Current File : C:/Users/ITO/Desktop/VF9/program files/microsoft visual foxpro 9/samples/solution/forms/makesql.sct

T�VERSION =   3.00dataenvironmentdataenvironmentDataenvironmentLLeft = 245
Top = 217
Width = 495
Height = 162
Name = "Dataenvironment"
cursorcursorCursor1Dataenvironment�Left = 10
Top = 20
Width = 95
Height = 90
Alias = "customer"
Database = ..\..\data\testdata.dbc
CursorSource = "customer"
Name = "Cursor1"
22formform	createsql�DataSession = 2
Top = 8
Left = 5
Height = 292
Width = 426
DoCreate = .T.
BorderStyle = 3
Caption = "Interactively Build a SELECT Statement"
MaxButton = .F.
WindowState = 0
LockScreen = .F.
HelpContextID = 184
alias = 
Name = "createsql"
UPROCEDURE clearsql
THISFORM.edtSQL.Value = ""
	
THISFORM.cboField1.Value = ""
THISFORM.cboRelation1.Value = "="
THISFORM.txtValue1.Value = ""
	
THISFORM.opgOperand1.Value = 0
	
THISFORM.cboField2.Value = ""
THISFORM.cboRelation2.Value = "="
THISFORM.txtValue2.Value = ""
THISFORM.cboField2.Enabled = .F.
THISFORM.cboRelation2.Enabled = .F.
THISFORM.txtValue2.Enabled = .F.

THISFORM.cmdClear.Enabled = .F.
THISFORM.cmdExecute.Enabled = .F.
ENDPROC
PROCEDURE bldsql
LOCAL lcOperand,lcWHERE, lcField1, lcRelation1, lcValue1, ;
	lcField2, lcRelation2, lcValue2, lcAlias, lcSQL, lcType
	
* Test to make sure all values that are required have been entered
*------------------------------------------------------------------
IF EMPTY(THISFORM.cboField1.Value)
	 THISFORM.cmdExecute.Enabled = .F.
	 RETURN
ELSE
	IF THISFORM.opgOperand1.Value > 0 AND ;
			EMPTY(THISFORM.cboField2.Value)
		THISFORM.cmdExecute.Enabled = .F.
		RETURN
	ENDIF
ENDIF
*-------------------------------------------------------------------

lcWHERE = ""
lcAlias = ALIAS()

** Retrieve the values of the controls into variables
lcField1 = THISFORM.cboField1.Value
lcRelation1 = THISFORM.cboRelation1.Value
lcValue1 = ALLTRIM(THISFORM.txtValue1.Value)

DO CASE
	CASE THISFORM.opgOperand1.Value = 0
		lcOperand = ""
	CASE THISFORM.opgOperand1.Value = 1
		lcOperand = "AND"
	CASE THISFORM.opgOperand1.Value = 2
		lcOperand = "OR"
ENDCASE

lcField2 = THISFORM.cboField2.Value
lcRelation2 = THISFORM.cboRelation2.Value
lcValue2 = ALLTRIM(THISFORM.txtValue2.Value)

** Need to put the proper delimiters around comparison values of certain types
lcValue1 = THISFORM.ValidateType(THIS.cboField1.Value,lcValue1)
	
** Create the second part of the WHERE condition
IF !EMPTY(lcOperand)
	lcValue2 = THISFORM.ValidateType(THIS.cboField2.Value,lcValue2)	
	lcWHERE = lcOperand + " " + lcField2 + " " + ;
		lcRelation2 + " " + lcValue2
ENDIF

** Create the first part of the WHERE condition
lcWHERE = "WHERE " + lcField1 + " " + lcRelation1 + " ";
  + lcValue1 + " " + lcWHERE
  
** Create the full SQL command using the base table for the form
lcSQL = "SELECT * FROM " + lcAlias + " " + lcWHERE

THISFORM.edtSQL.Value = lcSQL

THISFORM.cmdClear.Enabled = .T.
THISFORM.cmdExecute.Enabled = .T.

ENDPROC
PROCEDURE validatetype
LPARAMETERS lField, lcValue
LOCAL lcType
lcType = TYPE(lField)
DO CASE
	CASE lcType $ "CM"
		lcValue = CHR(34) + lcValue + CHR(34)
	CASE lcType $ "DT"
		lcValue = "{" + lcValue + "}"
	CASE lcType $ "NY"
		IF EMPTY(lcValue)
			lcValue = "0"
		ENDIF
	CASE lcType $ "L"
		IF !INLIST(UPPER(lcValue), ".T.", ".F.")
			lcValue = ".T."
		ENDIF
ENDCASE
RETURN lcValue
ENDPROC
PROCEDURE settextboxformat
LPARAMETERS oSource, oTxt
LOCAL lcType
oTxt.Value = ""
lcType = TYPE(oSource.Value)
DO CASE
	CASE lcType = "D"	
		oTxt.Format = "D"
	CASE lcType = "L"
		oTxt.Inputmask = ".T.,.F."
		oTxt.Format = "M"
	CASE lcType = "T"
		oTxt.Inputmask = "99/99/99 99:99:99"
ENDCASE

ENDPROC
PROCEDURE choosetable
USE ?

IF EMPTY(ALIAS())  && User canceled out of the open table dialog
	RETURN
ELSE
	THIS.Alias = ALIAS()
	THIS.nFields = AFIELDS(THIS.aStructure)
	THIS.init
ENDIF
ENDPROC
PROCEDURE Load
THIS.Alias = ALIAS()
THIS.nFields = AFIELDS(THIS.aStructure)
ENDPROC
PROCEDURE Init
IF  fontmetric(1, 'MS Sans Serif', 8, '') # 13 OR ;
	fontmetric(4, 'MS Sans Serif', 8, '') # 2 OR ;
	fontmetric(6, 'MS Sans Serif', 8, '') # 5 OR ;
	fontmetric(7, 'MS Sans Serif', 8, '') # 11
	this.setall('fontname', 'Tahoma')  
ELSE
	this.setall('fontname','MS Sans Serif')
ENDIF
this.setall('fontsize',8)

THIS.cboField1.clear
THIS.cboField2.clear
FOR nLoop = 1 TO THIS.nFields
	IF !THIS.aStructure[nLoop,2]$"MGO"
		THIS.cboField1.AddItem(THIS.aStructure[nLoop,1])
		THIS.cboField2.AddItem(THIS.aStructure[nLoop,1])
	ENDIF
ENDFOR


ENDPROC
PROCEDURE Unload
IF USED(THIS.Alias)
	USE IN (THIS.Alias)
ENDIF
ENDPROC
PROCEDURE Activate
THIS.c_solutions1.saveHelp
ENDPROC
PROCEDURE Deactivate
IF TYPE("THIS.c_solutions1") = "O" THEN
	THIS.c_solutions1.restoreHelp
ENDIF
ENDPROC

�� �
�
�
%F�z��U�T�������T�������T�����=��T�������T�������T�������T�����=��T��	�����T���
�-��T���
�-��T��	�
�-��T���
�-��T���
�-��U
THISFORMEDTSQLVALUE	CBOFIELD1CBORELATION1	TXTVALUE1OPGOPERAND1	CBOFIELD2CBORELATION2	TXTVALUE2ENABLEDCMDCLEAR
CMDEXECUTE�/�����������	�
�%�C���
���Y�T����-��B����&%����
��C���
�	����T����-��B���
T�����T��C��T�����
��T�����
��T��C���
���
H��v�����
���)�
T���������
���P�T���AND������
���v�T���OR���T�����
��T�����
��T��C���
���T��C���
�����%�C��
��)�T��C���
�����(T���� �� �� ����2T���WHERE �� �� �� ���(T�	��SELECT * FROM �� ���T���
��	��T����a��T����a��U	LCOPERANDLCWHERELCFIELD1LCRELATION1LCVALUE1LCFIELD2LCRELATION2LCVALUE2LCALIASLCSQLLCTYPETHISFORM	CBOFIELD1VALUE
CMDEXECUTEENABLEDOPGOPERAND1	CBOFIELD2CBORELATION1	TXTVALUE1CBORELATION2	TXTVALUE2VALIDATETYPETHISEDTSQLCMDCLEAR�������T��C�b��
H�.������CM��Z�T��C�" �C�" �����DT����T���{��}�����NY����%�C������T���0������L����%�CC�f�.T.�.F.�
����T���.T.����	B����ULFIELDLCVALUELCTYPE��������T������T��C��b��
H�A������D��d�T����D�����L����T����.T.,.F.��T����M�����T����!T����99/99/99 99:99:99���UOSOURCEOTXTLCTYPEVALUEFORMAT	INPUTMASKXQ�?�%�CC����B��Q�T���C��T���C�����
�����UTHISALIASNFIELDS
ASTRUCTUREINIT(T���C��T���C�����UTHISALIASNFIELDS
ASTRUCTURE��%�C��
MS Sans Serif���$�
�!C��
MS Sans Serif���$��!C��
MS Sans Serif���$��!C��
MS Sans Serif���$�����!��C�fontname�Tahoma�������(��C�fontname�
MS Sans Serif�������C�fontsize�����
�����
����������(������� %�C�����MGO
������CC�����������CC������������U	THISSETALL	CBOFIELD1CLEAR	CBOFIELD2NLOOPNFIELDS
ASTRUCTUREADDITEM'%�C����� �Q������UTHISALIAS
�����UTHISC_SOLUTIONS1SAVEHELP9%%�C�THIS.c_solutions1b�O��2�
������UTHISC_SOLUTIONS1RESTOREHELPclearsql,��bldsql���validatetype���settextboxformat���choosetable���Load;��Init���Unload~
��Activate�
��
Deactivate�
��112A122A12�TA�bAAA��31Q�q�qq�A21Q���A$�23�q��1�1q1��A!�AA�2�q!�!!q!A3��A��a�A2�a2d	��A������AA4!�A2�2Q�A1��	46	�
RG�
�fU�v^�
�a-
U�pr��t���v�J�)�
'nfields number of fields in the table
alias Specifies the alias used for each table or view associated with a Cursor object.
*clearsql Clears the previously execute SQL command.
^astructure[1,2] holds fields in the table
*bldsql build an executable SQL SELECT statement
*validatetype Make sure the right type of value is included in the WHERE clause of the SELECT statement
*settextboxformat Based on the type of field selected, sets inputmask or format for a textbox.
*choosetable Allows the user to change the table used to build the query.
shapeshapeShape1	createsqlbTop = 80
Left = 9
Height = 102
Width = 408
BackStyle = 0
SpecialEffect = 0
Name = "Shape1"
comboboxcombobox	cboField1	createsql�FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Height = 23
Left = 85
Style = 2
TabIndex = 3
Top = 94
Width = 111
ColorScheme = 1
Name = "cboField1"
lPROCEDURE InteractiveChange
THISFORM.SetTextboxFormat(THIS, THISFORM.txtValue1)
THISFORM.BldSQL
ENDPROC
�� ����%����U$��C�������
����UTHISFORMSETTEXTBOXFORMATTHIS	TXTVALUE1BLDSQLInteractiveChange,��1q�1a)�labellabelLabel1	createsql�AutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
BackStyle = 0
Caption = "Condition \<1:"
Height = 15
Left = 19
Top = 98
Width = 58
TabIndex = 2
ColorScheme = 1
Name = "Label1"
optiongroupoptiongroupopgOperand1	createsql�ButtonCount = 2
BackStyle = 0
BorderStyle = 0
Value = 0
Height = 21
Left = 161
Top = 122
Width = 104
TabIndex = 6
Name = "opgOperand1"
Option1.FontBold = .F.
Option1.FontName = "MS Sans Serif"
Option1.FontSize = 8
Option1.BackStyle = 0
Option1.Caption = "\<AND"
Option1.Value = 0
Option1.Height = 15
Option1.Left = 8
Option1.Top = 2
Option1.Width = 41
Option1.AutoSize = .T.
Option1.Name = "AND"
Option2.FontBold = .F.
Option2.FontName = "MS Sans Serif"
Option2.FontSize = 8
Option2.BackStyle = 0
Option2.Caption = "\<OR"
Option2.Value = 0
Option2.Height = 15
Option2.Left = 59
Option2.Top = 2
Option2.Width = 34
Option2.AutoSize = .T.
Option2.Name = "OR"
�PROCEDURE InteractiveChange
THISFORM.cboField2.Enabled = .T.
THISFORM.cboRelation2.Enabled = .T.
THISFORM.txtValue2.Enabled = .T.
THISFORM.BldSQL
ENDPROC
8�� �%����U@T����a��T����a��T����a��
����UTHISFORM	CBOFIELD2ENABLEDCBORELATION2	TXTVALUE2BLDSQLInteractiveChange,��1�1�)comboboxcombobox	cboField2	createsql�FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Enabled = .F.
Height = 23
Left = 85
Style = 2
TabIndex = 8
Top = 146
Width = 111
ColorScheme = 1
Name = "cboField2"
lPROCEDURE InteractiveChange
THISFORM.SetTextboxFormat(THIS, THISFORM.txtValue2)
THISFORM.BldSQL
ENDPROC
�� ����%����U$��C�������
����UTHISFORMSETTEXTBOXFORMATTHIS	TXTVALUE2BLDSQLInteractiveChange,��1q�1a)�labellabelLabel2	createsql�AutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
BackStyle = 0
Caption = "Condition \<2:"
Height = 15
Left = 19
Top = 150
Width = 58
TabIndex = 7
ColorScheme = 1
Name = "Label2"
textboxtextbox	txtValue1	createsql�FontBold = .T.
FontName = "MS Sans Serif"
FontSize = 8
Height = 23
Left = 282
TabIndex = 5
Top = 94
Width = 126
ColorScheme = 1
Name = "txtValue1"
�PROCEDURE Valid
THISFORM.BldSQL
ENDPROC
PROCEDURE GotFocus
IF THIS.Format = "M"
	THIS.Parent.lblToggle.Visible = .T.
ENDIF
ENDPROC
PROCEDURE LostFocus
THIS.Parent.lblToggle.Visible = .F.

ENDPROC
��� ����%�0	�U

����UTHISFORMBLDSQL0%����M��)�T�����a���UTHISFORMATPARENT	LBLTOGGLEVISIBLET�����-��UTHISPARENT	LBLTOGGLEVISIBLEValid,��GotFocusO��	LostFocus���1�2QAA2A2 ?���	)�textboxtextbox	txtValue2	createsql�FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Enabled = .F.
Height = 23
Left = 282
TabIndex = 10
Top = 146
Width = 126
ColorScheme = 1
Name = "txtValue2"
�PROCEDURE Valid
THISFORM.BldSQL
ENDPROC
PROCEDURE LostFocus
THIS.Parent.lblToggle.Visible = .F.

ENDPROC
PROCEDURE GotFocus
IF THIS.Format = "M"
	THIS.Parent.lblToggle.Visible = .T.
ENDIF
ENDPROC
��� ����%�0	�U

����UTHISFORMBLDSQLT�����-��UTHISPARENT	LBLTOGGLEVISIBLE0%����M��)�T�����a���UTHISFORMATPARENT	LBLTOGGLEVISIBLEValid,��	LostFocusO��GotFocus���1�2A3QAA1 @e��)�
commandbutton
commandbutton
cmdExecute	createsql�Top = 260
Left = 178
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "Run S\<QL"
Enabled = .F.
TabIndex = 15
ColorScheme = 1
Name = "cmdExecute"
PROCEDURE Click
LOCAL lcOldAlias
lcOldAlias = ALIAS()

cMacro = ALLTRIM(THISFORM.edtSQL.Value) + "INTO CURSOR TEMPQUERY"
&cMacro

IF _TALLY = 0
	#DEFINE MSG_LOC "No records were found to match the criteria you specified."
	#DEFINE TITLE_LOC "No Results"
	=MESSAGEBOX(MSG_LOC,64+0+0,TITLE_LOC)
ELSE
	BROWSE NORMAL TITLE SUBSTR(THISFORM.edtSQL.Value, AT("WHERE",THISFORM.edtSQL.Value )+ 6)
ENDIF

IF USED("TEMPQUERY")
	USE IN TEMPQUERY
ENDIF
IF USED(lcOldAlias)
	SELECT (lcOldAlias)
ENDIF
ENDPROC
'�� +%����U,���T��C��.T��C�����INTO CURSOR TEMPQUERY��&cMacro
%�� �����V��C�:No records were found to match the criteria you specified.�@�
No Results�x�����*	�'�C���C�WHERE����\���%�C�	TEMPQUERY����Q���%�C����%�
F�����U
LCOLDALIASCMACROTHISFORMEDTSQLVALUE	TEMPQUERYClick,��1q���c��A��A��A1�)comboboxcomboboxcboRelation1	createsql;FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
ColumnCount = 1
ColumnWidths = "60"
RowSourceType = 1
RowSource = "=,<>,==,<,<=,>,>="
Value = ("=")
FirstElement = 1
Height = 23
Left = 208
NumberOfElements = 0
Style = 2
TabIndex = 4
Top = 94
Width = 60
ColorScheme = 1
Name = "cboRelation1"
7PROCEDURE InteractiveChange
THISFORM.BldSQL
ENDPROC
�� ��k�%Opj�U

����UTHISFORMBLDSQLInteractiveChange,��1�1,)�comboboxcomboboxcboRelation2	createsqlKFontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
ColumnCount = 1
ColumnWidths = "60"
RowSourceType = 1
RowSource = "=,<>,==,<,<=,>,>="
Value = ("=")
Enabled = .F.
FirstElement = 1
Height = 23
Left = 208
NumberOfElements = 0
Style = 2
TabIndex = 9
Top = 146
Width = 60
ColorScheme = 1
Name = "cboRelation2"
7PROCEDURE InteractiveChange
THISFORM.BldSQL
ENDPROC
�� ��k�%Opj�U

����UTHISFORMBLDSQLInteractiveChange,��1�1,)�editboxeditboxedtSQL	createsql�FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Height = 45
Left = 9
ReadOnly = .T.
TabIndex = 12
TabStop = .F.
Top = 204
Width = 408
ColorScheme = 1
BackColor = 192,192,192
Name = "edtSQL"
7PROCEDURE Click
THISFORM.cboField1.SetFocus
ENDPROC
�� ��7�%_tn�U
�����UTHISFORM	CBOFIELD1SETFOCUSClick,��1�1,)�
commandbutton
commandbuttoncmdClear	createsql�Top = 260
Left = 255
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "Clea\<r"
Enabled = .F.
TabIndex = 16
Name = "cmdClear"
ZPROCEDURE Click
THISFORM.ClearSQL
ENDPROC
PROCEDURE Init
THIS.Enabled = .F.
ENDPROC
�� ����%u���U

����UTHISFORMCLEARSQLT���-��UTHISENABLEDClick,��InitQ��1�2�1"=O)�c_solutions..\solution.vcxcustomC_solutions1	createsqlFTop = 262
Left = 62
Height = 18
Width = 25
Name = "C_solutions1"
behindscenes..\solution.vcx
commandbutton
Behindscenes1	createsql=Top = 260
Left = 10
TabIndex = 13
Name = "Behindscenes1"
cmdclose..\solution.vcx
commandbutton	Cmdclose2	createsql:Top = 260
Left = 344
TabIndex = 17
Name = "Cmdclose2"
labellabelLabel3	createsql�AutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " \<Selection Criteria "
Height = 15
Left = 16
Top = 74
Width = 87
TabIndex = 1
ColorScheme = 1
Name = "Label3"
labellabelLabel4	createsql�AutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
BackStyle = 0
Caption = "SQL SELECT Statement"
Height = 15
Left = 8
Top = 188
Width = 118
TabIndex = 11
ColorScheme = 1
Name = "Label4"
labellabel	lblToggle	createsqlAutoSize = .T.
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 9
WordWrap = .T.
BackStyle = 0
Caption = "Press Spacebar to toggle values"
Height = 28
Left = 291
Top = 117
Visible = .F.
Width = 89
TabIndex = 0
ForeColor = 255,255,255
Name = "lblToggle"
shapeshapeShape2	createsqlaTop = 12
Left = 9
Height = 56
Width = 408
BackStyle = 0
SpecialEffect = 0
Name = "Shape2"
labellabelLabel5	createsqlUFontName = "MS Sans Serif"
FontSize = 8
WordWrap = .T.
Caption = "Build a SQL SELECT command by selecting a field and operator and entering a comparison value.  To include a second condition, click And or Or.  Run the SQL SELECT command by clicking Run SQL."
Height = 39
Left = 18
Top = 22
Width = 389
TabIndex = 0
Name = "Label5"
labellabelLabel6	createsql�AutoSize = .T.
FontName = "MS Sans Serif"
FontSize = 8
Caption = " Instructions "
Height = 15
Left = 17
Top = 6
Width = 62
TabIndex = 0
Name = "Label6"

commandbutton
commandbuttoncmdOpenTable	createsql�Top = 260
Left = 90
Height = 23
Width = 72
FontBold = .F.
FontName = "MS Sans Serif"
FontSize = 8
Caption = "\<Use Table..."
Enabled = .T.
TabIndex = 14
ColorScheme = 1
Name = "cmdOpenTable"
OPROCEDURE Click
THIS.parent.cmdClear.click
THIS.parent.choosetable
ENDPROC
��� ��F:%|���U ������
�����UTHISPARENTCMDCLEARCLICKCHOOSETABLEClick,��1�1D)�sArial, 0, 9, 5, 15, 12, 32, 3, 0
MS Sans Serif, 0, 8, 5, 13, 11, 11, 2, 0
MS Sans Serif, 1, 8, 6, 13, 11, 12, 2, 0
�DataSession = 2
Top = 8
Left = 5
Height = 292
Width = 426
DoCreate = .T.
BorderStyle = 3
Caption = "Interactively Build a SELECT Statement"
MaxButton = .F.
WindowState = 0
LockScreen = .F.
HelpContextID = 1231571
alias =
Name = "createsql"