grid does not refresh - visual-foxpro

This is the code of the init of the form
if !used if !used ("supplier_temp")
SELECT supplier
afields(structure)
CREATE cursor supplier_temp from array structure
else
SELECT supplier_temp
for re = 1 to reccount()
SELECT supplier_temp
go re
_id = supplier_temp.id
_name = supplier_temp.name
_dir = supplier_temp.dir
_cel = supplier_temp.cellphon
_em = supplier_temp.email
scan
update provider set name=_name, address=_dir, cell=_cel, email = _em where control = 1 and id = _id
end scan
end for
delete all
endif
SELECT supplier_temp
APPEND FROM supplier for dispatched = 1
GO TOP
Thisform.Suppliers.RecordSource = "supplier_temp"
Thisform.Suppliers.column1.ControlSource = "supplier_temp.name"
Thisform.Proveedores.column2.ControlSource = "supplier_temp.direntre"
Thisform.Proveedores.column3.ControlSource = "provider_temp.cellphon"
Thisform.Suppliers.column4.ControlSource = "supplier_temp.email"
This is the code for the process button
If thisform.Proveedores.Column1.Check2.Value = 1
thisform.Preclientes.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 2
locate for supplier_temp.control = 2
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
This is the code for the reject button
If thisform.Suppliers.Column1.Check2.Value = 1
if !empty(suppliers_temp.obs)
thisform.Suppliers.column1.Check2.valid
select supplier_temp
go top
replace supplier_temp.control with 3
locate for supplier_temp.control = 3
REPLACE supplier.control WITH supplier_temp.control for supplier.id = supplier_temp.id IN supplier
Thisform.Suppliers.refresh
thisform.Suppliers.setfocus()
thisform.refresh
endif
endif
The grid is not refresh despite having in the init and in the buttons the commands Thisform.Suppliers.refresh,thisform.Suppliers.setfocus() and
thisform.refresh. When the form is closed and reopened, the grid is refreshed

&& reset the grid control because init() executed twice
Thisform.Suppliers.RecordSource = ""
CREATE cursor supplier_temp from array structure
Thisform.Suppliers.RecordSource = "supplier_temp"

Related

Auto number an attribute based on multiple attributes

I have a transaction like this
And I have a web panel using Work With Plus to insert data into the transaction
I want to auto number the attribute TmpltId based on the SalOutCd7Plc and BseCd like this:
Example:
SalOutCd7Plc = 1 and BseCd = 1 -> TmpltId = 1 then continue if SalOutCd7Plc = 1 and BseCd = 1 -> TmpltId = 2
But if SalOutCd7Plc = 1 and BseCd = 2 -> TmpltId = 1 and continue
If SalOutCd7Plc = 2 and BseCd = 1 -> TmpltId = 1 and continue
Something like that. How can I achieve this. Thank you
To autonumber the attribute TmpltId you may create a procedure with the following:
Rules:
parm(in:&SENSY0470M_SalOutCd7Plc,in:&SENSY0470M_BseCd,out:&SENSY0470M_TmpltId);
Source:
For each SENSY0470M order SENSY0470M_SalOutCd7Plc SENSY0470M_BseCd (SENSY0470M_TmpltId)
where SENSY0470M_SalOutCd7Plc = &SENSY0470M_SalOutCd7Plc
where SENSY0470M_BseCd = &SENSY0470M_BseCd
&SENSY0470M_TmpltId = SENSY0470M_TmpltId + 1
exit
when none
&SENSY0470M_TmpltId = 1
EndFor
Then, in your web panel before inserting you can call the procedure to get the new SENSY0470M_TmpltId
&NEW_SENSY0470M_TmpltId = Procedure.Udp(&SENSY0470M_SalOutCd7Plc, &SENSY0470M_BseCd)

Not able to select the 2nd row in a webtable usng description lanugauge in UFT

