By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,905 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,905 IT Pros & Developers. It's quick & easy.

Session variable trouble

P: n/a
Hi,

I am facing a trouble. I have some Session variables in my code and
somehow my session variables are getting mixed up with other users.

For example User A has access to 10 companies and User B has access to
5, now when both of us hits to the server at the same time then their
session variables gets mixedup means either User A and USer B will have
now 5 companies or both have 10 companies. Now again when User A hits
to the server he will have again his session variables setting.

I have initialsed my session variables in session_Onstart event.
Now and clue why it is happening.

Regards,
Amit Arora

Apr 13 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Hi, how are you simulating the two different users? Same/differenr machine?
Same/different browser?
Apr 13 '06 #2

P: n/a
diffrent machine and diffrent browser...

Apr 13 '06 #3

P: n/a
diffrent machine and same browser...

Apr 13 '06 #4

P: n/a
> Hi,

I am facing a trouble. I have some Session variables in my code and
somehow my session variables are getting mixed up with other users.

For example User A has access to 10 companies and User B has access to
5, now when both of us hits to the server at the same time then their
session variables gets mixedup means either User A and USer B will have
now 5 companies or both have 10 companies. Now again when User A hits
to the server he will have again his session variables setting.

I have initialsed my session variables in session_Onstart event.
Now and clue why it is happening.

Regards,
Amit Arora


By any chance using *static* members in those objects that you put in
session?

Hans Kesting
Apr 13 '06 #5

P: n/a
Nopes, infact earlier I was using static variables but later on I
changed it to Sessions.........

Apr 13 '06 #6

P: n/a
Have you checked that you don't store a static variable in your session
objet ? What matters is not really that you use session variables, but
rather what exactly you store in those session variables.

It should be fairly easy to repro the problem or not with just a small piece
of code so that you can make sure it works in the trivial case. From there
you'll make sure if this is a problem in your code (I would expect this) or
if you have really a big problem with sessions.
--
Patrice

<ar*********@gmail.com> a écrit dans le message de news:
11**********************@g10g2000cwb.googlegroups. com...
Nopes, infact earlier I was using static variables but later on I
changed it to Sessions.........

Apr 13 '06 #7

P: n/a
Patric Here goes my long code, if you could check it out, then I would
be more than obliged to you...................

namespace CMS
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using Properties;
//using UserContorls;

/// <summary>
/// Summary description for DisplayCompanyContacts.
/// </summary>
public class DisplayCompanyContacts : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.PlaceHolder plcompany;
LiteralControl litcontrol;
protected System.Web.UI.WebControls.CheckBox CheckBox1;
LiteralControl litcontrol2;
string roleid,userid;
protected System.Web.UI.WebControls.Button btn;
protected System.Web.UI.WebControls.LinkButton ClearLink;
protected System.Web.UI.HtmlControls.HtmlInputHidden CheckBoxFlag;
protected System.Web.UI.HtmlControls.HtmlInputHidden CompanyID;
protected System.Web.UI.WebControls.LinkButton SelectLink;

private void Page_Load(object sender, System.EventArgs e)
{
//DisplayConversationFromCalander();
if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="" ;
roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();
//if(!IsPostBack)
bindleftpanel();
///Removing these Common Properties and Placing Sessions Instead

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

/* if(CommonProperties.CompaniesCheckBoxIDsInLeftMenu .Length>0)
CommonProperties.CompaniesCheckBoxIDsInLeftMenu=
CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Su bstring
(0,CommonProperties.CompaniesCheckBoxIDsInLeftMenu .Length-1);

if(CommonProperties.ContactCheckBoxIDsInLeftMenu.L ength>0)
CommonProperties.ContactCheckBoxIDsInLeftMenu=
CommonProperties.ContactCheckBoxIDsInLeftMenu.Subs tring
(0,CommonProperties.ContactCheckBoxIDsInLeftMenu.L ength-1); */

/* if (Request.Url!=null)
{
string _pageurl=Request.Url.ToString();
char[] splitter = {'/'};
string[] arInfo = _pageurl.Split(splitter);
for(int x = 0; x < arInfo.Length; x++)
{
_pageurl=arInfo[x];
}

if (_pageurl=="ViewContact.aspx")
{
UserContorls.ViewContact viewcontact=new
CMS.UserContorls.ViewContact();
viewcontact.BindViewDetails();
}
} */
}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
//string sql;
/*if (roleid=="1" || roleid=="2")
{
if (CommonProperties.FilterCompanyId==null)
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+roleid+" Union Select Company_id from Company where
COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') and
company_id='"+CommonProperties.FilterCompanyId.ToS tring()+"' order by
company_name";
}
}
else
{
sql="select * from company order by company_name";
}*/
//objcomm=new SqlCommand(sql,strcon);

