Esempio n. 1
0
        public void Find_Click(object sender, EventArgs e)
        {
            switch (((LinkButton)sender).ID)
            {
            case "Find":
                string top      = String.Empty;
                string fullText = String.Empty;
                if (RadioList1.Items[1].Selected)
                {
                    fullText = "%";
                }
                top = "top " + NRes.SelectedValue;
                string sqlString = "SELECT " + top + " CRM_LEADS.ID,(CRM_LEADS.SURNAME+' '+ISNULL(CRM_LEADS.NAME,'')) AS REFERENTE,CRM_LEADS.COMPANYNAME, CRM_LEADS.COMPANYID, CRM_LEADS.EMAIL, CRM_CROSSLEAD.SALESPERSON, CRM_LEADS.OWNERID FROM CRM_LEADS INNER JOIN CRM_CROSSLEAD ON CRM_LEADS.ID=CRM_CROSSLEAD.LEADID ";
                sqlString += "WHERE (CRM_LEADS.LIMBO=0 AND ACTIVE=1 AND ((" + GroupsSecure("CRM_LEADS.GROUPS") + ") OR CRM_LEADS.OWNERID=" + UC.UserId + ")) AND (CRM_LEADS.NAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.SURNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.PHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.MOBILEPHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.COMPANYNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%') ";
                if (UC.Zones.Length > 0)
                {
                    sqlString += String.Format(" AND ({0})", ZoneSecure("CRM_LEADS.COMMERCIALZONE", UC));
                }

                sqlString += " ORDER BY REFERENTE";
                ContactReferrer.DataSource = DatabaseConnection.CreateDataset(sqlString);
                ContactReferrer.DataBind();
                break;

            case "NewRef":
                Find.Visible            = false;
                FindIt.Visible          = false;
                ContactReferrer.Visible = false;
                NewReferrer.Visible     = true;
                break;
            }
        }
