473,605 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session variable trouble

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
14 2360
Hi, how are you simulating the two different users? Same/differenr machine?
Same/different browser?
Apr 13 '06 #2
diffrent machine and diffrent browser...

Apr 13 '06 #3
diffrent machine and same browser...

Apr 13 '06 #4
> 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
Nopes, infact earlier I was using static variables but later on I
changed it to Sessions....... ..

Apr 13 '06 #6
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*********@gm ail.com> a écrit dans le message de news:
11************* *********@g10g2 00...legr oups.com...
Nopes, infact earlier I was using static variables but later on I
changed it to Sessions....... ..

Apr 13 '06 #7
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.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
using System.Configur ation;
using Properties;
//using UserContorls;

/// <summary>
/// Summary description for DisplayCompanyC ontacts.
/// </summary>
public class DisplayCompanyC ontacts : System.Web.UI.U serControl
{
protected System.Web.UI.W ebControls.Plac eHolder plcompany;
LiteralControl litcontrol;
protected System.Web.UI.W ebControls.Chec kBox CheckBox1;
LiteralControl litcontrol2;
string roleid,userid;
protected System.Web.UI.W ebControls.Butt on btn;
protected System.Web.UI.W ebControls.Link Button ClearLink;
protected System.Web.UI.H tmlControls.Htm lInputHidden CheckBoxFlag;
protected System.Web.UI.H tmlControls.Htm lInputHidden CompanyID;
protected System.Web.UI.W ebControls.Link Button SelectLink;

private void Page_Load(objec t sender, System.EventArg s e)
{
//DisplayConversa tionFromCalande r();
if (Session["Userid"].ToString()=="" )
{
Session.Abandon ();
Response.Redire ct("Login.aspx" );
}

Session["ContactCheckBo xIDsInLeftMenu"]="";
Session["CompaniesCheck BoxIDsInLeftMen u"]="";
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu ="";
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu="";
roleid=Session["Roleid"].ToString().Tri m();
userid=Session["Userid"].ToString().Tri m();
//if(!IsPostBack)
bindleftpanel() ;
///Removing these Common Properties and Placing Sessions Instead

if(Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Len gth>0)
Session["CompaniesCheck BoxIDsInLeftMen u"]=
Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Sub string
(0,Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Len gth-1);

if(Session["ContactCheckBo xIDsInLeftMenu"].ToString().Len gth>0)
Session["ContactCheckBo xIDsInLeftMenu"]=
Session["ContactCheckBo xIDsInLeftMenu"].ToString().Sub string
(0,Session["ContactCheckBo xIDsInLeftMenu"].ToString().Len gth-1);

/* if(CommonProper ties.CompaniesC heckBoxIDsInLef tMenu.Length>0)
CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu=
CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu.Substring
(0,CommonProper ties.CompaniesC heckBoxIDsInLef tMenu.Length-1);

if(CommonProper ties.ContactChe ckBoxIDsInLeftM enu.Length>0)
CommonPropertie s.ContactCheckB oxIDsInLeftMenu =
CommonPropertie s.ContactCheckB oxIDsInLeftMenu .Substring
(0,CommonProper ties.ContactChe ckBoxIDsInLeftM enu.Length-1); */

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

if (_pageurl=="Vie wContact.aspx")
{
UserContorls.Vi ewContact viewcontact=new
CMS.UserContorl s.ViewContact() ;
viewcontact.Bin dViewDetails();
}
} */
}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
//string sql;
/*if (roleid=="1" || roleid=="2")
{
if (CommonProperti es.FilterCompan yId==null)
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+ro leid+" 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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY ='"+userid+"' ) and
company_id='"+C ommonProperties .FilterCompanyI d.ToString()+"' 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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp _LeftMenu_Compa ny",strcon);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Clear();
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );
objcomm.Paramet ers.Add( "@permissio n", permission );
/* objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/
try
{
objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",Convert.ToInt 32(Session["Filterrole id"]));
objcomm.Paramet ers.Add(
"@FILTER_USERID ",Convert.ToInt 32(Session["Filteruser id"]));
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Convert .ToInt32(Sessio n["FilterIV"]));
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Convert.ToI nt32(Session["FilterDoma in"]));
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Convert.ToI nt32(Session["FilterSour ce"]));
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Convert.T oInt32(Session["FilterWorkType "]));
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Conver t.ToInt32(Sessi on["FilterDisposit ion"]));
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",Session["Filteremai l"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",Session["Filterphon e"].ToString());
}
catch
{}
objread=objcomm .ExecuteReader( );
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu="";
//Session["CompaniesCheck BoxIDsInLeftMen u"]="";
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkc ompany"+objread["company_id "].ToString();
//Response.Write( objread["company_id "]);
chkbox.AutoPost Back=true;
chkbox.EnableVi ewState=true;

chkbox.Attribut es.Add("onClick ","javascript:F oo(this);");
chkbox.EnableVi ewState=true;
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu+=chkbox.ID+" ,";
Session["CompaniesCheck BoxIDsInLeftMen u"]+=chkbox.ID+"," ;
//if (CommonProperti es.SelectedComp any!=null)
if (Session["SelectedCompan y"].ToString()!="" )
{
//string info_company =
CommonPropertie s.SelectedCompa ny;
string info_company =
Session["SelectedCompan y"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Sp lit(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arI nfo[x])
{
chkbox.Checked= true;
}
}
}
chkbox.CheckedC hanged+=new
System.EventHan dler(this.ASSIG N_CHECKED);
plcompany.Contr ols.Add(chkbox) ;
litcontrol=new LiteralControl( );
litcontrol.Text ="<span
class=FilterLis tCompany>"+objr ead["company_na me"].ToString()+"</span><br>";
plcompany.Contr ols.Add(litcont rol );

subcontact(objr ead["company_id "].ToString());
}
}

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

}

public void subcontact(stri ng company_id)
{
using(SqlConnec tion strcon2=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();
//string sql2;

int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp _LeftMenu_Conta ct",strcon2);
objcomm2.Comman dType = CommandType.Sto redProcedure;
objcomm2.Parame ters.Clear();
objcomm2.Parame ters.Add( "@SESSION_ROLEI D", roleid );
objcomm2.Parame ters.Add( "@SESSION_USERI D", userid );
objcomm2.Parame ters.Add( "@permissio n", permission );
/* objcomm2.Parame ters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm2.Parame ters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm2.Parame ters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm2.Parame ters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm2.Parame ters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm2.Parame ters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm2.Parame ters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm2.Parame ters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm2.Parame ters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm2.Parame ters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm2.Parame ters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);
objcomm2.Parame ters.Add( "@FILTER_CONTAC TCOMPANYID",com pany_id);*/