//kapil kalra 20-mar-2006 permission check
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/
try
{
objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
}
catch
{}
objread=objcomm.ExecuteReader();
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="" ;
//Session["CompaniesCheckBoxIDsInLeftMenu"]="";
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();
//Response.Write(objread["company_id"]);
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(th is);");
chkbox.EnableViewState=true;
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu+=c hkbox.ID+",";
Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString()!="" )
{
//string info_company =
CommonProperties.SelectedCompany;
string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();
//string sql2;

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );
/* objcomm2.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm2.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm2.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm2.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);*/

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//Session["ContactCheckBoxIDsInLeftMenu"]="";
if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();
//CommonProperties.ContactCheckBoxIDsInLeftMenu+=chk box.ID+",";
Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;
//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
//string info_company =
CommonProperties.SelectedContact;
string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();

if(roleid=="4" ||roleid=="5"||roleid=="6"||roleid=="7" )
{
int flag=ColorSeg(company_id,objread2["contact_id"].ToString());

if(flag==0)//not alloted
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==1)//alloted to RA
{
litcontrol2.Text="<span
class=FilterListContactRA>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==2)// alloted to SR
{
litcontrol2.Text="<span
class=FilterListContactSR>"+objread2["contact_name"].ToString()+"</span><br>";
}
else// alloted to both
{
litcontrol2.Text="<span
class=FilterListContactBoth>"+objread2["contact_name"].ToString()+"</span><br>";
}

}
else
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}

plcompany.Controls.Add(litcontrol2 );
}
}
objcomm2.Cancel();
objread2.Close();
strcon2.Close();
}
}

private int ColorSeg(string company_id,string contactid)
{
int flag=0;
string kk;
string sql="SELECT userroleid FROM
dbo.CONTACTSALLOCATION where CONTACT_ID="+contactid+" and userroleid
in(1,2)";
SqlConnection conn=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]);
SqlCommand cmd=new SqlCommand();
cmd.Parameters.Clear();
cmd.CommandText="dbo.[Usp_LeftPanelColor]";
cmd.CommandType=CommandType.StoredProcedure;
cmd.Connection=conn;
cmd.Parameters.Add("@contactid",Convert.ToInt32(co ntactid));

DataSet ds=new DataSet();
SqlDataAdapter adpter=new SqlDataAdapter(cmd);

adpter.Fill(ds);

if(ds.Tables[0].Rows.Count>0)
{
kk= ds.Tables[0].Rows[0]["userroleid"].ToString();
flag=Convert.ToInt32(kk);
if(ds.Tables[0].Rows.Count>1)
{
flag=3;
}
}
return flag;

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SelectLink.Click += new
System.EventHandler(this.SelectLink_Click);
this.ClearLink.Click += new
System.EventHandler(this.ClearLink_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void ASSIGN_CHECKED(object sender, System.EventArgs e)
{
//CommonProperties.SelectedCompany=null;
Session["SelectedCompany"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if (roleid=="1" || roleid=="2")
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company order by company_name";
}

objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/*objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);

objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcompany"+objre ad["company_id"].ToString());

string _unchkdcompanyid=check.ID;
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString().Trim()!="" )
{

//CommonProperties.SelectedCompany=CommonProperties. SelectedCompany+","+_chkdcompanyid;
Session["SelectedCompany"]=Session["SelectedCompany"]+","+_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
else
{
//CommonProperties.SelectedCompany=_chkdcompanyid;
Session["SelectedCompany"]=_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
}
else
{
// UnChkContatct(_unchkdcompanyid);
}
}
}
if(Session["SelectedCompany"].ToString().StartsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(1,Session["SelectedCompany"].ToString().Length);
}
if(Session["SelectedCompany"].ToString().EndsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(0,Session["SelectedCompany"].ToString().Length-1);
}
if(Session["SelectedContact"].ToString().StartsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(1,Session["SelectedContact"].ToString().Length);
}
if(Session["SelectedContact"].ToString().EndsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(0,Session["SelectedContact"].ToString().Length-1);
}
objcomm.Cancel();
objread.Close();
}
string FlagStatus=CheckBoxFlag.Value.ToString();

string strCompanyID=CompanyID.Value.ToString();
strCompanyID=strCompanyID.Substring(strCompanyID.L astIndexOf("_")+1);
if(!Convert.ToBoolean(FlagStatus))
UnChkContatct(strCompanyID);
}

public void ChkContact(string chkedCmpy)
{

chkedCmpy=chkedCmpy.Replace("chkcompany","");
SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();
// SqlCommand cmdcontact=new SqlCommand("Select CONTACT_ID from
Contacts where CONTACT_COMPANY_ID='"+chkedCmpy+"'", conn);
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);

cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();

if(rdr.HasRows)
{
while(rdr.Read())
{

CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());
check.Checked=true;
string _chkdcontactid=check.ID;
//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
int flag=AldyInsertCont(_chkdcontactid);
if(flag==0)
//CommonProperties.SelectedContact=CommonProperties. SelectedContact+","+_chkdcontactid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcontactid;
}
else
{
//CommonProperties.SelectedContact=_chkdcontactid;
Session["SelectedContact"]=_chkdcontactid;
}
}
}

}

private int AldyInsertCont(string contid)
{
int flag=0;
string[] Cont=Session["SelectedContact"].ToString().Split(new char[]
{','});
for(int i=0;i<Cont.Length;i++)
{
if(contid==Cont[i].ToString())
{
flag=1;
break;
}

}
return flag;
}

public void UnChkContatct(string chkedCmpy)
{

string chkedCmpy1=chkedCmpy;
chkedCmpy=chkedCmpy.Replace("chkcompany","");
SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Clear();
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/
cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);
cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();
// string[] ChkContacts=CommonProperties.SelectedContact.Split (new
char[] {','});
// CommonProperties.SelectedContact=null;
if(rdr.HasRows)
{
while(rdr.Read())
{
CheckBox check1 = (CheckBox)plcompany.FindControl(chkedCmpy1);
CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());
//if(CommonProperties.SelectedContact!=null)
if(Session["SelectedContact"].ToString()!="")
{
/* if(CommonProperties.SelectedContact.IndexOf(check. ID.ToString()+",")>-1)
CommonProperties.SelectedContact=CommonProperties. SelectedContact.Replace(check.ID.ToString()+",","" );
else
if(CommonProperties.SelectedContact.IndexOf(check. ID.ToString())>-1)
CommonProperties.SelectedContact=CommonProperties. SelectedContact.Replace(check.ID.ToString(),"");*/
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString()+",")>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString()+",","");
else
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString())>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString(),"");
}
// CommonProperties.SelectedContact=null;
check.Checked=false;
}
}

}