Esempio n. 2
0
 public void FindClick(object sender, EventArgs e)
 {
     if (Request.QueryString["Impersonate"] != null)
     {
         ContactReferrer.DataSource = DatabaseConnection.CreateDataset("sELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE DIARYACCOUNT LIKE '|%" + UC.UserId + "|%') AND (NAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR SURNAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%')");
     }
     else
     {
         if (ViewState["sales"].ToString() == "0")
         {
             ContactReferrer.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE (NAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR SURNAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%')");
         }
         else
         {
             ContactReferrer.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE ACCESSLEVEL=" + ViewState["sales"] + " AND (NAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR SURNAME LIKE '%" + DatabaseConnection.FilterInjection(FindIt.Text) + "%')");
         }
     }
     ContactReferrer.DataBind();
 }
Esempio n. 3
0
        private void FindCompany(int cID)
        {
            string sqlString = "SELECT BASE_CONTACTS.ID,(BASE_CONTACTS.SURNAME+' '+ISNULL(BASE_CONTACTS.NAME,'')) AS REFERENTE,BASE_COMPANIES.COMPANYNAME, BASE_COMPANIES.ID AS COMPANYID, BASE_CONTACTS.EMAIL, BASE_CONTACTS.SALESPERSONID, BASE_CONTACTS.OWNERID FROM BASE_CONTACTS ";

            sqlString += "LEFT OUTER JOIN BASE_COMPANIES ON BASE_CONTACTS.COMPANYID = BASE_COMPANIES.ID WHERE BASE_CONTACTS.LIMBO=0 AND (BASE_CONTACTS.COMPANYID=" + cID + ") ";
            string queryGroup = GroupsSecure("BASE_CONTACTS.GROUPS", UC);

            if (queryGroup.Length > 0)
            {
                sqlString += String.Format(" AND ({0})", queryGroup);
            }
            if (UC.Zones.Length > 0)
            {
                sqlString += String.Format(" AND ({0})", ZoneSecure("BASE_CONTACTS.COMMERCIALZONE", UC));
            }

            sqlString += " ORDER BY REFERENTE";
            ContactReferrer.DataSource = DatabaseConnection.CreateDataset(sqlString);
            ContactReferrer.DataBind();
        }
Esempio n. 4
0
        private void FillRepeater(string control3, bool admin)
        {
            string    userquery = @"SELECT PROJECT_MEMBERS.USERID, PROJECT_MEMBERS.ID, PROJECT_MEMBERS.TEAM, PROJECT_MEMBERS.TYPE, PROJECT_TEAMS.DESCRIPTION, ISNULL(ACCOUNT.NAME,'')+' '+ISNULL(ACCOUNT.SURNAME,'') AS MEMBERNAME
FROM PROJECT_MEMBERS LEFT OUTER JOIN ACCOUNT ON PROJECT_MEMBERS.USERID = ACCOUNT.UID LEFT OUTER JOIN
PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM = PROJECT_TEAMS.ID WHERE PROJECT_MEMBERS.TYPE=2 AND PROJECT_TEAMS.PROJECTID=" + ViewState["ProjectId"];
            DataTable dtLeader  = DatabaseConnection.CreateDataset(userquery).Tables[0];

            userquery = @"SELECT PROJECT_MEMBERS.USERID, PROJECT_MEMBERS.ID, PROJECT_MEMBERS.TEAM, PROJECT_MEMBERS.TYPE, PROJECT_TEAMS.DESCRIPTION, ISNULL(ACCOUNT.NAME,'')+' '+ISNULL(ACCOUNT.SURNAME,'') AS MEMBERNAME
FROM PROJECT_MEMBERS LEFT OUTER JOIN ACCOUNT ON PROJECT_MEMBERS.USERID = ACCOUNT.UID LEFT OUTER JOIN
PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM = PROJECT_TEAMS.ID WHERE PROJECT_MEMBERS.TYPE=0 AND PROJECT_TEAMS.PROJECTID=" + ViewState["ProjectId"];
            DataTable dtUser = DatabaseConnection.CreateDataset(userquery).Tables[0];

            DataTable dtContacs = new DataTable();

            if (control3 != "0")
            {
                userquery = @"SELECT PROJECT_MEMBERS.USERID, PROJECT_MEMBERS.ID, PROJECT_MEMBERS.TEAM, PROJECT_MEMBERS.TYPE, PROJECT_TEAMS.DESCRIPTION, ISNULL(BASE_CONTACTS.NAME,'')+' '+ISNULL(BASE_CONTACTS.SURNAME,'') AS MEMBERNAME
FROM PROJECT_MEMBERS LEFT OUTER JOIN BASE_CONTACTS ON PROJECT_MEMBERS.USERID = BASE_CONTACTS.ID LEFT OUTER JOIN
PROJECT_TEAMS ON PROJECT_MEMBERS.TEAM = PROJECT_TEAMS.ID WHERE PROJECT_MEMBERS.TYPE=1 AND PROJECT_TEAMS.PROJECTID=" + ViewState["ProjectId"];
                dtContacs = DatabaseConnection.CreateDataset(userquery).Tables[0];
            }

            DataTable dtTemp     = DataManipulation.Union(dtLeader, dtUser);
            DataTable dtComplete = new DataTable();

            if (control3 != "0")
            {
                dtComplete = DataManipulation.Union(dtTemp, dtContacs);
            }
            else
            {
                dtComplete = dtTemp;
            }



            dtComplete.DefaultView.Sort = "TEAM";
            ContactReferrer.DataSource  = dtComplete;
            ContactReferrer.DataBind();
        }
Esempio n. 5
0
        private void FindCompany(int cID)
        {
            string sqlString = "SELECT CRM_LEADS.ID,(CRM_LEADS.SURNAME+' '+ISNULL(CRM_LEADS.NAME,'')) AS REFERENTE,CRM_LEADS.COMPANYNAME, CRM_LEADS.COMPANYID, CRM_LEADS.EMAIL FROM CRM_LEADS "
                               + "WHERE (CRM_LEADS.LIMBO=0 AND ACTIVE=1 AND ((" + GroupsSecure("CRM_LEADS.GROUPS") + ") OR CRM_LEADS.OWNERID=" + UC.UserId + ")) AND (CRM_LEADS.COMPANYID=@COMPANYID) ";
            DbSqlParameterCollection par = new DbSqlParameterCollection();

            par.Add(new DbSqlParameter("@COMPANYID", cID));
            string queryGroup = GroupsSecure("CRM_LEADS.GROUPS", UC);

            if (queryGroup.Length > 0)
            {
                sqlString += String.Format(" AND ({0})", queryGroup);
            }
            if (UC.Zones.Length > 0)
            {
                sqlString += String.Format(" AND ({0})", ZoneSecure("CRM_LEADS.COMMERCIALZONE", UC));
            }

            sqlString += " ORDER BY REFERENTE";
            ContactReferrer.DataSource = DatabaseConnection.SecureCreateDataset(sqlString, par);
            ContactReferrer.DataBind();
        }
Esempio n. 6
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (!Login())
            {
                SomeJS.Text = "<script>opener.location.href=opener.location.href;self.close();</script>";
            }
            else
            {
                string js;

                string control  = Request.QueryString["textbox"].ToString();
                string control2 = Request.QueryString["textbox2"].ToString();

                string clickControl  = null;
                string eventFunction = null;
                if (Request.QueryString["click"] != null)
                {
                    clickControl = Request.QueryString["click"].ToString();
                }
                if (Request.QueryString["event"] != null)
                {
                    eventFunction = Request.QueryString["event"].ToString();
                }

                js  = "<script>";
                js += "function SetRef(id,tx){";
                if (Request.QueryString["frame"] != null)
                {
                    js += "dynaret.SetParams('" + control + "',tx);";
                    js += "dynaret.SetParams('" + control2 + "',id);";
                }
                else
                {
                    js += "dynaret('" + control + "').value=tx;";
                    js += "dynaret('" + control2 + "').value=id;";
                }
                js += "self.close();";
                if (clickControl != null)
                {
                    js += "clickElement(dynaret('" + clickControl + "'));" + Environment.NewLine;
                }
                if (eventFunction != null)
                {
                    js += "dynaevent('" + eventFunction + "');" + Environment.NewLine;
                }
                js         += "parent.HideBox();}";
                js         += "</script>";
                SomeJS.Text = js;
                Find.Text   = Root.rm.GetString("Prftxt5");
                if (!Page.IsPostBack)
                {
                    if (Request.QueryString["sales"] != null)
                    {
                        ViewState["sales"] = Request.QueryString["sales"];
                    }
                    else
                    {
                        ViewState["sales"] = 0;
                    }


                    if (Request.QueryString["Impersonate"] != null)
                    {
                        ContactReferrer.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE ACTIVE=1 AND DIARYACCOUNT LIKE '|%" + UC.UserId + "|%'");
                    }
                    else
                    {
                        string query  = G.GroupDependency(UC.UserGroupId);
                        string qGroup = String.Empty;
                        if (query.Length > 1)
                        {
                            string[] arryD = query.Split('|');
                            foreach (string ut in arryD)
                            {
                                if (ut.Length > 0)
                                {
                                    qGroup += "GROUPID=" + ut + " OR ";
                                }
                            }
                            if (qGroup.Length > 0)
                            {
                                qGroup = qGroup.Substring(0, qGroup.Length - 3);
                            }
                        }
                        else
                        {
                            qGroup = "GROUPID=" + UC.UserGroupId;
                        }
                        if (ViewState["sales"].ToString() == "0")
                        {
                            ContactReferrer.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE ACTIVE=1 AND (" + qGroup + ")");
                        }
                        else
                        {
                            ContactReferrer.DataSource = DatabaseConnection.CreateDataset("SELECT UID,(NAME+' '+SURNAME) AS USERNAME FROM ACCOUNT WHERE ACCESSLEVEL=" + ViewState["sales"] + " AND ACTIVE=1 AND (" + qGroup + ")");
                        }
                    }
                    ContactReferrer.DataBind();
                }
            }
        }