objcomm2.Parame ters.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm2.Parame ters.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm2.Parame ters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
objcomm2.Parame ters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm2.Parame ters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm2.Parame ters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm2.Parame ters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm2.Parame ters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm2.Parame ters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm2.Parame ters.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm2.Parame ters.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);
objcomm2.Parame ters.Add( "@FILTER_CONTAC TCOMPANYID",com pany_id);

objread2=objcom m2.ExecuteReade r();
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu ="";
//Session["ContactCheckBo xIDsInLeftMenu"]="";
if (objread2.HasRo ws)
{
while(objread2. Read())
{
litcontrol2=new LiteralControl( );
litcontrol2.Tex t="&nbsp;&nbsp; &nbsp;";
plcompany.Contr ols.Add(litcont rol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkc ontact"+objread 2["contact_id "].ToString();
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu +=chkbox.ID+"," ;
Session["ContactCheckBo xIDsInLeftMenu"]+=chkbox.ID+"," ;
chkbox.AutoPost Back=true;
chkbox.EnableVi ewState=true;
//if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
//string info_company =
CommonPropertie s.SelectedConta ct;
string info_company =
Session["SelectedContac t"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Sp lit(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arI nfo[x])
{
chkbox.Checked= true;
}
}
}
chkbox.CheckedC hanged+=new
System.EventHan dler(this.Conta ct_Checked);
plcompany.Contr ols.Add(chkbox) ;
litcontrol2=new LiteralControl( );

if(roleid=="4" ||roleid=="5"|| roleid=="6"||ro leid=="7" )
{
int flag=ColorSeg(c ompany_id,objre ad2["contact_id "].ToString());

if(flag==0)//not alloted
{
litcontrol2.Tex t="<span
class=FilterLis tContact>"+objr ead2["contact_na me"].ToString()+"</span><br>";
}
else if(flag==1)//alloted to RA
{
litcontrol2.Tex t="<span
class=FilterLis tContactRA>"+ob jread2["contact_na me"].ToString()+"</span><br>";
}
else if(flag==2)// alloted to SR
{
litcontrol2.Tex t="<span
class=FilterLis tContactSR>"+ob jread2["contact_na me"].ToString()+"</span><br>";
}
else// alloted to both
{
litcontrol2.Tex t="<span
class=FilterLis tContactBoth>"+ objread2["contact_na me"].ToString()+"</span><br>";
}

}
else
{
litcontrol2.Tex t="<span
class=FilterLis tContact>"+objr ead2["contact_na me"].ToString()+"</span><br>";
}

plcompany.Contr ols.Add(litcont rol2 );
}
}
objcomm2.Cancel ();
objread2.Close( );
strcon2.Close() ;
}
}