public void Contact_Checked(object sender, System.EventArgs e)
{
// CommonProperties.SelectedContact=null;
Session["SelectedContact"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if ( roleid=="2")
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+")
order by contact_name";
}
else if(roleid=="1" )
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+"
Union Select CONTACT_ID from Contacts where contact_company_id in
(select COMPANY_ID from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"'))) order by contact_name";
}
else
{
sql="select * from contacts order by contact_name";
}

//Response.Write (sql);
//Response.End();
objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Contact_Checked",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );

objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );
objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);


objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+objre ad["contact_id"].ToString());
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
// if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
// CommonProperties.SelectedContact=CommonProperties. SelectedContact+","+_chkdcompanyid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcompanyid;
}
else
{
//CommonProperties.SelectedContact=_chkdcompanyid;
Session["SelectedContact"]=_chkdcompanyid;
}
}

}
}
objcomm.Cancel();
objread.Close();
}
}

private void SelectLink_Click(object sender, System.EventArgs e)
{
CheckAllCompaniesContact();
}
private void CheckAllCompaniesContact()
{
try
{
// string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheck BoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"];
}
catch{}
try
{
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBo xIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
// CommonProperties.SelectedCompany=CommonProperties. CompaniesCheckBoxIDsInLeftMenu;
// CommonProperties.SelectedContact=CommonProperties. ContactCheckBoxIDsInLeftMenu;

Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"];
}
catch{}
}

private void ClearLink_Click(object sender, System.EventArgs e)
{
ClearAllCompaniesContact();
}
private void ClearAllCompaniesContact()
{
try
{
//string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheck BoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBo xIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}

//CommonProperties.SelectedCompany=CommonProperties. CompaniesCheckBoxIDsInLeftMenu="";

//CommonProperties.SelectedContact=CommonProperties. ContactCheckBoxIDsInLeftMenu="";
Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"]="";
}
catch{}
}


}
}

Apr 13 '06 #8

P: n/a
Ummm, no one is going to read this. Can you please attach the code that
is causing the problem?
ar*********@gmail.com wrote:
Patric Here goes my long code, if you could check it out, then I would
be more than obliged to you...................

namespace CMS
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using Properties;
//using UserContorls;

/// <summary>
/// Summary description for DisplayCompanyContacts.
/// </summary>
public class DisplayCompanyContacts : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.PlaceHolder plcompany;
LiteralControl litcontrol;
protected System.Web.UI.WebControls.CheckBox CheckBox1;
LiteralControl litcontrol2;
string roleid,userid;
protected System.Web.UI.WebControls.Button btn;
protected System.Web.UI.WebControls.LinkButton ClearLink;
protected System.Web.UI.HtmlControls.HtmlInputHidden CheckBoxFlag;
protected System.Web.UI.HtmlControls.HtmlInputHidden CompanyID;
protected System.Web.UI.WebControls.LinkButton SelectLink;