I have written the below piece of code to pick a row from web table to process it. The code picks/opens the first row successfully, however, when it is trying to double click the second row, it errors out with an error "Unspecified error". The web table has 7 rows, nevertheless, it is failing. Can some one point out what could be the reason for the failure please?
Set objDesc = Description.Create
objDesc("micclass").Value = "WebTable"
objDesc("html tag").Value = "Table"
Set objList = Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").ChildObjects(objDesc)
oCount = objList.Count
For k =0 To oCount - 1
colName = objList(k).GetRoproperty("cols")
If Trim(colName) = 21 Then 'This is the right table
objList(k).Highlight
rows= objList(k).GetROProperty("rows")
For i = 1 To rows
x = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_x")
y = objList(k).ChildItem(i,1,"WebElement",0).GetROProperty("abs_y")
Wait(2)
Set obj = CreateObject("Mercury.DeviceReplay")
obj.MouseDblClick x,y,LEFT_MOUSE_BUTTON
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebEdit("ben_elig_dte"), "ben_elig_dte", "WebEdit", Parameter("elig_date"))
Call ClickVerifyElement(Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebList("emp_state_withd_opt_decode"), "emp_state_withd_opt_decode", "WebList", Parameter("withhold_ind"))
Browser("3 - Employee Assign Benefits").Page("3 - Employee Assign Benefits").Frame("APPFRAMEWORK").WebButton("Save").Click
Next
Exit For
End If
Next

VFP combobox displaying all data to listbox

I'm newly introduced in visual foxpro and having some difficulties
I have combobox(combo1),listbox(list1),and tables(table1 and table2)
combo1's rowsource is table1.records
If I select a record in combo1, it will display all data from table2 to list1
Is it possible to do this? Thanks for your help :)
Remember this is just a sample built on a 'guess':
Public oForm
oForm = Createobject('SampleForm')
oForm.Show()
Define Class SampleForm As Form
Height = 800
Width=600
DataSession = 2
Add Object cmbCustomers As ComboBox With Top=10, Left=10, Width=250
Add Object lstOrders As ListBox With Top=10, Left=280, Height=780, Width=310
Procedure Init
With This.cmbCustomers
.RowSourceType = 3 && -SQL
.RowSource = "select CompanyName, CustomerId from ('"+;
_Samples+;
"Northwind\Customers') into cursor crsCustomers nofilter"
.ListIndex=1
Endwith
With This.lstOrders
.RowSourceType = 3 && -SQL
.RowSource = "select OrderId, OrderDate, ShippedDate, CustomerId from ('"+;
_Samples+;
"Northwind\Orders') o"+;
" where o.CustomerId = crsCustomers.CustomerId"+;
" into cursor crsOrders nofilter"
.ColumnCount = 3
.ColumnWidths = '70,120,120'
Endwith
Endproc
Procedure cmbCustomers.InteractiveChange
With Thisform.lstOrders
.ListIndex = 0
.Requery()
Endwith
Endproc
Enddefine

VB6 MSFlexGrid - Unable to set columns and rows count at runtime

I have a Visual Basic 6 form with a MSFlexGrid control inside, which takes data from a record set(ADODB) and displays them.
Before starting the copy of data to the FlexGrid, I'm trying to set the rows count, depending on records count. Also I have a collection which contains columns' names, then I can get the number of columns from here.
The following is a code snippet:
v_colsCount = UBound(aCols) + 2 // aCols = array with columns' names
v_regCount = rs.RecordCount // rs = my ADODB record set
myFlexGrid.Rows = 0 // for cleaning rows from a previous display
myFlexGrid.Rows = IIf(v_regCount > 0, v_regCount + 1, 2)
myFlexGrid.Cols = v_colsCount
myFlexGrid.FixedRows = 1
myFlexGrid.FixedCols = 0
There are 7532 rows and 52 columns. The problem comes when I run the application and try to execute this part of the code (fill the FlexGrid with data from the record set):
For iRow = 1 To v_regCount
For iCol = 0 To v_colsCount -2
sAux = ConvStr(rs.Fields(aCols(iCol)).Value)
myFlexGrid.TextMatrix(iRow, iCol) = sAux
I notice that
v_regCount = 7532 but v_colsCount = 2 ,
and I get an error ("Substring out of range"). If I swap the settings order (i.e. if I set myFlexGrid.Cols after set myFlexGrid.Rows), then
v_regCount = 0 and v_colsCount = 52
I don't understand why I can't set rows and columns count at the same time.
Any ideas?
Thanks in advance

While debugging the function breakpoint is not hit

