|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hey Guys,
I have a tough one here, I want to set an If statement for a repeated region inside a repeated region... Confusing?? OK Here is the story: First, I repeat all products which includes the repeated values of components of the product and multiply it by the quantity So now I have total for each component per product Now, I want to check if the amount of each component is in stock or not and If all the components of a product is available, Then add the product to next step Then loop for the second product Any clue ![]() |
|
#2
|
|||
|
|||
|
So you run a loop to grab your products and quantity, and a loop for each product to get a list of components required for the product and how many components you would need for that quantity of products, and you want to take those results and check whether or not all the necessar components are in stock, correct?
|
|
#3
|
|||
|
|||
|
Exactly but ...
Thank you for your help, actually I did something which helped. Below is the original code plus the modification I made in bold but now I have another 2 problems (sorry if i'm asking too much )
Question No. 1: how to update the value of the onhold find it in bold and italic Question No. 2: If one of the component is False then calculate the minimum quantity to produce based on the stock avilable for this component And if 2 or more components are false then calculate the minimum quantity to produce based on the stock avilable for each component and then select the minimum quantity I'm sorry if it sounds stupid or confusing <% Set DataConn = Server.CreateObject("ADODB.Connection") Set CmdProducts = Server.CreateObject("ADODB.Recordset") DataConn.Open "dsn=medco-local;" MYSQL1 = "SELECT * FROM sales_order_products WHERE MSO='" & Request.QueryString("mso") & "'" CmdProducts.Open MYSQL1, DataConn Do While Not CmdProducts.EOF Set CmdSalesComponents = Server.CreateObject("ADODB.Recordset") MYSQL2 = "SELECT * FROM required_components WHERE Product='" & CmdProducts("Product") & "'" CmdSalesComponents.Open MYSQL2, DataConn Dim Yes Dim No Yes = 0 No = 0 Do While Not CmdSalesComponents.EOF Required = CmdSalesComponents("Amount")* CmdSalesComponents("Weight") Available = CmdSalesComponents("Stock") - CmdSalesComponents("OnHold") If Available / Required => CmdSalesComponents("Quantity") Then Yes = Yes + 1 Else No = No + 1 End IF %> <% CmdSalesComponents.MoveNext Loop %> <% If No = 0 then // Question No. 1 Do While Not CmdSalesComponents.EOF Dim Component Dim Onhold Component = CmdSalesComponents("Component") Onhold = CmdSalesComponents("OnHold") + (CmdSalesComponents("Amount")* CmdSalesComponents("Weight")) Set CmdAddRecord = Server.CreateObject("ADODB.Recordset") MYSQL3 = "SELECT * FROM raw_material WHERE Item='" & Component & "'" CmdAddRecord.Open MYSQL3, DataConn, 1, 3 CmdAddRecord.Update CmdAddRecord.Fields("OnHold") = OnHold CmdAddRecord.Update CmdAddRecord.Close Set CmdAddRecord = Nothing CmdSalesComponents.MoveNext Loop End If %> <% If No //Question No.2 End If %> <BR> <% CmdProducts.MoveNext Loop CmdSalesComponents.Close Set CmdSalesComponents = Nothing CmdProducts.Close Set CmdProducts = Nothing DataConn.Close Set DataConn = Nothing %> |
|
#4
|
|||
|
|||
|
You seem to be moving in the right direction on your own. Unfortunately there's no "elegant" way to handle these types of problems. You'll have to just write a function or two to perform the checks you want, and they'll be a mess of if statements i'm sure.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Need Help in ASP and Repeat Region |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|