private void Page_Load(object sender, System.EventArgs e)
{
//DisplayConversationFromCalander();
if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="" ;
roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();
//if(!IsPostBack)
bindleftpanel();
///Removing these Common Properties and Placing Sessions Instead

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

/* if(CommonProperties.CompaniesCheckBoxIDsInLeftMenu .Length>0)
CommonProperties.CompaniesCheckBoxIDsInLeftMenu=
CommonProperties.CompaniesCheckBoxIDsInLeftMenu.Su bstring
(0,CommonProperties.CompaniesCheckBoxIDsInLeftMenu .Length-1);

if(CommonProperties.ContactCheckBoxIDsInLeftMenu.L ength>0)
CommonProperties.ContactCheckBoxIDsInLeftMenu=
CommonProperties.ContactCheckBoxIDsInLeftMenu.Subs tring
(0,CommonProperties.ContactCheckBoxIDsInLeftMenu.L ength-1); */

/* if (Request.Url!=null)
{
string _pageurl=Request.Url.ToString();
char[] splitter = {'/'};
string[] arInfo = _pageurl.Split(splitter);
for(int x = 0; x < arInfo.Length; x++)
{
_pageurl=arInfo[x];
}

if (_pageurl=="ViewContact.aspx")
{
UserContorls.ViewContact viewcontact=new
CMS.UserContorls.ViewContact();
viewcontact.BindViewDetails();
}
} */
}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
//string sql;
/*if (roleid=="1" || roleid=="2")
{
if (CommonProperties.FilterCompanyId==null)
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+roleid+" Union Select Company_id from Company where
COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') and
company_id='"+CommonProperties.FilterCompanyId.ToS tring()+"' order by
company_name";
}
}
else
{
sql="select * from company order by company_name";
}*/
//objcomm=new SqlCommand(sql,strcon);

//kapil kalra 20-mar-2006 permission check
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/
try
{
objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
}
catch
{}
objread=objcomm.ExecuteReader();
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu="" ;
//Session["CompaniesCheckBoxIDsInLeftMenu"]="";
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();
//Response.Write(objread["company_id"]);
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(th is);");
chkbox.EnableViewState=true;
//CommonProperties.CompaniesCheckBoxIDsInLeftMenu+=c hkbox.ID+",";
Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString()!="" )
{
//string info_company =
CommonProperties.SelectedCompany;
string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();
//string sql2;

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );
/* objcomm2.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm2.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm2.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm2.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);*/

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();
//CommonProperties.ContactCheckBoxIDsInLeftMenu="";
//Session["ContactCheckBoxIDsInLeftMenu"]="";
if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();
//CommonProperties.ContactCheckBoxIDsInLeftMenu+=chk box.ID+",";
Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;
//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
//string info_company =
CommonProperties.SelectedContact;
string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();

if(roleid=="4" ||roleid=="5"||roleid=="6"||roleid=="7" )
{
int flag=ColorSeg(company_id,objread2["contact_id"].ToString());

if(flag==0)//not alloted
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==1)//alloted to RA
{
litcontrol2.Text="<span
class=FilterListContactRA>"+objread2["contact_name"].ToString()+"</span><br>";
}
else if(flag==2)// alloted to SR
{
litcontrol2.Text="<span
class=FilterListContactSR>"+objread2["contact_name"].ToString()+"</span><br>";
}
else// alloted to both
{
litcontrol2.Text="<span
class=FilterListContactBoth>"+objread2["contact_name"].ToString()+"</span><br>";
}

}
else
{
litcontrol2.Text="<span
class=FilterListContact>"+objread2["contact_name"].ToString()+"</span><br>";
}

plcompany.Controls.Add(litcontrol2 );
}
}
objcomm2.Cancel();
objread2.Close();
strcon2.Close();
}
}

private int ColorSeg(string company_id,string contactid)
{
int flag=0;
string kk;
string sql="SELECT userroleid FROM
dbo.CONTACTSALLOCATION where CONTACT_ID="+contactid+" and userroleid
in(1,2)";
SqlConnection conn=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]);
SqlCommand cmd=new SqlCommand();
cmd.Parameters.Clear();
cmd.CommandText="dbo.[Usp_LeftPanelColor]";
cmd.CommandType=CommandType.StoredProcedure;
cmd.Connection=conn;
cmd.Parameters.Add("@contactid",Convert.ToInt32(co ntactid));

DataSet ds=new DataSet();
SqlDataAdapter adpter=new SqlDataAdapter(cmd);

adpter.Fill(ds);