private int ColorSeg(string company_id,stri ng contactid)
{
int flag=0;
string kk;
string sql="SELECT userroleid FROM
dbo.CONTACTSALL OCATION where CONTACT_ID="+co ntactid+" and userroleid
in(1,2)";
SqlConnection conn=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]);
SqlCommand cmd=new SqlCommand();
cmd.Parameters. Clear();
cmd.CommandText ="dbo.[Usp_LeftPanelCo lor]";
cmd.CommandType =CommandType.St oredProcedure;
cmd.Connection= conn;
cmd.Parameters. Add("@contactid ",Convert.ToInt 32(contactid));

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.To Int32(kk);
if(ds.Tables[0].Rows.Count>1)
{
flag=3;
}
}
return flag;

}

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

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.SelectLink .Click += new
System.EventHan dler(this.Selec tLink_Click);
this.ClearLink. Click += new
System.EventHan dler(this.Clear Link_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

public void ASSIGN_CHECKED( object sender, System.EventArg s e)
{
//CommonPropertie s.SelectedCompa ny=null;
Session["SelectedCompan y"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp _LeftMenu_Compa ny",strcon);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Clear();
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );
objcomm.Paramet ers.Add( "@permissio n", permission );
/*objcomm.Parame ters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

objcomm.Paramet ers.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm.Paramet ers.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm.Paramet ers.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm.Paramet ers.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);

objread=objcomm .ExecuteReader( );
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcompany"+ objread["company_id "].ToString());

string _unchkdcompanyi d=check.ID;
if (check.Checked= =true)
{
string _chkdcompanyid= check.ID;
//if (CommonProperti es.SelectedComp any!=null)
if (Session["SelectedCompan y"].ToString().Tri m()!="" )
{

//CommonPropertie s.SelectedCompa ny=CommonProper ties.SelectedCo mpany+","+_chkd companyid;
Session["SelectedCompan y"]=Session["SelectedCompan y"]+","+_chkdcompa nyid;
ChkContact(_chk dcompanyid);
}
else
{
//CommonPropertie s.SelectedCompa ny=_chkdcompany id;
Session["SelectedCompan y"]=_chkdcompanyid ;
ChkContact(_chk dcompanyid);
}
}
else
{
// UnChkContatct(_ unchkdcompanyid );
}
}
}
if(Session["SelectedCompan y"].ToString().Sta rtsWith(","))
{
Session["SelectedCompan y"]=Session["SelectedCompan y"].ToString().Sub string(1,Sessio n["SelectedCompan y"].ToString().Len gth);
}
if(Session["SelectedCompan y"].ToString().End sWith(","))
{
Session["SelectedCompan y"]=Session["SelectedCompan y"].ToString().Sub string(0,Sessio n["SelectedCompan y"].ToString().Len gth-1);
}
if(Session["SelectedContac t"].ToString().Sta rtsWith(","))
{
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Sub string(1,Sessio n["SelectedContac t"].ToString().Len gth);
}
if(Session["SelectedContac t"].ToString().End sWith(","))
{
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Sub string(0,Sessio n["SelectedContac t"].ToString().Len gth-1);
}
objcomm.Cancel( );
objread.Close() ;
}
string FlagStatus=Chec kBoxFlag.Value. ToString();

string strCompanyID=Co mpanyID.Value.T oString();
strCompanyID=st rCompanyID.Subs tring(strCompan yID.LastIndexOf ("_")+1);
if(!Convert.ToB oolean(FlagStat us))
UnChkContatct(s trCompanyID);
}

public void ChkContact(stri ng chkedCmpy)
{

chkedCmpy=chked Cmpy.Replace("c hkcompany","");
SqlConnection conn=new
SqlConnection(C onfigurationSet tings.AppSettin gs["CMSConnect ion"]);
conn.Open();
// SqlCommand cmdcontact=new SqlCommand("Sel ect CONTACT_ID from
Contacts where CONTACT_COMPANY _ID='"+chkedCmp y+"'", conn);
int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

SqlCommand cmdcontact=new SqlCommand("Aut oChkContacts",c onn);
cmdcontact.Comm andType = CommandType.Sto redProcedure;
cmdcontact.Para meters.Add( "@SESSION_ROLEI D", roleid );
cmdcontact.Para meters.Add( "@SESSION_USERI D", userid );
cmdcontact.Para meters.Add( "@permissio n", permission );
/*cmdcontact.Par ameters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

cmdcontact.Para meters.Add(
"@FILTER_ROLEID ",Session["Filterrole id"]);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",Session["Filteruser id"]);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",Session["Filteremai l"]);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",Session["Filterphon e"]);

cmdcontact.Para meters.Add( "@FILTER_CONTAC TCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact. ExecuteReader() ;

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

CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ rdr["CONTACT_ID "].ToString());
check.Checked=t rue;
string _chkdcontactid= check.ID;
//if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
int flag=AldyInsert Cont(_chkdconta ctid);
if(flag==0)
//CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact+","+_chkd contactid;
Session["SelectedContac t"]=Session["SelectedContac t"]+","+_chkdconta ctid;
}
else
{
//CommonPropertie s.SelectedConta ct=_chkdcontact id;
Session["SelectedContac t"]=_chkdcontactid ;
}
}
}

}

private int AldyInsertCont( string contid)
{
int flag=0;
string[] Cont=Session["SelectedContac t"].ToString().Spl it(new char[]
{','});
for(int i=0;i<Cont.Leng th;i++)
{
if(contid==Cont[i].ToString())
{
flag=1;
break;
}

}
return flag;
}

public void UnChkContatct(s tring chkedCmpy)
{

string chkedCmpy1=chke dCmpy;
chkedCmpy=chked Cmpy.Replace("c hkcompany","");
SqlConnection conn=new
SqlConnection(C onfigurationSet tings.AppSettin gs["CMSConnect ion"]);
conn.Open();

int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
SqlCommand cmdcontact=new SqlCommand("Aut oChkContacts",c onn);
cmdcontact.Comm andType = CommandType.Sto redProcedure;
cmdcontact.Para meters.Clear();
cmdcontact.Para meters.Add( "@SESSION_ROLEI D", roleid );
cmdcontact.Para meters.Add( "@SESSION_USERI D", userid );
cmdcontact.Para meters.Add( "@permissio n", permission );
/*cmdcontact.Par ameters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/
cmdcontact.Para meters.Add(
"@FILTER_ROLEID ",Session["Filterrole id"]);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",Session["Filteruser id"]);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",Session["Filteremai l"]);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",Session["Filterphon e"]);
cmdcontact.Para meters.Add( "@FILTER_CONTAC TCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact. ExecuteReader() ;
// string[] ChkContacts=Com monProperties.S electedContact. Split(new
char[] {','});
// CommonPropertie s.SelectedConta ct=null;
if(rdr.HasRows)
{
while(rdr.Read( ))
{
CheckBox check1 = (CheckBox)plcom pany.FindContro l(chkedCmpy1);
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ rdr["CONTACT_ID "].ToString());
//if(CommonProper ties.SelectedCo ntact!=null)
if(Session["SelectedContac t"].ToString()!="" )
{
/* if(CommonProper ties.SelectedCo ntact.IndexOf(c heck.ID.ToStrin g()+",")>-1)
CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact.Replace(c heck.ID.ToStrin g()+",","");
else
if(CommonProper ties.SelectedCo ntact.IndexOf(c heck.ID.ToStrin g())>-1)
CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact.Replace(c heck.ID.ToStrin g(),"");*/
if(Session["SelectedContac t"].ToString().Ind exOf(check.ID.T oString()+",")>-1)
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Rep lace(check.ID.T oString()+","," ");
else
if(Session["SelectedContac t"].ToString().Ind exOf(check.ID.T oString())>-1)
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Rep lace(check.ID.T oString(),"");
}
// CommonPropertie s.SelectedConta ct=null;
check.Checked=f alse;
}
}

}


