form display.......the one who solve it deserve more than 500 points :)

I have a form in which i insert date,station_id,production
each station has many distillers like(station A has D1,D2,D3)and the total of the D1,D2,D3 is the prodction of the station.

i have a table named distillers:


what i want to do is to let the user see the station form to insert date,station_id and to make a link next to production textbox that opens a new pop up window and this window has:
date(same as inserted in station form,distiller_id ,production)
what i want is to list all the distillers related to this station like in Station A it will show me a form in this way:

date:(as the one entered in stationA form)

D1:       , storage:
D2:       , storage:  
D3:       , storage:

and that form will insert the values into distillers table:
so each distiller will save the same form date with storage entered,

at last in the stationA form i want after submitting the result of the distiller form the window closes and the production field in the stationA form hold or shows the total of the 3 distillers entered through the pop up window.
I know its a bit difficult and confusing but i really need help in that and if i can give more than 500 points ,i will.
Who is Participating?
anyways, best of luck =)
is it like this:

PAGE [primary data] ---> POPUP [secondary data] --> CLOSE() --> [secondary data --> primary data] :: popup-->close, parent-->reload etc

1. How are the distillers shown?? DataGrid ??
2. Would it be nicer to display the data as a master - child grid without the need for a pop up.
3. If a popup is used, we can bubble the data from the PopUp container to the Parent Container via the Session object (which once retrieved is immediately cleared, the Session object is used as a delivery mechanism and not a persistance mechanism throughout the application)

What you are asking is not difficult? The code is pretty straight forward (no rocket scientist required). What is difficult however is devising the architecture.

Provide more info about the UI on the parent page and the pop up page.

noor21Author Commented:
lets start from the structure of the database tables:
1.station table(station_id,date,production)------------->station_id & date are keys
2.distiller table(distiller_id,station_id,date,storage)----------------->distiller_id & date are keys

the forms design:

*station_id:------------->(selected from drop down list)
*production:----------------------------->(read only text that gets its data from a link that shows pop up window with distiller form.


*date:------------------------>(should be the same as in station_form)
*Distiller1,distiller2,distiller3--------------------------------------->(should be automatically created based on the relation with the station they belong to)

ex:station(A) has 3 distillers(D1,D2,D3) when i choose from station_form station(A),they should appear automatically in the pop up window

*storage----------------------(each distiller has a text box to enter the values in it)
*submit button that stores the values back to the distiller table like this:

distiller_id    |station_id   | date          |storage
D1               |station A    |1/1/2005    |  55
D2               |station A    |1/1/2005    | 20
D3               |station A    |1/1/2005    |10

so,in the station form the production textbox will automatically has(D1+D2+D3)=85

and stored back to the station table as:

station_id   |  date    | production
station A    |1/1/2005| 85

and that after closing the pop up window.

i hope that i gave you the details you need,and i never used parent/child datagrid so i don't know how would it look like.

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

do you need a popup becoz of real estate issues/fitting issues??? becoz you prolly do not need the pop up window for what you have described. Unless, you want the user to confirm the selection???
noor21Author Commented:
i want the pop up for confirmation or if u have a better easier idea i would love to hearit
Public Class Station
      Inherits Page
      Protected WithEvents ProductionNumbers As Label
      Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            If Not IsPostBack Then
                  'deal with data init stuff
            ElseIf Not Session(DistillerPopUp.SessionKeyName) Is Nothing Then
                  'grab a copy of the object in the session object
                  Dim data As DistillerItemData = DirectCast(Session(DistillerPopUp.SessionKeyName),DistillerItemData).Copy()
                  'remove item from session
                  'session used only as a delivery tool
                  'now you have data sent from the pop up
                  'you can set the label
                  'but before you do that you should submit data to the database
                  'psuedo code
                  'strongly type DataSet
                  Dim ds As New ProductionDataSet()
                  Dim row As ProductionDataSet.ProductionRow = ds.Production.NewProductionRow();
                  row.station_id = data.ID
         = data.ProductionDate
                  row.production = data.ProductionNumbers
                  'add row
                  'pseudo code
                  Dim connection As New SqlConnection("<connection_string")
                  Dim insertCommand As SqlCommand = connection.CreateCommand()
                  insertCommand.CommandText = "INSERT station (station_id,date,production) VALUES(@station,@date,@production)"
                  'example of use SqlDataAdapters to update data
                  'can handle complex conditions
                  Dim da As New SqlDataAdapter()
                  da.InsertCommand = insertCommand
            End If
      End Sub
End Class

Imports System.Globalization
Public Class DistillerPopUp
      Inherits Page
      Protected WithEvents dgResults As DataGrid
      Public Const SessionKeyName = "DistlillerPopUp"
      Public Const ClientScriptName = "DistlillerPopUpScript"
      Private Sub btnSubmit_Click(ByVal sender As Object,ByVal e As EventArgs) Handles btnSubmit.Click
            Dim d As New DistillerItemData()
            'pseudo code
            d.ID = dgResults.Items(0).Cells(1).Text
            d.ProductionDate = DateTime.ParseExact(dgResults.Items(0).Cells(2).Text,"M/d/yyyy",new CultureInfo("en-US",True))
            d.ProductionNumbers = 0
            For Each item As DateGridItem In dgResults.Items
                  d.ProductionNumbers += CInt(item.Cells(3).Text)
            Session(SessionKeyName) = d
            'fires off client side script code which instructs the main window to repost and then closes the pop up window
            'this page is opened through the showModelessDialog method good with MSIE
            'please check documentation at for details on this method.
            Page.RegisterClientScriptBlock(ClientScriptName,"<script language='javascript'>top.dialogArguments.document.forms[0].submit(); top.close();</script>")
      End Sub
End Class

<Serializable()> _
Public Class DistillerItemData
      Public ID As String
      Public ProductionDate As DateTime
      Public ProductionNumbers As Integer
      Public Sub New()
      Public Function Copy() As DistillerItemData
            Dim d As New DistillerItemData
            d.ID = Me.ID
            d.ProductionDate = Me.ProductionDate
            d.ProductionNumbers = Me.ProductionNumbers
            Return d
      End Function

End Class
That's the code behind...
The story continues... (I can feel this being a looooong day =P )

anyways, in the main page, have the showModelessDialog pass the parameters in the url of whatever you need th pop up to access.
noor21Author Commented:
what do u mean by session key name?
it's just an identifier.... a constant string
noor21Author Commented:
thats a long code and i have copied it and pasted into aspx code behind but got some errors and i don't really know how to fix them coz i couldn't understand the whole thing here r the errors:
ElseIf Not Session(DistillerPopUp.SessionKeyName) Is Nothing Then---------------------->(line under distillerpopup)
  Dim ds As New ProductionDataSet------------------------------------------------------------>(line under productiondataset)
row.station_id = data.ID-------------------------------------------------------------------------->(line under row)
   = data.ProductionDate
            row.production = data.ProductionNumbers
            'add row
ahhh, noor,

this is just pseudo-code (not real code) to show you what you'd have to do. In this case, a cut and paste operation will not do. You must gain understanding of what needs to be done. Copying code here will not help you out. It is a question of understanding the architecture behind the code.

The DistillerPopUp class does not exist in your code. It is just a class to show you what the PopUp window's code behind so do and be like.

ProductionDataSet is just an example of using a strongly typed dataset. It aids in data operations.

The code pasted is just all examples of what CAN be done. In this classic case, simply copying cannot save you.

noor21Author Commented:
i am new to and i have an important project to be done,thats why sometimes i just need urgent aid but i will try to do it.
1. The parent page has information that needs to be passed onto the popup page.
2. When the user clicks on the button, 2 things can occur:
      a. A Postback occurs wherein the client-side script is provided (in cases where data from server needs to be passed via the URL and in the correct format)
      b. No Postback occurs. Direct client-side script occurs with the values provided or obtained at point of clicking (via client-side script)
3. The pop up page now loads.
4. In the code, the page picks up the values from the parent page via the Request.QueryString collection. It then connects to the database and displays the data appropriately.
5. The popup window is now visible to the end-user.
6. The use clicks on the submit button.
7. A postback occurs (in order not to have another window opened, use an IFRAME in the html of the popup window to contain the popup.aspx)
8. In postback, the data is packaged and saved into the Session Object. The use of a constant for the name allows for safe retrieval from the other parent page.
9. Now after the data is packaged, client-side code is emitted to do 2 things:
      a. To force the parent page to re-post (dialogArguments.document.forms[0].submit();)
      b. To close the pop up window (top.close();)
10. Now that the postback of the parent occurs, we look into whether the Session Object with the Key equalling the const exists and is not nothing
        ElseIf Not Session(DistillerPopUp.SessionKeyName) Is Nothing Then
11. If it is not nothing, we get a copy and immediately remove the item from the Session Object.
12. Now that we have the data, we connection to the database and update it.
13. Everything is done.
noor21Author Commented:
any other easier solutions?
1. The parent page has the information that is set via javascript:
2. The user selects the dropdown and clicks on the button.
3. The popup appears with the data passed thru via client-side script in the url.
4. The popup does the necessary server-side operations to show the data.
5. When the data is selected, the popup window sends information down to the hidden inputs of the parent window
6. A reload is forced on the parent.
7. The parent picks up the hidden input values and does the necessary work.
noor21Author Commented:
i tried doing it myself but i need help with coding techniques
noor21Author Commented:
i need more help with that plz
sorry, but I am excusing myself from this thread. I feel that it is one thing to help, it is quite another to be asked to do everything from ground up.
noor21Author Commented:
b1xml2 ,
it is suppose to be an expert who answers and of course you get alot of questions from people who are just starting to deal with like myself,i want help in understanding the things not someone to do everything for me or i would just give it to any programmer to do it and i sit back and relax....any way i thank you alot for your help and thanks for your time and valuable answers
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.