if(ds.Tables[0].Rows.Count>0)
{
kk= ds.Tables[0].Rows[0]["userroleid"].ToString();
flag=Convert.ToInt32(kk);
if(ds.Tables[0].Rows.Count>1)
{
flag=3;
}
}
return flag;

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.SelectLink.Click += new
System.EventHandler(this.SelectLink_Click);
this.ClearLink.Click += new
System.EventHandler(this.ClearLink_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

public void ASSIGN_CHECKED(object sender, System.EventArgs e)
{
//CommonProperties.SelectedCompany=null;
Session["SelectedCompany"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if (roleid=="1" || roleid=="2")
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"') order by company_name";
}
else
{
sql="select * from company order by company_name";
}

objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
/*objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);

objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcompany"+objre ad["company_id"].ToString());

string _unchkdcompanyid=check.ID;
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
//if (CommonProperties.SelectedCompany!=null)
if (Session["SelectedCompany"].ToString().Trim()!="" )
{

//CommonProperties.SelectedCompany=CommonProperties. SelectedCompany+","+_chkdcompanyid;
Session["SelectedCompany"]=Session["SelectedCompany"]+","+_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
else
{
//CommonProperties.SelectedCompany=_chkdcompanyid;
Session["SelectedCompany"]=_chkdcompanyid;
ChkContact(_chkdcompanyid);
}
}
else
{
// UnChkContatct(_unchkdcompanyid);
}
}
}
if(Session["SelectedCompany"].ToString().StartsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(1,Session["SelectedCompany"].ToString().Length);
}
if(Session["SelectedCompany"].ToString().EndsWith(","))
{
Session["SelectedCompany"]=Session["SelectedCompany"].ToString().Substring(0,Session["SelectedCompany"].ToString().Length-1);
}
if(Session["SelectedContact"].ToString().StartsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(1,Session["SelectedContact"].ToString().Length);
}
if(Session["SelectedContact"].ToString().EndsWith(","))
{
Session["SelectedContact"]=Session["SelectedContact"].ToString().Substring(0,Session["SelectedContact"].ToString().Length-1);
}
objcomm.Cancel();
objread.Close();
}
string FlagStatus=CheckBoxFlag.Value.ToString();

string strCompanyID=CompanyID.Value.ToString();
strCompanyID=strCompanyID.Substring(strCompanyID.L astIndexOf("_")+1);
if(!Convert.ToBoolean(FlagStatus))
UnChkContatct(strCompanyID);
}

public void ChkContact(string chkedCmpy)
{

chkedCmpy=chkedCmpy.Replace("chkcompany","");
SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();
// SqlCommand cmdcontact=new SqlCommand("Select CONTACT_ID from
Contacts where CONTACT_COMPANY_ID='"+chkedCmpy+"'", conn);
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);

cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();

if(rdr.HasRows)
{
while(rdr.Read())
{

CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());
check.Checked=true;
string _chkdcontactid=check.ID;
//if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
int flag=AldyInsertCont(_chkdcontactid);
if(flag==0)
//CommonProperties.SelectedContact=CommonProperties. SelectedContact+","+_chkdcontactid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcontactid;
}
else
{
//CommonProperties.SelectedContact=_chkdcontactid;
Session["SelectedContact"]=_chkdcontactid;
}
}
}

}

private int AldyInsertCont(string contid)
{
int flag=0;
string[] Cont=Session["SelectedContact"].ToString().Split(new char[]
{','});
for(int i=0;i<Cont.Length;i++)
{
if(contid==Cont[i].ToString())
{
flag=1;
break;
}

}
return flag;
}

public void UnChkContatct(string chkedCmpy)
{

string chkedCmpy1=chkedCmpy;
chkedCmpy=chkedCmpy.Replace("chkcompany","");
SqlConnection conn=new
SqlConnection(ConfigurationSettings.AppSettings["CMSConnection"]);
conn.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
SqlCommand cmdcontact=new SqlCommand("AutoChkContacts",conn);
cmdcontact.CommandType = CommandType.StoredProcedure;
cmdcontact.Parameters.Clear();
cmdcontact.Parameters.Add( "@SESSION_ROLEID", roleid );
cmdcontact.Parameters.Add( "@SESSION_USERID", userid );
cmdcontact.Parameters.Add( "@permission", permission );
/*cmdcontact.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
cmdcontact.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/
cmdcontact.Parameters.Add(
"@FILTER_ROLEID",Session["Filterroleid"]);
cmdcontact.Parameters.Add(
"@FILTER_USERID",Session["Filteruserid"]);
cmdcontact.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
cmdcontact.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
cmdcontact.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
cmdcontact.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
cmdcontact.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
cmdcontact.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
cmdcontact.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
cmdcontact.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"]);
cmdcontact.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"]);
cmdcontact.Parameters.Add( "@FILTER_CONTACTCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact.ExecuteReader();
// string[] ChkContacts=CommonProperties.SelectedContact.Split (new
char[] {','});
// CommonProperties.SelectedContact=null;
if(rdr.HasRows)
{
while(rdr.Read())
{
CheckBox check1 = (CheckBox)plcompany.FindControl(chkedCmpy1);
CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+rdr["CONTACT_ID"].ToString());
//if(CommonProperties.SelectedContact!=null)
if(Session["SelectedContact"].ToString()!="")
{
/* if(CommonProperties.SelectedContact.IndexOf(check. ID.ToString()+",")>-1)
CommonProperties.SelectedContact=CommonProperties. SelectedContact.Replace(check.ID.ToString()+",","" );
else
if(CommonProperties.SelectedContact.IndexOf(check. ID.ToString())>-1)
CommonProperties.SelectedContact=CommonProperties. SelectedContact.Replace(check.ID.ToString(),"");*/
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString()+",")>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString()+",","");
else
if(Session["SelectedContact"].ToString().IndexOf(check.ID.ToString())>-1)
Session["SelectedContact"]=Session["SelectedContact"].ToString().Replace(check.ID.ToString(),"");
}
// CommonProperties.SelectedContact=null;
check.Checked=false;
}
}

}