public void Contact_Checked (object sender, System.EventArg s e)
{
// CommonPropertie s.SelectedConta ct=null;
Session["SelectedContac t"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
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 CONTACTSALLOCAT ION where
CONTACTSALLOCAT EDTO='"+userid+ "' and USERROLEID="+Se ssion["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 CONTACTSALLOCAT ION where
CONTACTSALLOCAT EDTO='"+userid+ "' and USERROLEID="+Se ssion["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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp _LeftMenu_Conta ct_Checked",str con);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );

objcomm.Paramet ers.Add( "@permissio n", permission );
/* objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);
objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

objcomm.Paramet ers.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm.Paramet ers.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm.Paramet ers.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm.Paramet ers.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);


objread=objcomm .ExecuteReader( );
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ objread["contact_id "].ToString());
if (check.Checked= =true)
{
string _chkdcompanyid= check.ID;
// if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
// CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact+","+_chkd companyid;
Session["SelectedContac t"]=Session["SelectedContac t"]+","+_chkdcompa nyid;
}
else
{
//CommonPropertie s.SelectedConta ct=_chkdcompany id;
Session["SelectedContac t"]=_chkdcompanyid ;
}
}

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

private void SelectLink_Clic k(object sender, System.EventArg s e)
{
CheckAllCompani esContact();
}
private void CheckAllCompani esContact()
{
try
{
// string []
CompanyCheckBox Ids=CommonPrope rties.Companies CheckBoxIDsInLe ftMenu.Split(ne w
char[] {','});
string []
CompanyCheckBox Ids=Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Spl it(new
char[] {','});
foreach (string temp in CompanyCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=t rue;

}
Session["SelectedCompan y"]=Session["CompaniesCheck BoxIDsInLeftMen u"];
}
catch{}
try
{
//string []
ContactCheckBox Ids=CommonPrope rties.ContactCh eckBoxIDsInLeft Menu.Split(new
char[] {','});
string []
ContactCheckBox Ids=Session["ContactCheckBo xIDsInLeftMenu"].ToString().Spl it(new
char[] {','});
foreach (string temp in ContactCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=t rue;

}
// CommonPropertie s.SelectedCompa ny=CommonProper ties.CompaniesC heckBoxIDsInLef tMenu;
// CommonPropertie s.SelectedConta ct=CommonProper ties.ContactChe ckBoxIDsInLeftM enu;

Session["SelectedContac t"]=Session["ContactCheckBo xIDsInLeftMenu"];
}
catch{}
}

private void ClearLink_Click (object sender, System.EventArg s e)
{
ClearAllCompani esContact();
}
private void ClearAllCompani esContact()
{
try
{
//string []
CompanyCheckBox Ids=CommonPrope rties.Companies CheckBoxIDsInLe ftMenu.Split(ne w
char[] {','});
string []
CompanyCheckBox Ids=Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Spl it(new
char[] {','});
foreach (string temp in CompanyCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=f alse;

}
Session["SelectedCompan y"]=Session["CompaniesCheck BoxIDsInLeftMen u"]="";
//string []
ContactCheckBox Ids=CommonPrope rties.ContactCh eckBoxIDsInLeft Menu.Split(new
char[] {','});
string []
ContactCheckBox Ids=Session["ContactCheckBo xIDsInLeftMenu"].ToString().Spl it(new
char[] {','});
foreach (string temp in ContactCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=f alse;

}

//CommonPropertie s.SelectedCompa ny=CommonProper ties.CompaniesC heckBoxIDsInLef tMenu="";

//CommonPropertie s.SelectedConta ct=CommonProper ties.ContactChe ckBoxIDsInLeftM enu="";
Session["SelectedContac t"]=Session["ContactCheckBo xIDsInLeftMenu"]="";
}
catch{}
}


}
}

Apr 13 '06 #8
Ummm, no one is going to read this. Can you please attach the code that
is causing the problem?
ar*********@gma il.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.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;
using System.Configur ation;
using Properties;
//using UserContorls;

/// <summary>
/// Summary description for DisplayCompanyC ontacts.
/// </summary>
public class DisplayCompanyC ontacts : System.Web.UI.U serControl
{
protected System.Web.UI.W ebControls.Plac eHolder plcompany;
LiteralControl litcontrol;
protected System.Web.UI.W ebControls.Chec kBox CheckBox1;
LiteralControl litcontrol2;
string roleid,userid;
protected System.Web.UI.W ebControls.Butt on btn;
protected System.Web.UI.W ebControls.Link Button ClearLink;
protected System.Web.UI.H tmlControls.Htm lInputHidden CheckBoxFlag;
protected System.Web.UI.H tmlControls.Htm lInputHidden CompanyID;
protected System.Web.UI.W ebControls.Link Button SelectLink;

private void Page_Load(objec t sender, System.EventArg s e)
{
//DisplayConversa tionFromCalande r();
if (Session["Userid"].ToString()=="" )
{
Session.Abandon ();
Response.Redire ct("Login.aspx" );
}

Session["ContactCheckBo xIDsInLeftMenu"]="";
Session["CompaniesCheck BoxIDsInLeftMen u"]="";
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu ="";
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu="";
roleid=Session["Roleid"].ToString().Tri m();
userid=Session["Userid"].ToString().Tri m();
//if(!IsPostBack)
bindleftpanel() ;
///Removing these Common Properties and Placing Sessions Instead

if(Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Len gth>0)
Session["CompaniesCheck BoxIDsInLeftMen u"]=
Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Sub string
(0,Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Len gth-1);

if(Session["ContactCheckBo xIDsInLeftMenu"].ToString().Len gth>0)
Session["ContactCheckBo xIDsInLeftMenu"]=
Session["ContactCheckBo xIDsInLeftMenu"].ToString().Sub string
(0,Session["ContactCheckBo xIDsInLeftMenu"].ToString().Len gth-1);

/* if(CommonProper ties.CompaniesC heckBoxIDsInLef tMenu.Length>0)
CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu=
CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu.Substring
(0,CommonProper ties.CompaniesC heckBoxIDsInLef tMenu.Length-1);

if(CommonProper ties.ContactChe ckBoxIDsInLeftM enu.Length>0)
CommonPropertie s.ContactCheckB oxIDsInLeftMenu =
CommonPropertie s.ContactCheckB oxIDsInLeftMenu .Substring
(0,CommonProper ties.ContactChe ckBoxIDsInLeftM enu.Length-1); */

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

if (_pageurl=="Vie wContact.aspx")
{
UserContorls.Vi ewContact viewcontact=new
CMS.UserContorl s.ViewContact() ;
viewcontact.Bin dViewDetails();
}
} */
}

