kescott
Posts: 49
|
Posted: 09/11/2008, 7:52 AM |
|
I have a custom session variable that is created when a user logs in the application named "theLoggedInVendor" that checks which vendor is logged.
In the employees grid, it displays the following:
---------------------------------------|
TotalActive: (3)___________|
---------------------------------------|
Name__|Vendor__|Status__|
---------------------------------------|
Bob___|Comp1___|Active__|
Mar___|Comp1___|Active__|
Joe___|Comp2___|Active__|
---------------------------------------|
My Code is the following:
EmployeesTotalActive.Text = (new TextField("","Total Active: "+Settings
.vid_connectionDataAccessObject.ExecuteScalar("SELECT count(*) FROM Employees WHERE
status = 'Active'"))).GetFormattedValue("");
However, I want it to display the TotalActive (2) for Bob or Mary
----------------------------------------|
theLoggedInVendor:Comp1_|
TotalActive: (2)___________|
---------------------------------------|
Name__|Vendor__|Status__|
--------------------------------------|
Bob___|Comp1___|Active__|
Mar___|Comp1___|Active__|
--------------------------------------|
and if Joe is logged in he will see
---------------------------------------|
theLoggedInVendor:Comp1_|
TotalActive: (1)___________|
---------------------------------------|
Name__|Vendor__|Status__|
---------------------------------------|
Joe___|Comp2___|Active__|
---------------------------------------|
I tried to do it this way, but my code below now is displaying the count of everyone in the table, I need the count to be specific to user based off the theLoggedInVendor Session variable:
Can I call and compare my custom session varible in where clause like this?
EmployeesTotalActive.Text = (new TextField("","Total Active: "+Settings
.vid_connectionDataAccessObject.ExecuteScalar
("SELECT count(*) FROM Employees WHERE (vendor ='{theLoggedInVendor}' AND
status = 'Active'")))).GetFormattedValue("");
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
kescott
Posts: 49
|
Posted: 09/11/2008, 1:34 PM |
|
I think I'm getting closer now because I think it is reading the column value, but I get another error message now that explains I have an invalid column name.
Error message: Invalid column name 'Wipro'
My code:
//Label TotalActive Event BeforeShow. Action Custom Code
String LoggedInVendor;
if (System.Web.HttpContext.Current.Session["theLoggedInVendor"] !=null)
{
LoggedInVendor = System.Web.HttpContext.Current.Session["theLoggedInVendor"].ToString();
EmployeesTotalActive.Text = (new TextField("","Total Active: "+Settings
.vid_connectionDataAccessObject.ExecuteScalar
("SELECT count(*) FROM Employees WHERE status = 'Active'
AND vendor =" + LoggedInVendor))).GetFormattedValue("");
}
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
kescott
Posts: 49
|
Posted: 09/12/2008, 2:32 AM |
|
Okay, I think I have this figured out, now.
Basically, I assign a value to the variable called LoggedInVendor, like this
LoggedInVendor = System.Web.HttpContext.Current.Session["theLoggedInVendor"].ToString();
Then count all Employees that are 'Active' and relate to the current logged in vendor, called 'theLoggedInVendor'.
When I try it with the static look code below, it counts all Employees that are 'Active' and relate to the vendor ='theLoggedInVendor'
EmployeesTotalActive.Text = (new TextField(" ","Total Active: "+Settings
.vid_connectionDataAccessObject.ExecuteScalar
("SELECT count(*) FROM Employees WHERE
status = 'Active' AND vendor = ' " + LoggedInVendor + " ' ")))
.GetFormattedValue(" ");))).GetFormattedValue(" ");
_________________
B.S. of Computer Science
Class of 2005
Norfolk State University
Norfolk, VA
http://www.nsu.edu
|
|
|
|