Beispiel #1
0
    protected void cbRegistrati_Click(object sender, EventArgs e)
    {
        id = Session["iduser"] != null?Int32.Parse(Session["iduser"].ToString()) : -1;

        if (id >= 0)
        {
            utente.cercaid(id);                  // mi assicuro di leggere abilitato e pwd (quei dati che non chiedo a video)
        }
        // avvia i controlli
        string er = "";

        if (tNikname.Text.Length < 7 || tNikname.Text.Trim().Length > 24)
        {
            er += "Username con almeno 8 caratteri (max 24); ";
        }
        if (tNome.Text.Length < 2)
        {
            er += "Nome con almeno 3 caratteri; ";
        }
        if (tCognome.Text.Length < 2)
        {
            er += "Cognome con almeno 3 caratteri; ";
        }
        if (tMail1.Text.Length < 6 || (tMail1.Text.IndexOf("@") < 1) || (tMail1.Text.IndexOf(".") < 1))
        {
            er += "E-Mail con almeno 7 caratteri e con il simbolo @ e il simbolo . ; ";
        }
        if (tMail1.Text != tMail2.Text)
        {
            er += "E-Mail e Conferma E-Mail; ";
        }
        //if (tMatricola.Text.Length < 4) er += "Matricola; ";
        if (cbNonPresente.Checked)         // ente non presente    -> può essere che ddlselezionato ma nonpresente = vero!!!!!
        {
            if (tEnte.Text.Trim().Length < 3)
            {
                er += "Ente con almeno 3; ";
            }
        }
        else
        if (ddlEnte.SelectedItem.Text.Trim().Length < 2)
        {
            er += "Ente non selezionato; ";
        }
        if (tIndirizzo.Text.Length < 5)
        {
            er += "Indirizzo con almeno 6 caratteri; ";
        }
        if (tCivico.Text.Trim().Length < 1)
        {
            er += "Civico; ";
        }
        if (tCap.Text.Trim().Length < 5)
        {
            er += "Cap con almeno 6 caratteri; ";
        }
        if (tCitta.Text.Trim().Length < 2)
        {
            er += "Città con almeno 3 caratteri; ";
        }
        if (tTelefono.Text.Trim().Length < 8)
        {
            er += "Telefono con almeno 9 caratteri; ";
        }
        if (tTelefono.Text.IndexOf(" ") > 0)
        {
            er += "Telefono: solo numeri senza spazi; ";
        }
        if (!cbConsenso.Checked)
        {
            er += "Consenso al trattamento: è necessario; ";
        }
        if (cbNonPresente.Checked && tEnte.Text.Trim().Length < 3)
        {
            er += "Ente: con almeno 3 caratteri; ";
        }
        if (!cbNonPresente.Checked && ddlEnte.SelectedItem.Text.Trim().Length < 2)
        {
            er += "Ente: con almeno 2 caratteri; ";
        }
        if (er != "")
        {
            er          = "I valori dei campi indicati sono errati o mancanti: " + er;
            tStato.Text = er;
            return;
        }
        utente.nikname = tNikname.Text.Trim();
        utente.nome    = tNome.Text.Trim();
        utente.cognome = tCognome.Text.Trim();
        utente.mail    = tMail1.Text.Trim();
        //utente.matricola = tMatricola.Text.Trim();
        utente.ente        = cbNonPresente.Checked ? tEnte.Text.Trim() : ddlEnte.SelectedItem.Text.Trim();
        utente.ente_ek     = "";
        utente.tipoente_ek = "";
        Gare gara = new Gare();

        tbl = gara.CercaEnte(null, utente.ente, out msg);
        if (tbl != null && tbl.Rows[0]["tipoente_ek"] != DBNull.Value)
        {
            utente.tipoente_ek = tbl.Rows[0]["tipoente_ek"].ToString().Trim();
        }
        utente.indirizzo = tIndirizzo.Text.Trim();
        utente.civico    = tCivico.Text.Trim();
        utente.cap       = tCap.Text.Trim();
        utente.città     = tCitta.Text.Trim();
        utente.telefono  = tTelefono.Text.Trim();
        utente.scadenza  = DateTime.Now.AddMonths(12);

        // non ci sono errori di inserimento e posso registrare la richiesta o la modifica
        if (id > 0)         // è una modifica
        {
            bool ok = utente.registradatiutente("Modifica anagrafica utente", (Int32)id);
            if (!ok)
            {
                tStato.Text = "Modifiche non apportate. Contattare il servizio assistenza al n. " + Session["assistenza"].ToString();
                return;
            }
            Response.Redirect("menu.aspx?p=" + utente.iduser.ToString().Trim() + "&l=si");
        }
        else
        {   // devo controllare se l'utente c'è già, se no lo registro ed invio mail di richiesta registrazione ed abilitazione
            // poi ritorno alla pagina di default con loggato = no
            DataSet ds = new DataSet();
            SQLClass.SQLc.Parameters.Clear();
            SQLClass.SQLc.Parameters.Add("@nikname", SqlDbType.NVarChar); SQLClass.SQLc.Parameters["@nikname"].Value = System.Convert.ToString(utente.nikname);
            if (SQLClass.getSQLdata("select * from utenti where nikname=@nikname", "utenti", out msg) > 0)
            {
                tStato.Text = "Utente con username " + utente.nikname + " già presente. Accertarsi di non essere già stati registrati o cambiare Username!";
                //ShowPopUpMsg("Utente con username " + utente.nikname + " già presente. Accertarsi di non essere già stati registrati o cambiare Username!");
                return;
            }
            else
            {
                utente.password            = utente.CalcolaPasswordCasuale(8, 3, 3, 3);
                utente.abilitato           = false;
                utente.forzocambiopassword = true;
                utente.giornalizza         = false;
                //utente.ente = (utente.ente);
                if (utente.aggiungiutente())
                {
                    // ok registrazione effettuata. ora manda mail agli amministratori
                    // devo rileggere il record aggiunto per avere l'id
                    if (!utente.cercanikname(utente.nikname, utente.password))
                    {
                        tStato.Text = "Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"];
                        return;
                        //ShowPopUpMsg("Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"]);
                    }

                    Session.Add("Utente", utente.nikname);
                    Session.Add("iduser", utente.iduser);

                    // inoltro mail a tutti gli amministratori

                    msg = "";
                    ds.Clear();
                    tbl = SQLClass.getfromDSet("select id, nikname, nome, cognome, mail, power from utenti where (power >= 50)", "Admin", out msg);
                    if (msg.Trim() != "")
                    {
                        tStato.Text = "Attenzione: problema di connessione. Prego contattare il n. " + (string)Session["assistenza"];
                        return;
                    }
                    int      k = 0, n = tbl.HasErrors ? 0 : tbl.Rows.Count;
                    string[] achisccn = new string[n];
                    string[] achi     = new string[1];
                    achi[0] = utente.mail;

                    for (int i = 0; i < n; i++)
                    {
                        if (tbl.Rows[i]["Mail"] != DBNull.Value)
                        {
                            achisccn[k++] = tbl.Rows[i]["Mail"].ToString();
                        }
                    }
                    if (k == 0)
                    {
                        tStato.Text = "Attenzione: non ci sono amministratori che posso confermare la tua richiesta. Prego contattare il n. " + (string)Session["assistenza"];
                        //ShowPopUpMsg("Attenzione: non ci sono amministratori che posso confermare la tua richiesta. Prego contattare il n. " + (string)Session["assistenza"]);
                    }
                    else
                    {
                        gmail gm = null;
                        gm = new gmail();
                        gm.dachivisualizzato = "Agenzia prov. pre gli Appalti e Contratti";
                        gm.achi      = achi;
                        gm.achiccn   = achisccn;
                        gm.numeritel = "0461-496456";
                        gm.subject   = "Raccolta fabbisogno: richiesta registrazione nuovo utente";
                        gm.body      = "Buongiorno,\n";
                        gm.body     += "\tla informaiamo che la sua domanda di registrazione all'applicazione web\n";
                        gm.body     += "per la presentazione delle richieste di gara per le quali s'intende avvalersi\n";
                        gm.body     += "dei servizi offerti da APAC è stata inoltrata correttamente.\n";
                        gm.body     += "\n\nI dati inseriti sono:\n";
                        gm.body     += "Username:          \t" + utente.nikname + "\n";
                        gm.body     += "Nome:              \t" + utente.nome + "\n";
                        gm.body     += "Cognome:           \t" + utente.cognome + "\n";
                        gm.body     += "Mail:              \t" + utente.mail + "\n";
                        gm.body     += "Tel.:              \t" + utente.telefono + "\n\n\n";
                        gm.body     += "Dopo l'approvazione, riceverà automaticamente la mail con le credenziali per il primo accesso.\n\n";
                        gm.body     += "Cordiali saluti.\n";
                        if (!gm.mandamail("", 0, "", "", out msg))
                        {
                            tStato.Text = "Richiesta di registrazione non eseguita! MAIL DI CONFERMA NON INOLTRATA!. CONTATTARE IL NUMERO " + (string)Session["assistenza"] + " Err: " + msg;
                            //ShowPopUpMsg("Richiesta di registrazione effettuata con successo, MAIL DI CONFERMA NON INOLTRATA!. CONTATTARE IL NUMERO " + (string)Session["assistenza"] + " Err: " + msg);
                        }
                        else
                        {
                            tStato.Text          = "Richiesta di registrazione effettuata con successo. Riceverà via email le credenziali per l'accesso.";
                            cbRegistrati.Enabled = false;
                            //ShowPopUpMsg("Richiesta di registrazione effettuata con successo. Riceverà, entro 24 ore via email, le credenziali per l'accesso.");
                        }
                    }
                }
                else
                {
                    tStato.Text = "Richiesta di registrazione non andata a buon fine. Prego contattare l'assistenza al n. " + (string)Session["assistenza"];
                }
            }
        }
    }