I am using powerbuilder 11.2 and I have a pbl that creates a main screen. The user enters an order number in the textbox and hit enter and it fills in data in the bottom of the screen. I am trying to get debugging to hit a breakpoint in my function but it seems to ignore the breakpoint. Is there a way to break into the function? I have a variable I need to evaluate and I can't seem to get into the function while running. Here is the code:
Decimal{2} ld_total_hrs,ld_load_hrs,ld_unload_hrs
long ll_stops_rowcount, ll_row, ll_type, ll_ord_number, ll_rd_rowcount
datetime ldt_1st_stop, ldt_last_stop, ldt_start_time, ldt_end_time, ldt_deliver_time
string ls_dest_id, ls_type, ls_pay_id, ls_ref_number, ls_pay_leg_config
boolean lb_first_drop = TRUE
ld_load_hrs = 0
ld_unload_hrs = 0
SetNull(ldt_deliver_time)
ll_stops_rowcount = dw_trip.RowCount()
If ll_stops_rowcount < 1 then Return 0
For ll_row = 1 to ll_stops_rowcount
If ll_row = 1 then
ldt_1st_stop = dw_trip.GetItemDateTime ( 1, "stops_stp_arrivaldate" )
End if
If dw_trip.GetItemString(ll_row,"stops_stp_type") = "PUP" then
ldt_start_time = dw_trip.GetItemDateTime(ll_row,"stops_stp_arrivaldate")
ldt_end_time = dw_trip.GetItemDateTime(ll_row,"stops_stp_departuredate")
ld_load_hrs = ld_load_hrs + (f_datetimediff(ldt_start_time,ldt_end_time)/60)/60
End if
If dw_trip.GetItemString(ll_row,"stops_stp_type") = "DRP" then
ldt_start_time = dw_trip.GetItemDateTime(ll_row,"stops_stp_arrivaldate")
ldt_end_time = dw_trip.GetItemDateTime(ll_row,"stops_stp_departuredate")
ld_unload_hrs = ld_unload_hrs + (f_datetimediff(ldt_start_time,ldt_end_time)/60)/60
// get the first drops info for the report if paylegaslane is true else get last drop
ls_pay_leg_config = is_PayLegConfig
If is_CompanyOverride=true then
ls_pay_leg_config = "ByLeg"
End if
//TGRIFFIT - PayLegConfig = 'ByLeg' in TMW is equivalent to 'PayLegAsLane = 'Y' in FSS
if Upper(ls_pay_leg_config) = 'BYLEG' then
If lb_first_drop Then
ldt_deliver_time = ldt_end_time
ls_dest_id = dw_trip.GetItemString(ll_row,"stops_cmp_id")
ls_ref_number = dw_trip.GetItemString(ll_row,"stops_stp_refnum")
lb_first_drop = FALSE
End if
else
ldt_deliver_time = ldt_end_time
ls_dest_id = dw_trip.GetItemString(ll_row,"stops_cmp_id")
ls_ref_number = dw_trip.GetItemString(ll_row,"stops_stp_refnum")
end if
End if
Next
ldt_last_stop = dw_trip.GetItemDateTime ( ll_stops_rowcount, "stops_stp_departuredate" )
ld_total_hrs = (f_datetimediff(ldt_1st_stop,ldt_last_stop)/60)/60
ll_ord_number = long(dw_triptab.GetItemString(1,"ord_number"))
//If g_messlevel% < 1 Then
if gnv_app.ii_MessLevel < 1 Then
ids_revdist.Reset()
End if
//Load the datastore that stores all the revenue distribution values
ll_rd_rowcount = ids_revdist.RowCount()
ids_revdist.InsertRow(0)
ll_rd_rowcount ++
ids_revdist.SetItem(ll_rd_rowcount,"mov_number",i_movenum%)
ids_revdist.SetItem(ll_rd_rowcount,"lgh_number",dw_trip.GetItemNumber(1,"stops_lgh_number"))
ids_revdist.SetItem(ll_rd_rowcount,"total_hours",ld_total_hrs)
ids_revdist.SetItem(ll_rd_rowcount,"load_hours",ld_load_hrs)
ids_revdist.SetItem(ll_rd_rowcount,"unload_hours",ld_unload_hrs)
ids_revdist.SetItem(ll_rd_rowcount,"deliver_date",ldt_deliver_time)
ids_revdist.SetItem(ll_rd_rowcount,"dest_code",ls_dest_id)
ids_revdist.SetItem(ll_rd_rowcount,"ref_number",ls_ref_number)
Return ids_revdist.RowCount()
I need to evaluate this line specifically and I set a breakpoint at this line:
ls_pay_leg_config = "ByLeg"
as well as the following lines. It does not break. I am rusty at PowerBuilder and can figure this out.
Put the breakpoint at the start of the loop.

Resources