sri
|
Posted: 11/18/2004, 2:08 AM |
|
hi
can any body tell me how to display a message box showing the last inserted values i.e like if the user has inserted four records in one session then the message box should show the user that he has inserted 4 records
any help would appreciated
thanks in advance
Mr Peter please do helpme.
i havent got any replies from you till now
i have posted already some question but nobody has answered me till now
regards
srinivas
|
|
|
dataobjx
Posts: 181
|
Posted: 11/18/2004, 5:29 AM |
|
One way would be to place code in the AfterInsert event that would associate the users Browser SessionID with the ID of the records being inserted.
You could add another field to the table to record the SessionID along with the regular data and then use a Where clause to display those records having the Browsers SessionID OR you could build a string in the users session, separating each LastRecordID with a comma.
E.g;
Dim strInserted
LastID = CCDLookUp("@@IDENTITY", "id", "id=@@IDENTITY", DBInternet)
strInserted = Session("InsertedThisSession")
If strInserted IS EMPTY Then
strInserted = LastID
Else
strInserted = strInserted & "," & LastID
End If
Session("InsertedThisSession") = strInserted
Then, at the end of the users session - whatever mechanism you're using to ultimately display this synapsis (of records for the session)... you would perhaps use the Split function to turn the string into an array that you can iterate through.
Dim MyArray
strInserted = Session("InsertedThisSession")
If Len(strInserted) > 0 Then MyArray = Split(strInserted, ",", -1, 1)
Set Session("InsertedThisSession") = EMPTY
For i = 0 to UBound(MyArray)
'iterate through the last inserted ID's and perform additional DB operations.
Next
Hope this helps.
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/18/2004, 7:18 AM |
|
[Hi
i am very much thankful for your answer but since i am new to this programming can you just tell me how to promt the user showing the last inserted records
i am using this statement inorder to get the values of the last inserted records
SELECT IDENT_CURRENT('Rueckgabe') as intIdent
which show me the last inserted records i mean the values
now i just want to tell the user that he had inserted four records
for the first time
and if he is still in session and he again inserts records say 3 then i should prompt his that he has inserted total of 7 records
today
or is there any way by which i can pop up a window showing only the last inserted records
since i am very new to this please do give some help
regards
srinivas
|
|
|
dataobjx
Posts: 181
|
Posted: 11/18/2004, 8:02 AM |
|
OK, let's try this then. You realize of course that you have not provided sufficient information to give a targeted answer.
For instance;
* Is the user logged in when they insert the records?
* Is it important to be able to historically track what records a user inserted over the course of time.
* Etc.
EASY METHOD.
In the AfterInsert event place the following code;
If Session("RecordsInsertedCount") IS EMPTY Then Session("RecordsInsertedCount") = 0
Session("RecordsInsertedCount") = Session("RecordsInsertedCount") + 1
This will provide a count of the inserted records for the session.
Place a label on your form and place the following code in the BeforeShow event;
MyDataSourceName.label1.value = Session("RecordsInsertedCount")
Replace MyDataSourceName with the name of your grid.
MORE COMPLEX METHOD
Add two (2) fields to your table.
added_by_id int
date_added smalldatetime
Add these fields to the record form as hidden fields.
In the BeforeShow event place the following code;
Function MyDataSourceName_added_by_id_BeforeShow()
MyDataSourceName.added_by_id.value = Session("UserID")
End Function
Function MyDataSourceName_date_added_BeforeShow()
MyDataSourceName.date_added.value = FormatDateTime(Now(), vbShortDate)
End Function
Add a new (very small) grid somewhere on your users interface and set the SQL. When asked whether to display the RecordCount, place a tick in the check box.
Select IDENT_CURRENT From TABLENAME Where date_added = '" & FormatDateTime(Now(), vbShortDate) & "' And added_by_id = " & Session("UserID")
The grid will now display the number of newly inserted records along with the values you want to display about those records, like name, etc.
If this doesn't help, give me more information to work with.
If the user isn't logged in when they add the record, you'll need to use the Array method or similar as mentioned in the previous post.
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/18/2004, 8:35 AM |
|
hi
thanks very much for the quick update which you are giving
i really appreciate your co-operation
yes regarding your information
yes the user is logged in and
he should be able to see historically alll the inserted data.
and i just want to show him the inserted records in a message boy or in a pop up window
regards
srinivas
|
|
|
dataobjx
Posts: 181
|
Posted: 11/18/2004, 8:49 AM |
|
OK, Use the method called "MORE COMPLEX METHOD" from the previous post.
Make sure you add the fields I mentioned on the Record Page so that the user_Id and Date_added values are saved on Insert.
Next
Create a new page... I'll call it "Inserted_Summary.ccp"
Add a grid to the Inserted_Summary page.
When asked whether to display the RecordCount, place a tick in the check box.
The SQL for the grid should be something along these lines... modify appropriately.
Select IDENT_CURRENT From TABLENAME Where date_added = '" & FormatDateTime(Now(), vbShortDate) & "' And added_by_id = " & Session("UserID")
The grid will now display the number of newly inserted records along with the values you want to display about those records, like name, etc.
If you want the user to be able to click a link and open this "Inserted_Summary" page...
I have provided a third party script below... this one or similar should work for you.
STEP 2 shows you how to cause the pop-up from a hyperlink
Let me know how it goes.
==============================================================
Script: Amazing Frameless Popup Window - Version I
Functions: In IE4 And later, this script launches a popup
window without the Windows frame Or titlebar
(that Is, a "containerless" window). In other
browsers, it launches a standard popup window.
Position, width, And height are settable.
Automatic closing of the window On leaving the
page may also be optionally Set.
Browsers: IE4 And later
Degrades fully functionally In other browsers
Author: etLux
==============================================================
Step 1.
Inserting the <script> In your page
Put the following <script> </script> In the head
section of your launching page.
Set the variables As indicated In the script.
<script>
// Amazing Frameless Popup Window - Version I
// (C) 2000 www.CodeLifter.com
// Free For all users, but leave In this header
// Set the popup window width And height
var windowW=214 // wide
var windowH=398 // high
// Set the screen position where the popup should appear
var windowX = 260 // from left
var windowY = 100 // from top
// Set the url of the page To show In the popup
var urlPop = "yourpage.html"
// Set the title of the page
var title = "This Is A Frameless Popup Window"
// Set this To True If the popup should Close
// upon leaving the launching page; Else, False
var autoclose = True
// ============================
// Do Not edit below this Line
// ============================
s = "width="+windowW+",height="+windowH;
var beIE = document.all?True:False
Function openFrameless()
If (beIE)
NFW = window.open("","popFrameless","fullscreen,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"</html>"
NFW.document.open();
NFW.document.write(frameString)
NFW.document.close()
Else
NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
NFW.focus()
If (autoclose)
window.onunload = Function()NFW.close()
</script>
==============================================================
Step 2.
Triggering the popup window
Call the openFrameless Function from a link, like this:
<a href="javascript:openFrameless()">click here</a>
==============================================================
Step 3.
Conditioning the page that goes In the popup window
Add the following Call To the <body> tag of the page that
will Open In the popup *If* your popup does Not come To the
front after it loads. This Is occasionally needed In early
versions of IE4, And With certain types of page content that
manipulate focus. If In doubt, Put it In -- it can't hurt.
<body onload="top.window.focus()">
==============================================================
ADDENDUM 2/22/2001
Making the Frameless Popup Center On the Screen Automatically
We've had numerous requests for this, and a minor modification
of the script can Do it. Here's how...
Comment out the two lines As shown, And add the two shown below
them.
// Set the screen position where the popup should appear
//var windowX = 260 // from left
//var windowY = 100 // from top
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);
==============================================================
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/19/2004, 4:11 AM |
|
hi
thanks very much
i tried your code but i have a problem which the select statement
its not working correctly
i mean where clause is not right
i am not sure whether we can use where clause wih select ident_current or not
so can you just help me out
regards
srinivas
|
|
|
sunny_99
Posts: 20
|
Posted: 11/19/2004, 5:12 AM |
|
hi
can you just look into my problem#
regard
srinivas
|
|
|
dataobjx
Posts: 181
|
Posted: 11/19/2004, 6:13 AM |
|
Perhaps simply changing it from
Select IDENT_CURRENT From TABLENAME Where date_added = '" & FormatDateTime(Now(), vbShortDate) & "' And added_by_id = " & Session("UserID")
To
Select * From TABLENAME Where date_added = '" & FormatDateTime(Now(), vbShortDate) & "' And added_by_id = " & Session("UserID")
In order to do this for you properly, I'd need to know your table structure - so you may need to extrapolate a little. Otherwise, post your table structure.
Also ensure that the added_by_id and date_added fields were properly updated by your record.
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/19/2004, 7:23 AM |
|
Date datetime 8 1
CustomerNo char 9 1
ReturnID int 4 0
Header char 30 1
UserID int 4 1
and here datum is the same as date_added
and User ID is the session ID
actually to make clearly understand
the wesite ´goes like this
it is article returning website where the user can return the articles
if the user return say 5 different articles ( there is a condition like the place from where he brought the article)
if the article belongs to the same place then he will have same return id
and if it belongs to different place then based on the place each return should have unique return id along with place
for example
if he brought four items from 4 different placee
then the output should be like this
returnID place
1 H1
2 H2
3 H3
4 H4
and this should be on the header of the page
along with all the detail information about the article belonging to the same place
and there is a button on the page which is used for the return
when he presses that then i should make him to show a message box
showing how many returns ID he got a and each time the message box should show the value of new records inserted
i hope you understand what i am up to
anyhow thanks for the all the help which you are providing to me
For eample
name
address
|
|
|
sunny_99
Posts: 20
|
Posted: 11/19/2004, 7:23 AM |
|
Date datetime 8 1
CustomerNo char 9 1
ReturnID int 4 0
Header char 30 1
UserID int 4 1
and here datum is the same as date_added
and User ID is the session ID
actually to make clearly understand
the wesite ´goes like this
it is article returning website where the user can return the articles
if the user return say 5 different articles ( there is a condition like the place from where he brought the article)
if the article belongs to the same place then he will have same return id
and if it belongs to different place then based on the place each return should have unique return id along with place
for example
if he brought four items from 4 different placee
then the output should be like this
returnID place
1 H1
2 H2
3 H3
4 H4
and this should be on the header of the page
along with all the detail information about the article belonging to the same place
and there is a button on the page which is used for the return
when he presses that then i should make him to show a message box
showing how many returns ID he got a and each time the message box should show the value of new records inserted
i hope you understand what i am up to
anyhow thanks for the all the help which you are providing to me
regards
srinivas
|
|
|
sunny_99
Posts: 20
|
Posted: 11/19/2004, 8:03 AM |
|
hi
i just posted all the details
can you just look into that
thanks very much for the uspport you are giving to me
regards
srinivas
|
|
|
dataobjx
Posts: 181
|
Posted: 11/20/2004, 12:12 PM |
|
Almost sounds like, well - a Shopping Cart... or at least the methodology is very similar.
Tell you what, forward your code and .mdb (or data structure) for the project to administrator@dataobjx.net and we'll have a quick look at it, ok.
It's simply going to be faster that way probably. We'll see if we can help.
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/22/2004, 4:23 AM |
|
this is my code for the insertion of data into two tables
i hope that should be fine with u
regards
Function OffenPositionen_AfterSubmit() 'OffenPositionen_AfterSubmit @8-6FC95866
'Custom Code @134-73254650
' -------------------------
Dim conn,conn1
Dim ErrorMessage
Dim SQL
Dim varNewID,rsNewID,Fial,FialID
Dim RecordSet,RecordSetPos
dim Filiale1, Filiale11
dim RowIndex1,UserID1,KundenNummer1,LSNummer1,LSDate1
dim Status1 ,ArtikelNummer1, Herstellernummer1, Bezeichnung11,Bezeichnung21 ,ATKZ1,Menge1
dim RuckgabeMenge1,EKPreis1,Einlagerungsgebuhr1,Lagerort1,Drucken1,Datum1
Dim KundenNummer
Dim KdFilialeSet,KdFilialeValues
Set conn = New clsDBConnection1
conn.open
KundenNummer = Session("KundenNummer")
' response.write("<br>"&KundenNummer)
if (event1 <> 0) then
if Last_Identity= 0 then
SQL = "SELECT DISTINCT Filiale FROM OffenPositionen where status= 'N' " &_
"And KundenNummer =" & KundenNummer
'response.write("<br>"&SQL)
set RecordSet = conn.Execute(SQL)
while not (RecordSet.EOF)
'response.write CCGetFromPost("ListBox1", Empty) & "<br>"
Filiale1 = CCGetValue(RecordSet,"Filiale")
SQL = "INSERT INTO Rueckgabe(KundenNummer,UserID,Datum,Filiale,Kdref,Versantart)" &_
"VALUES ("& KundenNummer &","& conn.ToSQL(CCGetUserID(), ccsInteger) & "," & conn.ToSQL(Now(), ccsDate) & ",'"& Filiale1 &"','"& (CCGetFromPost("TextBox1", Empty) ) &"','"& (CCGetFromPost("ListBox1", Empty) ) &"')"
'response.write("<br>"&SQL)
conn.Execute(SQL)
SQL = "SELECT IDENT_CURRENT('Rueckgabe') as intIdent "
Set rsNewID = conn.Execute(SQL)
If Not (rsNewID.EOF) then
Last_Identity = CInt(CCGetValue(rsNewID,"intIdent"))
else
response.write("<br> The @@IDENTITY Call did not Work!")
response.end()
End if
SQL = " Select * from OffenPositionen where Filiale='" &Filiale1&"'" &_
" And KundenNummer = " &KundenNummer
Set RecordSetPos = conn.Execute(SQL)
while NOT RecordSetPos.EOF
RowIndex1 = CCGetValue(RecordSetPos, "RowIndex")
UserID1 = CCGetValue(RecordSetPos, "UserID")
KundenNummer1 = CCGetValue(RecordSetPos, "KundenNummer")
LSNummer1 = CCGetValue(RecordSetPos, "LSNummer")
LSDate1 = CCGetValue(RecordSetPos, "LSDate")
Status1 = CCGetValue(RecordSet, "Status")
ArtikelNummer1 = CCGetValue(RecordSetPos, "ArtikelNummer")
Herstellernummer1 = CCGetValue(RecordSetPos, "Herstellernummer")
Bezeichnung11 = CCGetValue(RecordSetPos, "Bezeichnung1")
Bezeichnung21 = CCGetValue(RecordSetPos, "Bezeichnung2")
ATKZ1 = CCGetValue(RecordSetPos, "ATKZ")
Filiale11 = CCGetValue(RecordSetPos, "Filiale")
Menge1 = CCGetValue(RecordSetPos, "Menge")
RuckgabeMenge1 = CCGetValue(RecordSetPos, "RuckgabeMenge")
EKPreis1 = CCGetValue(RecordSetPos, "EKPreis")
Einlagerungsgebuhr1 = CCGetValue(RecordSetPos, "Einlagerungsgebuhr")
Lagerort1 = CCGetValue(RecordSetPos, "Lagerort")
Datum1 = CCGetValue(RecordSetPos, "Datum")
SQL = "INSERT INTO RueckgabePositionen(ReturnID,KundenNummer,LSNummer,LSDate,Filiale,ArtikelNummer,Herstellernummer,Bezeichnung1,Bezeichnung2,ATKZ,Menge,RuckgabeMenge,EKPreis,UserID)" &_
"VALUES ("& Last_Identity &","& KundenNummer &", "& LSNummer1 &",'"& LSDate1 &"','"& Filiale1 &"','"& ArtikelNummer1 &"','"& Herstellernummer1 &"','"& Bezeichnung11 &"' ,'"& Bezeichnung21 &"','"& ATKZ1 &"',"& Menge1 &","& RuckgabeMenge1 &","& EKPreis1 &","& conn.ToSQL(CCGetUserID(), ccsInteger) & ")"
conn.Execute(SQL)
RecordSetPos.MoveNext
Wend
RecordSet.MoveNext
Wend
SQL = "delete FROM OffenPositionen where status= 'N'" &_
" And KundenNummer= "&KundenNummer
conn.Execute(SQL)
end if
end if
conn.Close
Set conn = Nothing
on Error Goto 0
End Function 'Close OffenPositionen_AfterSubmit @8-54C34B28
|
|
|
sunny_99
Posts: 20
|
Posted: 11/23/2004, 2:41 AM |
|
hi
i putt all the information what you need
can you just look into the code
regards
sri
|
|
|
dataobjx
Posts: 181
|
Posted: 11/23/2004, 4:56 AM |
|
OK, I've commented the code below. Add your comments if necessary.
To be honest, it took me a while to get used to reading it, but... we'll give it a go.
I have to assume that during the process where-in the user is selecting the articles, these selections are being recorded in table OffenPositionen
I'm assuming that table OffenPositionen holds the values that you said were;
for example
if he brought four items from 4 different places
then the output should be like this
returnID place
1 H1
2 H2
3 H3
4 H4
But I'm not certain this is correct.
So, I've commented the code a little, but I need you to tell me what isn't working.... since I cannot 'test' the code as such and can only read it.... it appears ok.
So, now that we have actual table names and so forth to work with - we can home in on this.
Maybe it would be better to explain it like this;
[
* when the user selects an article that is recorded in table x
* after the user selects all of the articles they want, they need to be able to view them.
* after viewing them, the user clicks a button to confirm their selection.
* when they click the confirmation button, I have code in the AfterSubmit() event which does this....
]
So, before we can continue, let's clarify everything using actual table names and so forth so that we're on the same page.
***************************************************************************
***************************************************************************
KundenNummer = Session("KundenNummer")
' response.write("<br>"&KundenNummer)
if (event1 <> 0) then
if Last_Identity= 0 then
'*************************************************************************
'DataObjx Comments Begin;
'Get the unique branch? numbers for this customer
'Select Distinct branch? from openpositions where status = 'N' and customernumber=session("customernumber")
'DataObjx Comments End;
'*************************************************************************
SQL = "SELECT DISTINCT Filiale FROM OffenPositionen where status= 'N' " &_
"And KundenNummer =" & KundenNummer
'response.write("<br>"&SQL)
set RecordSet = conn.Execute(SQL)
while not (RecordSet.EOF)
'response.write CCGetFromPost("ListBox1", Empty) & "<br>"
'*************************************************************************
'DataObjx Comments Begin;
'For each record/loop
'place the unique branch? numbers for this customer into var Filale1
'then insert a record into table Rueckgabe, include var Filale1 in the insert
'DataObjx Comments End;
'*************************************************************************
Filiale1 = CCGetValue(RecordSet,"Filiale")
SQL = "INSERT INTO Rueckgabe(KundenNummer,UserID,Datum,Filiale,Kdref,Versantart)" &_
"VALUES ("& KundenNummer &","& conn.ToSQL(CCGetUserID(), ccsInteger) & "," & conn.ToSQL(Now(), ccsDate) & ",'"& Filiale1 &"','"& (CCGetFromPost("TextBox1", Empty) ) &"','"& (CCGetFromPost("ListBox1", Empty) ) &"')"
'response.write("<br>"&SQL)
conn.Execute(SQL)
'*************************************************************************
'DataObjx Comments Begin;
'Get the @@IDENTITY of the inserted record (into table Rueckgabe)
'DataObjx Comments End;
'*************************************************************************
SQL = "SELECT IDENT_CURRENT('Rueckgabe') as intIdent "
Set rsNewID = conn.Execute(SQL)
If Not (rsNewID.EOF) then
Last_Identity = CInt(CCGetValue(rsNewID,"intIdent"))
else
response.write("<br> The @@IDENTITY Call did not Work!")
response.end()
End if
'*************************************************************************
'DataObjx Comments Begin;
'Perform another select against (table OffenPositionen) where the branch? and customernumber match
'DataObjx Comments End;
'*************************************************************************
SQL = " Select * from OffenPositionen where Filiale='" &Filiale1&"'" &_
" And KundenNummer = " &KundenNummer
Set RecordSetPos = conn.Execute(SQL)
while NOT RecordSetPos.EOF
RowIndex1 = CCGetValue(RecordSetPos, "RowIndex")
UserID1 = CCGetValue(RecordSetPos, "UserID")
KundenNummer1 = CCGetValue(RecordSetPos, "KundenNummer")
LSNummer1 = CCGetValue(RecordSetPos, "LSNummer")
LSDate1 = CCGetValue(RecordSetPos, "LSDate")
Status1 = CCGetValue(RecordSet, "Status")
ArtikelNummer1 = CCGetValue(RecordSetPos, "ArtikelNummer")
Herstellernummer1 = CCGetValue(RecordSetPos, "Herstellernummer")
Bezeichnung11 = CCGetValue(RecordSetPos, "Bezeichnung1")
Bezeichnung21 = CCGetValue(RecordSetPos, "Bezeichnung2")
ATKZ1 = CCGetValue(RecordSetPos, "ATKZ")
Filiale11 = CCGetValue(RecordSetPos, "Filiale")
Menge1 = CCGetValue(RecordSetPos, "Menge")
RuckgabeMenge1 = CCGetValue(RecordSetPos, "RuckgabeMenge")
EKPreis1 = CCGetValue(RecordSetPos, "EKPreis")
Einlagerungsgebuhr1 = CCGetValue(RecordSetPos, "Einlagerungsgebuhr")
Lagerort1 = CCGetValue(RecordSetPos, "Lagerort")
Datum1 = CCGetValue(RecordSetPos, "Datum")
'*************************************************************************
'DataObjx Comments Begin;
'Perform an Insert against (table RueckgabePositionen)
'Use var Filale1 in the sql statement
'DataObjx Comments End;
'*************************************************************************
SQL = "INSERT INTO RueckgabePositionen(ReturnID,KundenNummer,LSNummer,LSDate,Filiale,ArtikelNummer,Herstellernummer,Bezeichnung1,Bezeichnung2,ATKZ,Menge,RuckgabeMenge,EKPreis,UserID)" &_
"VALUES ("& Last_Identity &","& KundenNummer &", "& LSNummer1 &",'"& LSDate1 &"','"& Filiale1 &"','"& ArtikelNummer1 &"','"& Herstellernummer1 &"','"& Bezeichnung11 &"' ,'"& Bezeichnung21 &"','"& ATKZ1 &"',"& Menge1 &","& RuckgabeMenge1 &","& EKPreis1 &","& conn.ToSQL(CCGetUserID(), ccsInteger) & ")"
conn.Execute(SQL)
RecordSetPos.MoveNext
Wend
RecordSet.MoveNext
Wend
'*************************************************************************
'DataObjx Comments Begin;
'Finally, Delete all records used from table (OffenPositionen) - which kicked off this entire
'looping process.
'DataObjx Comments End;
'*************************************************************************
SQL = "delete FROM OffenPositionen where status= 'N'" &_
" And KundenNummer= "&KundenNummer
conn.Execute(SQL)
end if
end if
_________________
www.DataObjx.net
www.mydigitalapps.com |
|
|
sunny_99
Posts: 20
|
Posted: 11/23/2004, 5:29 AM |
|
hi
what u think is correct offenpositionen is the table which is used for viewing and editing
but i have another two tables where i insert the return data i mean return id and his place and so and on and in another table i keep all the records based on his user id
now again to start
i just want to know whether there is any way such that if user click the submit button( all the records are inserted)
then i want to prompt the user a message box would be better
where i can say that he has returned four articles back and give him the four return ids
is that possible
any how thanks very much for all your support
regards
srinivas
all togethere we have four table
|
|
|
|