public void bindleftpanel()
{
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
SqlCommand objcomm;
SqlDataReader objread;
strcon.Open();
//string sql;
/*if (roleid=="1" || roleid=="2")
{
if (CommonProperti es.FilterCompan yId==null)
{
sql="select * from company where COMPANY_ID in (Select COMPANY_ID
from COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+ro leid+" 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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["Roleid"]+" Union Select Company_id from Company
where COMPANY_ADDEDBY ='"+userid+"' ) and
company_id='"+C ommonProperties .FilterCompanyI d.ToString()+"' 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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

objcomm=new SqlCommand("Usp _LeftMenu_Compa ny",strcon);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Clear();
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );
objcomm.Paramet ers.Add( "@permissio n", permission );
/* objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/
try
{
objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",Convert.ToInt 32(Session["Filterrole id"]));
objcomm.Paramet ers.Add(
"@FILTER_USERID ",Convert.ToInt 32(Session["Filteruser id"]));
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Convert .ToInt32(Sessio n["FilterIV"]));
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Convert.ToI nt32(Session["FilterDoma in"]));
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Convert.ToI nt32(Session["FilterSour ce"]));
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Convert.T oInt32(Session["FilterWorkType "]));
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Conver t.ToInt32(Sessi on["FilterDisposit ion"]));
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",Session["Filteremai l"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",Session["Filterphon e"].ToString());
}
catch
{}
objread=objcomm .ExecuteReader( );
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu="";
//Session["CompaniesCheck BoxIDsInLeftMen u"]="";
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox chkbox=new CheckBox();
chkbox.ID="chkc ompany"+objread["company_id "].ToString();
//Response.Write( objread["company_id "]);
chkbox.AutoPost Back=true;
chkbox.EnableVi ewState=true;

chkbox.Attribut es.Add("onClick ","javascript:F oo(this);");
chkbox.EnableVi ewState=true;
//CommonPropertie s.CompaniesChec kBoxIDsInLeftMe nu+=chkbox.ID+" ,";
Session["CompaniesCheck BoxIDsInLeftMen u"]+=chkbox.ID+"," ;
//if (CommonProperti es.SelectedComp any!=null)
if (Session["SelectedCompan y"].ToString()!="" )
{
//string info_company =
CommonPropertie s.SelectedCompa ny;
string info_company =
Session["SelectedCompan y"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Sp lit(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arI nfo[x])
{
chkbox.Checked= true;
}
}
}
chkbox.CheckedC hanged+=new
System.EventHan dler(this.ASSIG N_CHECKED);
plcompany.Contr ols.Add(chkbox) ;
litcontrol=new LiteralControl( );
litcontrol.Text ="<span
class=FilterLis tCompany>"+objr ead["company_na me"].ToString()+"</span><br>";
plcompany.Contr ols.Add(litcont rol );

subcontact(objr ead["company_id "].ToString());
}
}

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

}

public void subcontact(stri ng company_id)
{
using(SqlConnec tion strcon2=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
SqlCommand objcomm2;
SqlDataReader objread2;
strcon2.Open();
//string sql2;

int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm2=new SqlCommand("Usp _LeftMenu_Conta ct",strcon2);
objcomm2.Comman dType = CommandType.Sto redProcedure;
objcomm2.Parame ters.Clear();
objcomm2.Parame ters.Add( "@SESSION_ROLEI D", roleid );
objcomm2.Parame ters.Add( "@SESSION_USERI D", userid );
objcomm2.Parame ters.Add( "@permissio n", permission );
/* objcomm2.Parame ters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm2.Parame ters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm2.Parame ters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm2.Parame ters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm2.Parame ters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm2.Parame ters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm2.Parame ters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm2.Parame ters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm2.Parame ters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm2.Parame ters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm2.Parame ters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);
objcomm2.Parame ters.Add( "@FILTER_CONTAC TCOMPANYID",com pany_id);*/

objcomm2.Parame ters.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm2.Parame ters.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm2.Parame ters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
objcomm2.Parame ters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm2.Parame ters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm2.Parame ters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm2.Parame ters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm2.Parame ters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm2.Parame ters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm2.Parame ters.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm2.Parame ters.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);
objcomm2.Parame ters.Add( "@FILTER_CONTAC TCOMPANYID",com pany_id);

objread2=objcom m2.ExecuteReade r();
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu ="";
//Session["ContactCheckBo xIDsInLeftMenu"]="";
if (objread2.HasRo ws)
{
while(objread2. Read())
{
litcontrol2=new LiteralControl( );
litcontrol2.Tex t="&nbsp;&nbsp; &nbsp;";
plcompany.Contr ols.Add(litcont rol2 );

CheckBox chkbox=new CheckBox();
chkbox.ID="chkc ontact"+objread 2["contact_id "].ToString();
//CommonPropertie s.ContactCheckB oxIDsInLeftMenu +=chkbox.ID+"," ;
Session["ContactCheckBo xIDsInLeftMenu"]+=chkbox.ID+"," ;
chkbox.AutoPost Back=true;
chkbox.EnableVi ewState=true;
//if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
//string info_company =
CommonPropertie s.SelectedConta ct;
string info_company =
Session["SelectedContac t"].ToString();
char[] splitter = {','};
string[] arInfo = info_company.Sp lit(splitter);

for(int x = 0; x < arInfo.Length; x++)
{
if (chkbox.ID==arI nfo[x])
{
chkbox.Checked= true;
}
}
}
chkbox.CheckedC hanged+=new
System.EventHan dler(this.Conta ct_Checked);
plcompany.Contr ols.Add(chkbox) ;
litcontrol2=new LiteralControl( );

if(roleid=="4" ||roleid=="5"|| roleid=="6"||ro leid=="7" )
{
int flag=ColorSeg(c ompany_id,objre ad2["contact_id "].ToString());

if(flag==0)//not alloted
{
litcontrol2.Tex t="<span
class=FilterLis tContact>"+objr ead2["contact_na me"].ToString()+"</span><br>";
}
else if(flag==1)//alloted to RA
{
litcontrol2.Tex t="<span
class=FilterLis tContactRA>"+ob jread2["contact_na me"].ToString()+"</span><br>";
}
else if(flag==2)// alloted to SR
{
litcontrol2.Tex t="<span
class=FilterLis tContactSR>"+ob jread2["contact_na me"].ToString()+"</span><br>";
}
else// alloted to both
{
litcontrol2.Tex t="<span
class=FilterLis tContactBoth>"+ objread2["contact_na me"].ToString()+"</span><br>";
}

}
else
{
litcontrol2.Tex t="<span
class=FilterLis tContact>"+objr ead2["contact_na me"].ToString()+"</span><br>";
}

plcompany.Contr ols.Add(litcont rol2 );
}
}
objcomm2.Cancel ();
objread2.Close( );
strcon2.Close() ;
}
}