public void Contact_Checked(object sender, System.EventArgs e)
{
// CommonProperties.SelectedContact=null;
Session["SelectedContact"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
/*string sql;
if ( roleid=="2")
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+")
order by contact_name";
}
else if(roleid=="1" )
{
sql="select * from contacts where CONTACT_ID IN (Select CONTACT_ID
from Contacts where CONTACT_UPDATE_BY_ID='"+userid+"' UNION Select
CONTACT_ID from CONTACTSALLOCATION where
CONTACTSALLOCATEDTO='"+userid+"' and USERROLEID="+Session["Roleid"]+"
Union Select CONTACT_ID from Contacts where contact_company_id in
(select COMPANY_ID from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATION where COMPANYALLOCATEDTO='"+userid+"' and
USERROLEID="+Session["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY='"+userid+"'))) order by contact_name";
}
else
{
sql="select * from contacts order by contact_name";
}

//Response.Write (sql);
//Response.End();
objcomm=new SqlCommand(sql,strcon);*/
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp_LeftMenu_Contact_Checked",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );

objcomm.Parameters.Add( "@permission", permission );
/* objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );
objcomm.Parameters.Add(
"@FILTER_ROLEID",CommonProperties.Filterroleid );
objcomm.Parameters.Add(
"@FILTER_USERID",CommonProperties.Filteruserid );
objcomm.Parameters.Add(
"@FILTER_COMPANYID",CommonProperties.FilterCompany Id);
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",CommonProperties.Filter IV);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",CommonProperties.FilterDoma in);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",CommonProperties.FilterSour ce);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",CommonProperties.FilterWorkTy pe);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",CommonProperties.FilterDis position);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",CommonProperties.FilterDesig nation);
objcomm.Parameters.Add(
"@FILTER_EMAILID",CommonProperties.Filteremail );
objcomm.Parameters.Add(
"@FILTER_PHONENO",CommonProperties.Filterphone );*/

objcomm.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);


objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox check =
(CheckBox)plcompany.FindControl("chkcontact"+objre ad["contact_id"].ToString());
if (check.Checked==true)
{
string _chkdcompanyid=check.ID;
// if (CommonProperties.SelectedContact!=null)
if (Session["SelectedContact"].ToString()!="")
{
// CommonProperties.SelectedContact=CommonProperties. SelectedContact+","+_chkdcompanyid;
Session["SelectedContact"]=Session["SelectedContact"]+","+_chkdcompanyid;
}
else
{
//CommonProperties.SelectedContact=_chkdcompanyid;
Session["SelectedContact"]=_chkdcompanyid;
}
}

}
}
objcomm.Cancel();
objread.Close();
}
}

private void SelectLink_Click(object sender, System.EventArgs e)
{
CheckAllCompaniesContact();
}
private void CheckAllCompaniesContact()
{
try
{
// string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheck BoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"];
}
catch{}
try
{
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBo xIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=true;

}
// CommonProperties.SelectedCompany=CommonProperties. CompaniesCheckBoxIDsInLeftMenu;
// CommonProperties.SelectedContact=CommonProperties. ContactCheckBoxIDsInLeftMenu;

Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"];
}
catch{}
}

private void ClearLink_Click(object sender, System.EventArgs e)
{
ClearAllCompaniesContact();
}
private void ClearAllCompaniesContact()
{
try
{
//string []
CompanyCheckBoxIds=CommonProperties.CompaniesCheck BoxIDsInLeftMenu.Split(new
char[] {','});
string []
CompanyCheckBoxIds=Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in CompanyCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}
Session["SelectedCompany"]=Session["CompaniesCheckBoxIDsInLeftMenu"]="";
//string []
ContactCheckBoxIds=CommonProperties.ContactCheckBo xIDsInLeftMenu.Split(new
char[] {','});
string []
ContactCheckBoxIds=Session["ContactCheckBoxIDsInLeftMenu"].ToString().Split(new
char[] {','});
foreach (string temp in ContactCheckBoxIds)
{
CheckBox check = (CheckBox)plcompany.FindControl(temp);
check.Checked=false;

}

//CommonProperties.SelectedCompany=CommonProperties. CompaniesCheckBoxIDsInLeftMenu="";

//CommonProperties.SelectedContact=CommonProperties. ContactCheckBoxIDsInLeftMenu="";
Session["SelectedContact"]=Session["ContactCheckBoxIDsInLeftMenu"]="";
}
catch{}
}


}
}