Beispiel #2
0
    protected void initChartCollection()
    {
        DateTime dada = DateTime.Now, ada = DateTime.Now;

        switch (rblist.SelectedValue)
        {
        case "Oggi": dada = DateTime.Now; ada = DateTime.Now; titolo = "Accessi di oggi"; break;

        case "Ultima settimana":
            ada = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek - 1 + 1)); dada = DateTime.Now.AddDays(-((int)DateTime.Now.DayOfWeek - 1 + 7)); titolo = "Accessi ultima settimana";
            break;

        case "Ultimo mese":
            ada = DateTime.Now; dada = DateTime.Now.AddDays(-(DateTime.Now.Day - 1)); titolo = "Accessi ultimo mese";
            break;

        case "Da inizio anno":
            ada = DateTime.Now; dada = DateTime.Now.AddDays(-(DateTime.Now.DayOfYear - 1)); titolo = "Accessi da inizio anno";
            break;

        case "Anno precedente":
            ada    = new DateTime(DateTime.Now.Year - 1, 12, 31);
            dada   = new DateTime(DateTime.Now.Year - 1, 1, 1);
            titolo = "Accessi anno precedente";
            break;
        }

        //string dadata = "", adata = "";
        tStato.Text = "";

        //dadata = (da == null || da.ToShortDateString() == "1900-01-01") ? DateTime.Now.ToString(formatodata) : da.ToString(formatodata);
        //adata = (a == null || a.ToShortDateString() == "1900-01-01") ? DateTime.Now.ToString(formatodata) : a.ToString(formatodata);
        sqlfiltro = " CAST (a.voraentrata as date) BETWEEN (DATE '" + dada.ToString(formatodata) + "') and ( DATE '" + ada.ToString(formatodata) + "' )";
        Giornaliera.Titles.Clear();
        switch (rblTipo.SelectedValue)
        {
        case "Numero registrazioni per SEDE":
            sqlstr  = "SELECT count(a.IDVISITA) as Visite, b.SSEDE as Sede FROM ACCESSI as a left join sedi as b on a.VSEDE_EK=b.SID where " + sqlfiltro + " group by b.ssede";
            sqlstr  = "SELECT count(a.IDVISITA) as Registrazioni, coalesce(sum(vgruppo),0) as accompagnati, (count(idVisita) + coalesce(sum(vgruppo),0)) as Visite , b.SSEDE as Sede FROM ACCESSI as a left join ";
            sqlstr += "sedi as b on a.VSEDE_EK = b.SID where " + sqlfiltro + " group by b.ssede";
            break;

        case "Numero registrazioni per orario":
            //sqlstr = "SELECT  count (a.IDVISITA) as Registrazioni, (count(idVisita) + sum(vgruppo)) as Visite, extract ( hour from a.VORAENTRATA ) as ore FROM ACCESSI a where " + sqlfiltro + " group by ore having extract(hour from a.VORAENTRATA ) >= 7 and extract (hour from a.VORAENTRATA ) <= 19";
            sqlstr  = "SELECT  count (a.IDVISITA) as Registrazioni, (count(idVisita) + coalesce(sum(vgruppo),0)) as Visite, extract ( hour from a.VORAENTRATA ) as dalleore, ";
            sqlstr += "(extract(hour from a.voraentrata ) || ' - ' || cast(extract(hour from a.voraentrata ) + 1 as varchar(2))) as labelx FROM ACCESSI a where ";
            sqlstr += sqlfiltro + " group by dalleore having extract(hour from a.VORAENTRATA ) >= 7 and extract (hour from a.VORAENTRATA ) <= 19 ";
            //sqlstr += "order by mese";
            break;

        case "Numero registrazioni per mese":
            sqlstr  = "SELECT  count (a.IDVISITA) as Registrazioni, sum(vgruppo), (count(idVisita) + coalesce(sum(vgruppo), 0)) as Visite, ";
            sqlstr += "trim(iif(EXTRACT(MONTH FROM a.VORAENTRATA) > 9, '', '0') || EXTRACT(MONTH FROM a.VORAENTRATA)) || '-' || cast(extract(year from a.VORAENTRATA) as varchar(4)) as mese ";
            sqlstr += "FROM ACCESSI a where " + sqlfiltro + " group by extract(year from a.VORAENTRATA), mese ";
            sqlstr += "order by extract(year from a.VORAENTRATA), mese ";
            break;
        }
        tTitolo.Text    = "Rilevazione accessi a partire dal " + dada.ToString("dd-MM-yyyy") + " sino al " + ada.ToString("dd-MM-yyyy");
        tTitolo.Enabled = false;
        SqlCommand cmd = new SqlCommand();

        try
        {
            SQLClass.openaSQLConn(out msg);
            if (SQLClass.SQLConn.State != ConnectionState.Open)
            {
                SQLClass.closeaSQLConn(out msg);
                SQLClass.openaSQLConn(out msg);
            }
            SqlDataReader reader = cmd.ExecuteReader();
        }
        catch (Exception ex)
        {
            tStato.Text = string.Format("ERRORE: non è possibile leggere la tabella ACCESSI E SEDI. {0}", ex.Message);
            return;
        }

        long rr = SQLClass.getSQLdata(sqlstr, "AccessiXSedi", out msg);

        //tStato.Text = string.Format("Numero sedi attive in data {0} : {1}", Data.ToShortDateString(), rr);

        if (ds.Tables["AccessiXSedi"].Rows.Count > 0 && rblTipo.SelectedValue == "Numero registrazioni per SEDE")
        {
            Giornaliera.Series.Clear();
            Giornaliera.DataSource = ds.Tables["AccessiXSedi"];
            Giornaliera.Titles.Add(titolo).Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.Series.Add("Serie Sedi");
            Giornaliera.Series["Serie Sedi"].BorderWidth = 1;
            Giornaliera.Series["Serie Sedi"].ChartType   = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font            = new System.Drawing.Font("Verdana", 7);
            Giornaliera.ChartAreas["ChartArea1"].AxisX.Interval                   = 1;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit             = false;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.TruncatedLabels = false;
            Giornaliera.ChartAreas["ChartArea1"].BackColor          = System.Drawing.Color.FromName("AliceBlue");
            Giornaliera.ChartAreas["ChartArea1"].BackSecondaryColor = System.Drawing.Color.FromName("Red");
            Giornaliera.ChartAreas["ChartArea1"].BackGradientStyle  = System.Web.UI.DataVisualization.Charting.GradientStyle.TopBottom;
            Giornaliera.Series["Serie Sedi"].XValueMember           = "Sede";
            Giornaliera.Series["Serie Sedi"].AxisLabel = "Sede";
            Giornaliera.Series["Serie Sedi"].Color     = System.Drawing.Color.FromName("RoyalBlue");
            Giornaliera.ChartAreas["ChartArea1"].AxisY.LabelStyle.TruncatedLabels = false;
            Giornaliera.Series["Serie Sedi"].YValueMembers       = "Visite";
            Giornaliera.Series["Serie Sedi"].IsValueShownAsLabel = true;
            Giornaliera.Series["Serie Sedi"].Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["Serie Sedi"].
            Giornaliera.ChartAreas["ChartArea1"].AxisY2.Enabled = new System.Web.UI.DataVisualization.Charting.AxisEnabled();
            //Giornaliera.Series["Serie Sedi"].Label = Giornaliera.Series["Serie Sedi"].YValueMembers;
            Giornaliera.DataBind();
        }
        if (ds.Tables["AccessiXSedi"].Rows.Count > 0 && rblTipo.SelectedValue == "Numero registrazioni per orario")
        {
            Giornaliera.Series.Clear();
            Giornaliera.DataSource = ds.Tables["AccessiXSedi"];
            Giornaliera.Titles.Add(titolo).Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.Series.Add("Serie Ore");
            Giornaliera.Series["Serie Ore"].BorderWidth = 1;
            Giornaliera.Series["Serie Ore"].ChartType   = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font            = new System.Drawing.Font("Verdana", 7);
            Giornaliera.ChartAreas["ChartArea1"].AxisX.Interval                   = 1;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit             = false;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.TruncatedLabels = false;
            Giornaliera.ChartAreas["ChartArea1"].BackColor          = System.Drawing.Color.FromName("Bisque");
            Giornaliera.ChartAreas["ChartArea1"].BackSecondaryColor = System.Drawing.Color.FromName("Red");
            Giornaliera.ChartAreas["ChartArea1"].BackGradientStyle  = System.Web.UI.DataVisualization.Charting.GradientStyle.TopBottom;
            Giornaliera.Series["Serie Ore"].XValueMember            = "labelx";
            Giornaliera.Series["Serie Ore"].AxisLabel = "labelx";
            Giornaliera.Series["Serie Ore"].Color     = System.Drawing.Color.FromName("Coral");
            Giornaliera.ChartAreas["ChartArea1"].AxisY.LabelStyle.TruncatedLabels = false;
            Giornaliera.Series["Serie Ore"].YValueMembers       = "Visite";
            Giornaliera.Series["Serie Ore"].IsValueShownAsLabel = true;
            Giornaliera.Series["Serie Ore"].Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["Serie Sedi"].
            Giornaliera.ChartAreas["ChartArea1"].AxisY2.Enabled = new System.Web.UI.DataVisualization.Charting.AxisEnabled();
            //Giornaliera.Series["Serie Sedi"].Label = Giornaliera.Series["Serie Sedi"].YValueMembers;
            Giornaliera.DataBind();
        }
        if (ds.Tables["AccessiXSedi"].Rows.Count > 0 && rblTipo.SelectedValue == "Numero registrazioni per mese")
        {
            Giornaliera.Series.Clear();
            Giornaliera.DataSource = ds.Tables["AccessiXSedi"];
            Giornaliera.Titles.Add(titolo).Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.Series.Add("Serie Mesi");
            Giornaliera.Series["Serie Mesi"].BorderWidth = 1;
            Giornaliera.Series["Serie Mesi"].ChartType   = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.Font            = new System.Drawing.Font("Verdana", 7);
            Giornaliera.ChartAreas["ChartArea1"].AxisX.Interval                   = 1;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.IsLabelAutoFit             = false;
            Giornaliera.ChartAreas["ChartArea1"].AxisX.LabelStyle.TruncatedLabels = false;
            Giornaliera.ChartAreas["ChartArea1"].BackColor          = System.Drawing.Color.FromName("Azure");
            Giornaliera.ChartAreas["ChartArea1"].BackSecondaryColor = System.Drawing.Color.FromName("Red");
            Giornaliera.ChartAreas["ChartArea1"].BackGradientStyle  = System.Web.UI.DataVisualization.Charting.GradientStyle.TopBottom;
            Giornaliera.Series["Serie Mesi"].XValueMember           = "Mese";
            Giornaliera.Series["Serie Mesi"].AxisLabel = "Mese";
            Giornaliera.Series["Serie Mesi"].Color     = System.Drawing.Color.FromName("LightGoldenrodYellow");
            Giornaliera.ChartAreas["ChartArea1"].AxisY.LabelStyle.TruncatedLabels = false;
            Giornaliera.Series["Serie Mesi"].YValueMembers       = "Visite";
            Giornaliera.Series["Serie Mesi"].IsValueShownAsLabel = true;
            Giornaliera.Series["Serie Mesi"].Font = new System.Drawing.Font("Thaoma", 12);
            Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            //Giornaliera.ChartAreas["Serie Sedi"].
            Giornaliera.ChartAreas["ChartArea1"].AxisY2.Enabled = new System.Web.UI.DataVisualization.Charting.AxisEnabled();
            //Giornaliera.Series["Serie Sedi"].Label = Giornaliera.Series["Serie Sedi"].YValueMembers;
            Giornaliera.DataBind();
        }
        SQLClass.closeaSQLConn(out msg);
    }