private int ColorSeg(string company_id,stri ng contactid)
{
int flag=0;
string kk;
string sql="SELECT userroleid FROM
dbo.CONTACTSALL OCATION where CONTACT_ID="+co ntactid+" and userroleid
in(1,2)";
SqlConnection conn=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]);
SqlCommand cmd=new SqlCommand();
cmd.Parameters. Clear();
cmd.CommandText ="dbo.[Usp_LeftPanelCo lor]";
cmd.CommandType =CommandType.St oredProcedure;
cmd.Connection= conn;
cmd.Parameters. Add("@contactid ",Convert.ToInt 32(contactid));

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.To Int32(kk);
if(ds.Tables[0].Rows.Count>1)
{
flag=3;
}
}
return flag;

}

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

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.SelectLink .Click += new
System.EventHan dler(this.Selec tLink_Click);
this.ClearLink. Click += new
System.EventHan dler(this.Clear Link_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

public void ASSIGN_CHECKED( object sender, System.EventArg s e)
{
//CommonPropertie s.SelectedCompa ny=null;
Session["SelectedCompan y"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp _LeftMenu_Compa ny",strcon);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Clear();
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );
objcomm.Paramet ers.Add( "@permissio n", permission );
/*objcomm.Parame ters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

objcomm.Paramet ers.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm.Paramet ers.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm.Paramet ers.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm.Paramet ers.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);

objread=objcomm .ExecuteReader( );
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcompany"+ objread["company_id "].ToString());

string _unchkdcompanyi d=check.ID;
if (check.Checked= =true)
{
string _chkdcompanyid= check.ID;
//if (CommonProperti es.SelectedComp any!=null)
if (Session["SelectedCompan y"].ToString().Tri m()!="" )
{

//CommonPropertie s.SelectedCompa ny=CommonProper ties.SelectedCo mpany+","+_chkd companyid;
Session["SelectedCompan y"]=Session["SelectedCompan y"]+","+_chkdcompa nyid;
ChkContact(_chk dcompanyid);
}
else
{
//CommonPropertie s.SelectedCompa ny=_chkdcompany id;
Session["SelectedCompan y"]=_chkdcompanyid ;
ChkContact(_chk dcompanyid);
}
}
else
{
// UnChkContatct(_ unchkdcompanyid );
}
}
}
if(Session["SelectedCompan y"].ToString().Sta rtsWith(","))
{
Session["SelectedCompan y"]=Session["SelectedCompan y"].ToString().Sub string(1,Sessio n["SelectedCompan y"].ToString().Len gth);
}
if(Session["SelectedCompan y"].ToString().End sWith(","))
{
Session["SelectedCompan y"]=Session["SelectedCompan y"].ToString().Sub string(0,Sessio n["SelectedCompan y"].ToString().Len gth-1);
}
if(Session["SelectedContac t"].ToString().Sta rtsWith(","))
{
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Sub string(1,Sessio n["SelectedContac t"].ToString().Len gth);
}
if(Session["SelectedContac t"].ToString().End sWith(","))
{
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Sub string(0,Sessio n["SelectedContac t"].ToString().Len gth-1);
}
objcomm.Cancel( );
objread.Close() ;
}
string FlagStatus=Chec kBoxFlag.Value. ToString();

string strCompanyID=Co mpanyID.Value.T oString();
strCompanyID=st rCompanyID.Subs tring(strCompan yID.LastIndexOf ("_")+1);
if(!Convert.ToB oolean(FlagStat us))
UnChkContatct(s trCompanyID);
}

public void ChkContact(stri ng chkedCmpy)
{

chkedCmpy=chked Cmpy.Replace("c hkcompany","");
SqlConnection conn=new
SqlConnection(C onfigurationSet tings.AppSettin gs["CMSConnect ion"]);
conn.Open();
// SqlCommand cmdcontact=new SqlCommand("Sel ect CONTACT_ID from
Contacts where CONTACT_COMPANY _ID='"+chkedCmp y+"'", conn);
int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}

SqlCommand cmdcontact=new SqlCommand("Aut oChkContacts",c onn);
cmdcontact.Comm andType = CommandType.Sto redProcedure;
cmdcontact.Para meters.Add( "@SESSION_ROLEI D", roleid );
cmdcontact.Para meters.Add( "@SESSION_USERI D", userid );
cmdcontact.Para meters.Add( "@permissio n", permission );
/*cmdcontact.Par ameters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

cmdcontact.Para meters.Add(
"@FILTER_ROLEID ",Session["Filterrole id"]);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",Session["Filteruser id"]);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",Session["Filteremai l"]);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",Session["Filterphon e"]);

cmdcontact.Para meters.Add( "@FILTER_CONTAC TCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact. ExecuteReader() ;

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

CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ rdr["CONTACT_ID "].ToString());
check.Checked=t rue;
string _chkdcontactid= check.ID;
//if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
int flag=AldyInsert Cont(_chkdconta ctid);
if(flag==0)
//CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact+","+_chkd contactid;
Session["SelectedContac t"]=Session["SelectedContac t"]+","+_chkdconta ctid;
}
else
{
//CommonPropertie s.SelectedConta ct=_chkdcontact id;
Session["SelectedContac t"]=_chkdcontactid ;
}
}
}

}

private int AldyInsertCont( string contid)
{
int flag=0;
string[] Cont=Session["SelectedContac t"].ToString().Spl it(new char[]
{','});
for(int i=0;i<Cont.Leng th;i++)
{
if(contid==Cont[i].ToString())
{
flag=1;
break;
}

}
return flag;
}

public void UnChkContatct(s tring chkedCmpy)
{

string chkedCmpy1=chke dCmpy;
chkedCmpy=chked Cmpy.Replace("c hkcompany","");
SqlConnection conn=new
SqlConnection(C onfigurationSet tings.AppSettin gs["CMSConnect ion"]);
conn.Open();

int permission=0;
if((CommonRules .CommonLogic.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
SqlCommand cmdcontact=new SqlCommand("Aut oChkContacts",c onn);
cmdcontact.Comm andType = CommandType.Sto redProcedure;
cmdcontact.Para meters.Clear();
cmdcontact.Para meters.Add( "@SESSION_ROLEI D", roleid );
cmdcontact.Para meters.Add( "@SESSION_USERI D", userid );
cmdcontact.Para meters.Add( "@permissio n", permission );
/*cmdcontact.Par ameters.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/
cmdcontact.Para meters.Add(
"@FILTER_ROLEID ",Session["Filterrole id"]);
cmdcontact.Para meters.Add(
"@FILTER_USERID ",Session["Filteruser id"]);
cmdcontact.Para meters.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"]);
cmdcontact.Para meters.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
cmdcontact.Para meters.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
cmdcontact.Para meters.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
cmdcontact.Para meters.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
cmdcontact.Para meters.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
cmdcontact.Para meters.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
cmdcontact.Para meters.Add(
"@FILTER_EMAILI D",Session["Filteremai l"]);
cmdcontact.Para meters.Add(
"@FILTER_PHONEN O",Session["Filterphon e"]);
cmdcontact.Para meters.Add( "@FILTER_CONTAC TCOMPANYID", chkedCmpy );
SqlDataReader rdr=cmdcontact. ExecuteReader() ;
// string[] ChkContacts=Com monProperties.S electedContact. Split(new
char[] {','});
// CommonPropertie s.SelectedConta ct=null;
if(rdr.HasRows)
{
while(rdr.Read( ))
{
CheckBox check1 = (CheckBox)plcom pany.FindContro l(chkedCmpy1);
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ rdr["CONTACT_ID "].ToString());
//if(CommonProper ties.SelectedCo ntact!=null)
if(Session["SelectedContac t"].ToString()!="" )
{
/* if(CommonProper ties.SelectedCo ntact.IndexOf(c heck.ID.ToStrin g()+",")>-1)
CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact.Replace(c heck.ID.ToStrin g()+",","");
else
if(CommonProper ties.SelectedCo ntact.IndexOf(c heck.ID.ToStrin g())>-1)
CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact.Replace(c heck.ID.ToStrin g(),"");*/
if(Session["SelectedContac t"].ToString().Ind exOf(check.ID.T oString()+",")>-1)
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Rep lace(check.ID.T oString()+","," ");
else
if(Session["SelectedContac t"].ToString().Ind exOf(check.ID.T oString())>-1)
Session["SelectedContac t"]=Session["SelectedContac t"].ToString().Rep lace(check.ID.T oString(),"");
}
// CommonPropertie s.SelectedConta ct=null;
check.Checked=f alse;
}
}

}