Apr 13 '06 #9

P: n/a
Well, the problem is this code only...............

If you could solve it then please seee...

Apr 13 '06 #10

P: n/a
No. Reduce the code to show the problem. Create a test.aspx page that
minimully demonstrates the problem

Jeff

<ar*********@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
Well, the problem is this code only...............

If you could solve it then please seee...

Apr 13 '06 #11

P: n/a
Here is the Minimal code, Here I have included 3 methods, as Page_Load,
BindLeftPanel (Which actaully Binds the Companies Check Boxes),
SubContact (Which is called for each company with companyID) and
fetches out concerned Contacts with companyID paased as parameter.
Apart from this we have Assign_Checked event method which is called
when we click on a check box.

Please see if any thing is possible..........
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";
roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();
bindleftpanel();

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
try
{
objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
}
catch
{}
objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(th is);");
chkbox.EnableViewState=true;
Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
if (Session["SelectedCompany"].ToString()!="" )
{
string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();
if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();
Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;
if (Session["SelectedContact"].ToString()!="")
{
string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();
plcompany.Controls.Add(litcontrol2 );
}
}
objcomm2.Cancel();
objread2.Close();
strcon2.Close();
}
}

Apr 13 '06 #12

P: n/a
Way too much code again! Remove all sql code, and get it down to a dozen
lines or so of code! Just hard code the equivalent database values

Jeff

<ar*********@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Here is the Minimal code, Here I have included 3 methods, as Page_Load,
BindLeftPanel (Which actaully Binds the Companies Check Boxes),
SubContact (Which is called for each company with companyID) and
fetches out concerned Contacts with companyID paased as parameter.
Apart from this we have Assign_Checked event method which is called
when we click on a check box.

Please see if any thing is possible..........
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["Userid"].ToString()=="")
{
Session.Abandon();
Response.Redirect("Login.aspx");
}

Session["ContactCheckBoxIDsInLeftMenu"]="";
Session["CompaniesCheckBoxIDsInLeftMenu"]="";
roleid=Session["Roleid"].ToString().Trim();
userid=Session["Userid"].ToString().Trim();
bindleftpanel();

if(Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["CompaniesCheckBoxIDsInLeftMenu"]=
Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["CompaniesCheckBoxIDsInLeftMenu"].ToString().Length-1);

if(Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length>0)
Session["ContactCheckBoxIDsInLeftMenu"]=
Session["ContactCheckBoxIDsInLeftMenu"].ToString().Substring
(0,Session["ContactCheckBoxIDsInLeftMenu"].ToString().Length-1);

}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp_LeftMenu_Company",strcon);
objcomm.CommandType = CommandType.StoredProcedure;
objcomm.Parameters.Clear();
objcomm.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm.Parameters.Add( "@SESSION_USERID", userid );
objcomm.Parameters.Add( "@permission", permission );
try
{
objcomm.Parameters.Add(
"@FILTER_ROLEID",Convert.ToInt32(Session["Filterroleid"]));
objcomm.Parameters.Add(
"@FILTER_USERID",Convert.ToInt32(Session["Filteruserid"]));
objcomm.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"].ToString());
objcomm.Parameters.Add(
"@FILTER_INVERTICALID",Convert.ToInt32(Session["FilterIV"]));
objcomm.Parameters.Add(
"@FILTER_DOMAINID",Convert.ToInt32(Session["FilterDomain"]));
objcomm.Parameters.Add(
"@FILTER_SOURCEID",Convert.ToInt32(Session["FilterSource"]));
objcomm.Parameters.Add(
"@FILTER_WORKTYPEID",Convert.ToInt32(Session["FilterWorkType"]));
objcomm.Parameters.Add(
"@FILTER_DISPOSITIONID",Convert.ToInt32(Sessio n["FilterDisposition"]));
objcomm.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"].ToString());
objcomm.Parameters.Add(
"@FILTER_EMAILID",Session["Filteremail"].ToString());
objcomm.Parameters.Add(
"@FILTER_PHONENO",Session["Filterphone"].ToString());
}
catch
{}
objread=objcomm.ExecuteReader();
if (objread.HasRows)
{
while (objread.Read())
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkcompany"+objread["company_id"].ToString();
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;

chkbox.Attributes.Add("onClick","javascript:Foo(th is);");
chkbox.EnableViewState=true;
Session["CompaniesCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
if (Session["SelectedCompany"].ToString()!="" )
{
string info_company =
Session["SelectedCompany"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.ASSIGN_CHECKED);
plcompany.Controls.Add(chkbox);
litcontrol=new LiteralControl();
litcontrol.Text="<span
class=FilterListCompany>"+objread["company_name"].ToString()+"</span><br>";
plcompany.Controls.Add(litcontrol );

subcontact(objread["company_id"].ToString());
}
}

objcomm.Cancel();
objread.Close();
}

}

