Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Designing mutliple data views
Message
 
À
06/09/2005 15:13:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01047134
Message ID:
01047298
Vues:
8
>I need to come up with a design that will show all jobs per day per work center and is easy to read and change. They also need to see mutliple work centers and days at one time. I can't think of what that would look like. Here's what my raw data looks like.
>
>Job Table has three fields I care about: Job #, Start Date, Work Center.
>Work Center table that contains Work Center and scheduled - scheduled is a logical field that determins if it should show up on the screen.
>
>So they want something that has days on one side and work centers on top (or vice versa which ever way is easeir)
>
>I was thinking a grid with in a grid because there would be multiple jobs for a single day and work center. But to get that I would need a table for each day/work center combo because I can’t have multiple relationships into one table and have the grids show the correct data.
>
>Does anyone have another design idea to show all this data?

You can define a Local View (I hate them :o) or Cursor Adapter and put some input parameters into select clause. Then Base the Grid on that View/CA. When the user selects day and Work Center just add these values to parameters and refresh the view/CA.
Here an exampple. Keep in mind this is only exampl, not error checks here not any other normal things that you must do :o)
Just Select Day 6 and Name 6 or Day1 and Name 1 and see what happens to Grid
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN


	**************************************************
*-- Form:         form1 (d:\all_zapl\tte.scx)
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   09/07/05 01:53:02 PM
*
DEFINE CLASS form1 AS form


	Top = 0
	Left = 0
	Height = 510
	Width = 613
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"


	ADD OBJECT combo1 AS combobox WITH ;
		Value = 0, ;
		Height = 24, ;
		Left = 15, ;
		Style = 2, ;
		Top = 11, ;
		Width = 163, ;
		Name = "Combo1"


	ADD OBJECT combo2 AS combobox WITH ;
		BoundColumn = 2, ;
		RowSourceType = 6, ;
		Value = 0, ;
		Height = 24, ;
		Left = 185, ;
		Style = 2, ;
		Top = 11, ;
		Width = 270, ;
		BoundTo = .T., ;
		Name = "Combo2"


	ADD OBJECT grid1 AS grid WITH ;
		Height = 436, ;
		Left = 16, ;
		Top = 57, ;
		Width = 573, ;
		Name = "Grid1"


	PROCEDURE changegrid
		IF NOT EMPTY(thisform.Combo1.Value) AND;
		   NOT EMPTY(thisform.Combo2.Value) 
		   m.MyDay        = thisform.Combo1.Value
		   m.myWorkCenter = thisform.Combo2.Value
		   thisform.DataEnvironment.oCursor.CursorRefresh()
		   thisform.Grid1.Refresh()
		ENDIF
	ENDPROC


	PROCEDURE Init
		CLOSE DATABASES ALL
		CREATE DATABASE Test
		OPEN DATABASE Test
		CREATE TABLE JobTitle (Job N(5),StartDate D,WorkCenter N(4))
		CREATE TABLE WorkCenter (ID N(4),Name C(20))
		FOR asd = 1 TO 50
		    IF asd < 30
		       thisform.Combo1.AddItem(TRANSFORM(asd))
		    ENDIF
		    IF asd < 26
		       INSERT INTO JobTitle VALUES (asd, DATE(2005,9,asd),asd)
		    ELSE
		       INSERT INTO JobTitle VALUES (asd, DATE(2005,9,asd-25),asd-25)
		    ENDIF
		NEXT

		INSERT INTO WORKCENTER SELECT DISTINCT WorkCenter, PADR("Name "+TRANSFORM(WorkCenter),20) FROM JobTitle
		SELECT WorkCenter

		thisform.DataEnvironment.AddObject("oCursor","CursorAdapter")
		WITH thisform.DataEnvironment.oCursor
		     .Alias              = "MyGridSource"
		     .DataSourceType     = "Native"
		     .Tables             = "JobTitle"   
		     .DataSource         = "Test"
		     .WhereType          = 1
		     .BreakOnError       = .t.
		     .BufferModeOverride = 5
		     .KeyFieldList       = ""
		     .UpdateNameList     = ""
		     .UpdatableFieldList = ""
		     .SelectCmd          = "SELECT * FROM JobTitle WHERE DAY(StartDate) == ?m.myDay AND WorkCenter == ?m.myWorkCenter"
		ENDWITH
		ASSERT .f.
		m.MyDay = -1
		m.myWorkCenter = -1
		thisform.DataEnvironment.oCursor.CursorFill()


		thisform.Grid1.RecordSourceType = 1
		thisform.Grid1.RecordSource     = "MyGridSource"
		thisform.Grid1.Refresh()
		thisform.Combo2.RowSource = "WorkCenter.Name, Id"
		thisform.Combo2.requery()
	ENDPROC


	PROCEDURE combo1.InteractiveChange
		thisform.ChangeGrid()
	ENDPROC


	PROCEDURE combo2.InteractiveChange
		thisform.Changegrid()
	ENDPROC


ENDDEFINE
*
*-- EndDefine: form1
**************************************************
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform