Exemplo n.º 1
0
        private void btnCambiaPassword_Click(object sender, EventArgs e)
        {
            try
            {
                bool ok = false;

                if (!string.IsNullOrWhiteSpace(txtNuovaPassword.Text) && txtNuovaPassword.Text == txtConfermaPassword.Text)
                {
                    string psw = txtNuovaPassword.Text;

                    DataType.ConfigurazioneCorrente confObj = DataType.ConfigurazioneCorrente.Deserialize(Path.Combine(Properties.Settings.Default.DatiVisionePath, "ConfigurazioneCorrente.xml"));

                    if (rbLivelloOperatore.Checked == true)
                    {
                        if (confObj.PswTecnico != psw && confObj.PswCostruttore != psw)
                        {
                            confObj.PswOperatore = psw;
                            ok = true;
                        }
                    }
                    else if (rbLivelloTecnico.Checked == true)
                    {
                        if (confObj.PswOperatore != psw && confObj.PswCostruttore != psw)
                        {
                            confObj.PswTecnico = psw;
                            ok = true;
                        }
                    }
                    else if (rbLivelloCostruttore.Checked == true)
                    {
                        if (confObj.PswOperatore != psw && confObj.PswTecnico != psw)
                        {
                            confObj.PswCostruttore = psw;
                            ok = true;
                        }
                    }

                    if (ok)
                    {
                        DataType.ConfigurazioneCorrente.Serialize(confObj, Path.Combine(Properties.Settings.Default.DatiVisionePath, "ConfigurazioneCorrente.xml"));
                    }
                }

                if (ok)
                {
                    MessageBox.Show(linguaMngr.GetTranslation("MSG_CAMBIO_PSW_OK"), linguaMngr.GetTranslation("MSG_ATTENZIONE"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(linguaMngr.GetTranslation("MSG_CAMBIO_PSW_NON_VALIDO"), linguaMngr.GetTranslation("MSG_ERRORE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.AddException(ex);
            }
        }
Exemplo n.º 2
0
        private void btnFormati_Click(object sender, EventArgs e)
        {
            System.Drawing.Size  sizeTmp     = this.Size;
            System.Drawing.Point locationTmp = this.Location;

            try
            {
                DataType.ConfigurazioneCorrente confObj = DataType.ConfigurazioneCorrente.Deserialize(Path.Combine(Properties.Settings.Default.DatiVisionePath, "ConfigurazioneCorrente.xml"));
                DBL.FormatoManager dbmFormati           = new DBL.FormatoManager(Properties.Settings.Default.ConnectionStringFormati);

                //bool esisteFormato = dbmFormati.EsisteFormato(confObj.IdFormato);  |MP 18-1-19 COMMENTATO
                if (dbmFormati.EsisteFormato(confObj.IdFormato))  //esisteFormato)   |MP 18-1-19 COMMENTATO
                {
                    //bool ok = this.pwdManager.CanOpen(Class.PasswordManager.LivelloPassword.Tecnico, this.linguaMngr);  |MP 18-1-19 COMMENTATO
                    if (this.pwdManager.CanOpen(Class.PasswordManager.LivelloPassword.Tecnico, this.linguaMngr)) //ok)  |MP 18-1-19 COMMENTATO
                    {
                        FormGestioneFormati f = new FormGestioneFormati(this.core, this.plcMacchina, confObj.IdFormato, this.linguaMngr, this.repaintLock);
                        NascondiForm();
                        f.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show(linguaMngr.GetTranslation("MSG_FORMATO_INESISTENTE"), linguaMngr.GetTranslation("MSG_ATTENZIONE"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.AddException(ex);
            }
            finally
            {
                this.Size     = sizeTmp;
                this.Location = locationTmp;
            }
        }
Exemplo n.º 3
0
        public bool CanOpen(LivelloPassword minLevel, DBL.LinguaManager linguaMngr, bool force)
        {
            bool ok = false;

            if (Properties.Settings.Default.UsaPassword || force)
            {
                if (this.lastLivello != LivelloPassword.NN && swTempoLogin.ElapsedMilliseconds < Properties.Settings.Default.TempoPassword * 60 * 1000 && minLevel <= this.lastLivello)
                {
                    ok = minLevel <= this.lastLivello;
                }
                else
                {
                    FormPassword frmPsw = new FormPassword(linguaMngr);

                    if (frmPsw.ShowDialog() == DialogResult.OK)
                    {
                        bool pswTrovata = false;
                        bool livBasso   = true;

                        DataType.ConfigurazioneCorrente confObj = DataType.ConfigurazioneCorrente.Deserialize(Path.Combine(Properties.Settings.Default.DatiVisionePath, "ConfigurazioneCorrente.xml"));

                        string psw = frmPsw.GetPassword();

                        if (psw == confObj.PswCostruttore)
                        {
                            ok          = true;
                            lastLivello = LivelloPassword.Costruttore;
                            swTempoLogin.Restart();

                            pswTrovata = true;
                            livBasso   = false;
                        }

                        if (!ok && psw == confObj.PswTecnico)
                        {
                            if (minLevel <= LivelloPassword.Tecnico)
                            {
                                ok          = true;
                                lastLivello = LivelloPassword.Tecnico;
                                swTempoLogin.Restart();

                                livBasso = false;
                            }

                            pswTrovata = true;
                        }

                        if (!ok && psw == confObj.PswOperatore)
                        {
                            if (minLevel <= LivelloPassword.Operatore)
                            {
                                ok          = true;
                                lastLivello = LivelloPassword.Operatore;
                                swTempoLogin.Restart();

                                livBasso = false;
                            }

                            pswTrovata = true;
                        }

                        if (!pswTrovata)
                        {
                            MessageBox.Show(linguaMngr.GetTranslation("MSG_PSW_ERRATA"), linguaMngr.GetTranslation("MSG_ERRORE"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else if (livBasso)
                        {
                            MessageBox.Show(linguaMngr.GetTranslation("MSG_LIVELLO_PSW_BASSO"), linguaMngr.GetTranslation("MSG_ATTENZIONE"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
            }
            else
            {
                ok = true;
            }

            return(ok);
        }