Esempio n. 7
0
        public void Find_Click(object sender, EventArgs e)
        {
            switch (((LinkButton)sender).ID)
            {
            case "Find":
                string sqlString, sqlString2;
                string top      = String.Empty;
                string fullText = String.Empty;
                if (RadioList1.Items[1].Selected)
                {
                    fullText = "%";
                }
                top = "top " + NRes.SelectedValue;


                if (CheckLeads.Checked && CheckContacts.Checked)
                {
                    sqlString  = "SELECT " + top + " BASE_CONTACTS.ID,(BASE_CONTACTS.SURNAME+' '+ISNULL(BASE_CONTACTS.NAME,'')) AS REFERENTE,BASE_COMPANIES.COMPANYNAME, BASE_COMPANIES.ID AS COMPANYID, BASE_CONTACTS.EMAIL, BASE_CONTACTS.SALESPERSONID, BASE_CONTACTS.OWNERID FROM BASE_CONTACTS ";
                    sqlString += "LEFT OUTER JOIN BASE_COMPANIES ON BASE_CONTACTS.COMPANYID = BASE_COMPANIES.ID WHERE BASE_CONTACTS.LIMBO=0 AND (" + GroupsSecure("BASE_CONTACTS.GROUPS") + ") AND (BASE_CONTACTS.NAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.SURNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.PHONE_1 LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.MOBILEPHONE_1 LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%') ";

                    sqlString2  = "SELECT " + top + " CRM_LEADS.ID,(CRM_LEADS.SURNAME+' '+ISNULL(CRM_LEADS.NAME,'')) AS REFERENTE,CRM_LEADS.COMPANYNAME AS COMPANYNAME, CRM_LEADS.COMPANYID, CRM_LEADS.EMAIL, CRM_CROSSLEAD.SALESPERSON AS SALESPERSONID, CRM_LEADS.OWNERID FROM CRM_LEADS INNER JOIN CRM_CROSSLEAD ON CRM_LEADS.ID=CRM_CROSSLEAD.LEADID ";
                    sqlString2 += "WHERE (CRM_LEADS.LIMBO=0 AND ACTIVE=1 AND ((" + GroupsSecure("CRM_LEADS.GROUPS") + ") OR CRM_LEADS.OWNERID=" + UC.UserId + ")) AND (CRM_LEADS.NAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.SURNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.PHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.MOBILEPHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.COMPANYNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%') ";
                    sqlString  += " ORDER BY REFERENTE";
                    sqlString2 += " ORDER BY REFERENTE";
                    if (UC.Zones.Length > 0)
                    {
                        sqlString  += String.Format(" AND ({0})", ZoneSecure("BASE_CONTACTS.COMMERCIALZONE", UC));
                        sqlString2 += String.Format(" AND ({0})", ZoneSecure("BASE_CONTACTS.COMMERCIALZONE", UC));
                    }


                    DataTable contacts = DatabaseConnection.CreateDataset(sqlString).Tables[0];
                    DataTable leads    = DatabaseConnection.CreateDataset(sqlString2).Tables[0];

                    DataTable FinalTb = DataManipulation.Union(contacts, leads);
                    ContactReferrer.DataSource = FinalTb;
                    ContactReferrer.DataBind();
                }
                else if (CheckLeads.Checked)
                {
                    sqlString  = "SELECT " + top + " CRM_LEADS.ID,(CRM_LEADS.SURNAME+' '+ISNULL(CRM_LEADS.NAME,'')) AS REFERENTE,CRM_LEADS.COMPANYNAME, CRM_LEADS.COMPANYID, CRM_LEADS.EMAIL, CRM_CROSSLEAD.SALESPERSON AS SALESPERSONID, CRM_LEADS.OWNERID FROM CRM_LEADS INNER JOIN CRM_CROSSLEAD ON CRM_LEADS.ID=CRM_CROSSLEAD.LEADID ";
                    sqlString += "WHERE (CRM_LEADS.LIMBO=0 AND ACTIVE=1 AND ((" + GroupsSecure("CRM_LEADS.GROUPS") + ") OR CRM_LEADS.OWNERID=" + UC.UserId + ")) AND (CRM_LEADS.NAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.SURNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.PHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.MOBILEPHONE LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR CRM_LEADS.COMPANYNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%') ";
                    if (UC.Zones.Length > 0)
                    {
                        sqlString += String.Format(" AND ({0})", ZoneSecure("BASE_CONTACTS.COMMERCIALZONE", UC));
                    }

                    ContactReferrer.DataSource = DatabaseConnection.CreateDataset(sqlString);
                    ContactReferrer.DataBind();
                }
                else if (CheckContacts.Checked)
                {
                    sqlString  = "SELECT " + top + " BASE_CONTACTS.ID,(BASE_CONTACTS.SURNAME+' '+ISNULL(BASE_CONTACTS.NAME,'')) AS REFERENTE,BASE_COMPANIES.COMPANYNAME, BASE_COMPANIES.ID AS COMPANYID, BASE_CONTACTS.EMAIL, BASE_CONTACTS.SALESPERSONID, BASE_CONTACTS.OWNERID FROM BASE_CONTACTS ";
                    sqlString += "LEFT OUTER JOIN BASE_COMPANIES ON BASE_CONTACTS.COMPANYID = BASE_COMPANIES.ID WHERE BASE_CONTACTS.LIMBO=0 AND (" + GroupsSecure("BASE_CONTACTS.GROUPS") + ") AND (BASE_CONTACTS.NAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.SURNAME LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.PHONE_1 LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%' OR BASE_CONTACTS.MOBILEPHONE_1 LIKE '" + fullText + DatabaseConnection.FilterInjection(FindIt.Text) + "%') ";
                    if (UC.Zones.Length > 0)
                    {
                        sqlString += String.Format(" AND ({0})", ZoneSecure("BASE_CONTACTS.COMMERCIALZONE", UC));
                    }

                    ContactReferrer.DataSource = DatabaseConnection.CreateDataset(sqlString);
                    ContactReferrer.DataBind();
                }
                break;

            case "NewRef":
                Find.Visible            = false;
                FindIt.Visible          = false;
                ContactReferrer.Visible = false;
                NewReferrer.Visible     = true;
                break;
            }
        }