public void Contact_Checked (object sender, System.EventArg s e)
{
// CommonPropertie s.SelectedConta ct=null;
Session["SelectedContac t"]="";
using( SqlConnection strcon=new SqlConnection
(ConfigurationS ettings.AppSett ings["CMSConnect ion"]))
{
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 CONTACTSALLOCAT ION where
CONTACTSALLOCAT EDTO='"+userid+ "' and USERROLEID="+Se ssion["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 CONTACTSALLOCAT ION where
CONTACTSALLOCAT EDTO='"+userid+ "' and USERROLEID="+Se ssion["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 COMPANYALLOCATI ON where COMPANYALLOCATE DTO='"+userid+" ' and
USERROLEID="+Se ssion["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.is ValidServiceIte m(Convert.ToInt 32(Session["RoleID"]),"Allow
all Companies")))
{
permission=1;//full pemission
}
objcomm=new SqlCommand("Usp _LeftMenu_Conta ct_Checked",str con);
objcomm.Command Type = CommandType.Sto redProcedure;
objcomm.Paramet ers.Add( "@SESSION_ROLEI D", roleid );
objcomm.Paramet ers.Add( "@SESSION_USERI D", userid );

objcomm.Paramet ers.Add( "@permissio n", permission );
/* objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);
objcomm.Paramet ers.Add(
"@FILTER_ROLEID ",CommonPropert ies.Filterrolei d);
objcomm.Paramet ers.Add(
"@FILTER_USERID ",CommonPropert ies.Filteruseri d);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",CommonProp erties.FilterCo mpanyId);
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",CommonP roperties.Filte rIV);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",CommonPrope rties.FilterDom ain);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",CommonPrope rties.FilterSou rce);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",CommonPro perties.FilterW orkType);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Common Properties.Filt erDisposition);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",CommonPr operties.Filter Designation);
objcomm.Paramet ers.Add(
"@FILTER_EMAILI D",CommonProper ties.Filteremai l);
objcomm.Paramet ers.Add(
"@FILTER_PHONEN O",CommonProper ties.Filterphon e);*/

objcomm.Paramet ers.Add( "@FILTER_ROLEID ",Session["Filterrole id"]);
objcomm.Paramet ers.Add( "@FILTER_USERID ",Session["Filteruser id"]);
objcomm.Paramet ers.Add(
"@FILTER_COMPAN YID",Session["FilterCompanyI d"].ToString());
objcomm.Paramet ers.Add(
"@FILTER_INVERT ICALID",Session["FilterIV"]);
objcomm.Paramet ers.Add(
"@FILTER_DOMAIN ID",Session["FilterDoma in"]);
objcomm.Paramet ers.Add(
"@FILTER_SOURCE ID",Session["FilterSour ce"]);
objcomm.Paramet ers.Add(
"@FILTER_WORKTY PEID",Session["FilterWorkType "]);
objcomm.Paramet ers.Add(
"@FILTER_DISPOS ITIONID",Sessio n["FilterDisposit ion"]);
objcomm.Paramet ers.Add(
"@FILTER_DESIGN ATION",Session["FilterDesignat ion"]);
objcomm.Paramet ers.Add( "@FILTER_EMAILI D",Session["Filteremai l"]);
objcomm.Paramet ers.Add( "@FILTER_PHONEN O",Session["Filterphon e"]);


objread=objcomm .ExecuteReader( );
if (objread.HasRow s)
{
while (objread.Read() )
{
CheckBox check =
(CheckBox)plcom pany.FindContro l("chkcontact"+ objread["contact_id "].ToString());
if (check.Checked= =true)
{
string _chkdcompanyid= check.ID;
// if (CommonProperti es.SelectedCont act!=null)
if (Session["SelectedContac t"].ToString()!="" )
{
// CommonPropertie s.SelectedConta ct=CommonProper ties.SelectedCo ntact+","+_chkd companyid;
Session["SelectedContac t"]=Session["SelectedContac t"]+","+_chkdcompa nyid;
}
else
{
//CommonPropertie s.SelectedConta ct=_chkdcompany id;
Session["SelectedContac t"]=_chkdcompanyid ;
}
}

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

private void SelectLink_Clic k(object sender, System.EventArg s e)
{
CheckAllCompani esContact();
}
private void CheckAllCompani esContact()
{
try
{
// string []
CompanyCheckBox Ids=CommonPrope rties.Companies CheckBoxIDsInLe ftMenu.Split(ne w
char[] {','});
string []
CompanyCheckBox Ids=Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Spl it(new
char[] {','});
foreach (string temp in CompanyCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=t rue;

}
Session["SelectedCompan y"]=Session["CompaniesCheck BoxIDsInLeftMen u"];
}
catch{}
try
{
//string []
ContactCheckBox Ids=CommonPrope rties.ContactCh eckBoxIDsInLeft Menu.Split(new
char[] {','});
string []
ContactCheckBox Ids=Session["ContactCheckBo xIDsInLeftMenu"].ToString().Spl it(new
char[] {','});
foreach (string temp in ContactCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=t rue;

}
// CommonPropertie s.SelectedCompa ny=CommonProper ties.CompaniesC heckBoxIDsInLef tMenu;
// CommonPropertie s.SelectedConta ct=CommonProper ties.ContactChe ckBoxIDsInLeftM enu;

Session["SelectedContac t"]=Session["ContactCheckBo xIDsInLeftMenu"];
}
catch{}
}

private void ClearLink_Click (object sender, System.EventArg s e)
{
ClearAllCompani esContact();
}
private void ClearAllCompani esContact()
{
try
{
//string []
CompanyCheckBox Ids=CommonPrope rties.Companies CheckBoxIDsInLe ftMenu.Split(ne w
char[] {','});
string []
CompanyCheckBox Ids=Session["CompaniesCheck BoxIDsInLeftMen u"].ToString().Spl it(new
char[] {','});
foreach (string temp in CompanyCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=f alse;

}
Session["SelectedCompan y"]=Session["CompaniesCheck BoxIDsInLeftMen u"]="";
//string []
ContactCheckBox Ids=CommonPrope rties.ContactCh eckBoxIDsInLeft Menu.Split(new
char[] {','});
string []
ContactCheckBox Ids=Session["ContactCheckBo xIDsInLeftMenu"].ToString().Spl it(new
char[] {','});
foreach (string temp in ContactCheckBox Ids)
{
CheckBox check = (CheckBox)plcom pany.FindContro l(temp);
check.Checked=f alse;

}

//CommonPropertie s.SelectedCompa ny=CommonProper ties.CompaniesC heckBoxIDsInLef tMenu="";

//CommonPropertie s.SelectedConta ct=CommonProper ties.ContactChe ckBoxIDsInLeftM enu="";
Session["SelectedContac t"]=Session["ContactCheckBo xIDsInLeftMenu"]="";
}
catch{}
}


}
}

Apr 13 '06 #9
Well, the problem is this code only........... ....

If you could solve it then please seee...

Apr 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2434
by: Sean Pinto | last post by:
Ok, you all are going to have to bear with me on this one as it is kinda complicated to explain. I am implementing a company management suite that requires Role-Based authentiations (ie. users are in groups and groups have roles). I have one script which is included in EVERY page in the protected area (masterFuncs.php) and it contains function declarations as well as the authentication module kick-off. Here is a snippet from masterFuncs...
8
3690
by: Karen | last post by:
Hi there.... i got a quick one for you guys. i've this session variable that is updated by calling a server method (i set this value when the user hits a submit button in my form. The server method is called when i load all my asp forms.). I'd like to be able to update this session variable, without being forced to submit my form or refresh my form (something that will call my server method each 2 min lets say, without refreshing my page...
5
4015
by: Larry Woods | last post by:
I am losing Session variables, but only those that are set in the page previous to a redirect to a secure page. Anyone seen ANY situation where Session variables just "disappear?" Note that OTHER session variables are still intact !?! TIA, Larry Woods
6
2232
by: Brian Brinks | last post by:
I am having some trouble with seesion variables. I have just moved hosting companies to Brinkster.com but have been having problems with my applications holding session. They say they can't guarantee sessions and recomend another method of storing persistant data. I questioned them on why, only on their servers, my sessions are being reset as often as they are. They said it must be a coding issue.
9
2376
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use - perhaps I'm just not very smart or perhaps MS is making this too hard for us sql bunnies to understand - I dunno, but I'd really appreciate someone explaining what I'm doing wrong here & perhaps suggest a better approach.. I'm familiar with use of...
2
3325
by: moondaddy | last post by:
I need to set a variable to a session variable (if that's what you call it) like this: dim ds as dataset = HttpContext.Current.Session("CustDataSet") But I get an exception if this variable in the current session hasn't been set yet so I need to test it. I tried: If HttpContext.Current.Session("CustDataSet") = nothing then HttpContext.Current.Session("CustDataSet") = GetCustDataSet()
9
2100
by: Schraalhans Keukenmeester | last post by:
I am stomped with the following problem: I have a script start.php and a second script proceed.php Relevant (and working) sections of the code: start.php <?PHP start_session();
5
1965
by: Chenky | last post by:
Hi all, I'm not a overly experienced PHP programmer but I like to dabble and I'm working on a 'semi-secure' member's area. Previous I have used normal variables to determine the validity of a user. i.e. Once the user has logged in, a random id is created an placed in the database in their row and each secured page will have a URL like this : .../secure.php?user=joebloggs&randid=324395 Each page looks up the username and checks it...
18
3427
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that File-New-Window creates an instance of IE in the same process with the same SessionID as the parent window is in big trouble. This fundamentally restricts the usefullness of using session state management. I probably missed it somewhere - can...
0
8425
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5445
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3958
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2438
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1541
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1271
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.