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)
Related
I want to generate 3 NEW variables using these variables in my data set:
Ucod
19 variables in series by this name: Record_2, Record_3......Record_20
Both of them have values in alphanumerical format in it, basically ICD codes i.e, I150
I want to generate 3 new variables satisfying each of three new condition:
People dying primarily of COVID (Var1=1 if Ucod= U07.1)
People dying of a non-COVID condition WITH covid (Var2=1 IF Ucod != U07.1 & Record_2/20= U07.1)
People dying of a non-COVID condition WITHOUT covid (Var3=1 if Ucod != U07.1 & Record_2/20 != U07.1)
Can anyone suggest a code which can help me to generate these 3 variables using these 3 condition.
This may help. Note how I needed to define a toy dataset to give flavour to the problem.
* Example generated by -dataex-.
clear
input str5(Ucod Record_2) str4(Record_3 Record_4)
"U07.1" "U000" "U111" "U222"
"U999" "U07.1" "U444" "U333"
"U888" "U777" "U666" "U555"
end
gen wanted1 = Ucod == "U07.1"
gen count = 0
quietly foreach v of var Record_* {
replace count = count + (`v' == "U07.1")
}
gen wanted2 = Ucod != "U07.1" & count > 0
gen wanted3 = Ucod != "U07.1" & count == 0
list
+------------------------------------------------------------------------------+
| Ucod Record_2 Record_3 Record_4 wanted1 count wanted2 wanted3 |
|------------------------------------------------------------------------------|
1. | U07.1 U000 U111 U222 1 0 0 0 |
2. | U999 U07.1 U444 U333 0 1 1 0 |
3. | U888 U777 U666 U555 0 0 0 1 |
+------------------------------------------------------------------------------+
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"
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
So I have 13 binary values, which I call b_1... b_13, and based off these values I'd like to either set something I call indic_j to a previously defined string called inf_j, or nothing at all. Is it possible to do this without using 13 "If..." statements? What I have tried is below:
inf_1 = "aaaaa"
inf_2 = "bbbbb"
... and so on defining 13 infs, where aaaaa, bbbbb etc are names of columns in a table that I want to select.
FOR j = 1 to 13
IF b_j = 1 THEN "indic_"+j = inf_j + ",";
ELSE "indic_"+j = ""
ENDIF
ENDFOR
Also, before this I haven't introduced anything called indic_1, indic_2, etc. Is this needed?
My end goal is to transfer selected columns over to Excel. I've no problems doing this with predetermined columns, but I'm not sure how to allow for selected columns only.
I've tried using 13 IF statements, but I'm getting operator/operand type mismatch errors. My code currently is
IIF(b_1 = 1, indic_1 = inf_1 + ",",indic_1 = "")
IIF(b_2 = 1, indic_1 = inf_2 + ",",indic_1 = "")
IIF(b_3 = 1, indic_1 = inf_3 + ",",indic_1 = "")
and so on for 13 times, and then
SELECTIONRANG = indic_1 + indic_2 + indic_3 + indic_4 + indic_5 + indic_6 +indic_7 + indic_8 + indic_9 + indic_10 + indic_11 + indic_12 + indic_13
SELECTIONRANGE = LEFT(SELECTIONRANG,LEN(Selectionrang)-1)
You could create te variable name as a string and use it with &
As:
ind = 13
Var = "inf_" + ind
&Var ** inf_13
This question already has answers here:
Computing Result on server side but session data not isolated per user
(3 answers)
Closed 8 years ago.
I working in a app that i use to compute user details. But somehow, the values of a user alter that of another user.
Below is a fragment of the code
def Compute_UserScore(self, details, ques_no):
try:
if(HomePage.answer_.strip() == ""):
self.response.write("""<script type = "text/javascript">
alert("Dear User, You can not answer same answer twice.. Take test Again !");
</script>""")
self.redirect('/otherPages/subjectSelect.html')
else:
count = 0
HomePage.ans_no = 0
HomePage.unans_no = 0
HomePage.correct_no = 0
HomePage.wrong_no = 0
HomePage.failed_ques = list()
HomePage.answer_ = HomePage.answer_.strip()
question_1 = HomePage.question_.split(" gcdc_split_format ")
while (count != (ques_no)):
user_answer = str(details[count]).strip().capitalize()
real_answer = str(HomePage.answer_[count]).strip().capitalize()
if (len(str(user_answer).strip()) == 1):
HomePage.ans_no = HomePage.ans_no + 1
if(user_answer.strip() == real_answer.strip()):
HomePage.correct_no = HomePage.correct_no + 1
else:
HomePage.wrong_no = HomePage.wrong_no + 1
HomePage.failed_ques.append(str("No. " + str(int((count + 1))) + " " + str(question_1[count])))
else:
HomePage.unans_no = HomePage.unans_no + 1
count = count + 1
HomePage.answer_ = ""
except:
self.redirect('/')
return " "
and this is how my homepage looks like
class HomePage(webapp2.RequestHandler):
percentage = None
subject_answered = None
username_ = None
email_ = None
super_date = None
answer_ = " "
question_ = " "
failed_ques = list()
wrong_no = 0
correct_no = 0
ans_no = 0
unans_no = 0
The problem is, when a user A, take a test, He sees the result of another user B.
Read about Using instance variable, but still have not figure ouut how to make it work
Solution is simple: Stop setting class variables in web development! :)
Web requests are stateless, it's mean you never know what's happen between requests - between setting class variable and redirect.
Use database to store temporary data with user login/name (or use hashing/random for security) or send values by parameters (hidden or after '?') to other html page.
Using database is better, if you don't want this then send values (hidden in html) over http. Here is one version of solution (without database):
1.Use normal html form and write handler for this form - question page.
2.In handler write get method like this:
def post(self, some_parameters):
...
self.render('homepage.html', {'ans_no': ans_no,\
'uans_no': uans_no ...})
3.homepage.html have to be template for showing results