public void subcontact(string company_id)
{
using(SqlConnection strcon2=new SqlConnection
(ConfigurationSettings.AppSettings["CMSConnection"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();

int permission=0;
if((CommonRules.CommonLogic.isValidServiceItem(Con vert.ToInt32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp_LeftMenu_Contact",strcon2);
objcomm2.CommandType = CommandType.StoredProcedure;
objcomm2.Parameters.Clear();
objcomm2.Parameters.Add( "@SESSION_ROLEID", roleid );
objcomm2.Parameters.Add( "@SESSION_USERID", userid );
objcomm2.Parameters.Add( "@permission", permission );

objcomm2.Parameters.Add( "@FILTER_ROLEID",Session["Filterroleid"]);
objcomm2.Parameters.Add( "@FILTER_USERID",Session["Filteruserid"]);
objcomm2.Parameters.Add(
"@FILTER_COMPANYID",Session["FilterCompanyId"]);
objcomm2.Parameters.Add(
"@FILTER_INVERTICALID",Session["FilterIV"]);
objcomm2.Parameters.Add(
"@FILTER_DOMAINID",Session["FilterDomain"]);
objcomm2.Parameters.Add(
"@FILTER_SOURCEID",Session["FilterSource"]);
objcomm2.Parameters.Add(
"@FILTER_WORKTYPEID",Session["FilterWorkType"]);
objcomm2.Parameters.Add(
"@FILTER_DISPOSITIONID",Session["FilterDisposition"]);
objcomm2.Parameters.Add(
"@FILTER_DESIGNATION",Session["FilterDesignation"]);
objcomm2.Parameters.Add( "@FILTER_EMAILID",Session["Filteremail"]);
objcomm2.Parameters.Add( "@FILTER_PHONENO",Session["Filterphone"]);
objcomm2.Parameters.Add( "@FILTER_CONTACTCOMPANYID",company_id);

objread2=objcomm2.ExecuteReader();
if (objread2.HasRows)
{
while(objread2.Read())
{
litcontrol2=new LiteralControl();
litcontrol2.Text="&nbsp;&nbsp;&nbsp;";
plcompany.Controls.Add(litcontrol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkcontact"+objread2["contact_id"].ToString();
Session["ContactCheckBoxIDsInLeftMenu"]+=chkbox.ID+",";
chkbox.AutoPostBack=true;
chkbox.EnableViewState=true;
if (Session["SelectedContact"].ToString()!="")
{
string info_company =
Session["SelectedContact"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Split(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arInfo[x])
{
chkbox.Checked=true;
}
}
}
chkbox.CheckedChanged+=new
System.EventHandler(this.Contact_Checked);
plcompany.Controls.Add(chkbox);
litcontrol2=new LiteralControl();
plcompany.Controls.Add(litcontrol2 );
}
}
objcomm2.Cancel();
objread2.Close();
strcon2.Close();
}
}

Apr 13 '06 #13

P: n/a
At a wild guess, a bug in your stored procedure Usp_LeftMenu_Contact,
perhaps it isn't actually querying the user id? You should explicitly
execute it with different values and observe the results.

You might put some handling in your catch block too, although I'd
expect the subsequent call to ExecuteReader to fail if the parameters
aren't initialized.

Apr 14 '06 #14

P: n/a
Also dump userid and sessionid so that you can at least cut down the mixed
up session theory.
If you have the same userid but distinct sessionIDs this is that the userid
initialization code is likely bad.
Also SQL Server profiler may help (you'll see if both statement are fed with
the same parameters for both users, you can try them from QA then).

My failed attempt was to convey the idea that to find out the problem you
have to try and test hypothesis on possibly simplified code instead of
trying to address the problme in the whole original context where likely
much of the code has nothing to do with the carrefully hidden problem.

--
Patrice

"Russell" <ru*****@goisc.com> a écrit dans le message de news:
11*********************@u72g2000cwu.googlegroups.c om...
At a wild guess, a bug in your stored procedure Usp_LeftMenu_Contact,
perhaps it isn't actually querying the user id? You should explicitly
execute it with different values and observe the results.

You might put some handling in your catch block too, although I'd
expect the subsequent call to ExecuteReader to fail if the parameters
aren't initialized.

Apr 14 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.