Exemplo n.º 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                labMsg.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    labMsg.Text += error;
                }
                return;
            }
            if (Session["pwd_system"] != null)
            {
                LabelPasswordCfg.Visible = false;
            }
            // Put user code to initialize the page here
            if (IsPostBack)
            {
                string pwdsys = Request.Form["txtPwdSystem"].ToString();
                if (Session["pwd_system"] == null)
                {
                    if (pwdsys != "web report fc-hires")
                    {
                        labMsg.Text = "Password di sistema non accettata.";
                        return;
                    }
                    Session["pwd_system"] = "1";
                }
                string          dip    = txtDip.Text;
                string          codice = txtCodice.Text;
                string          ip     = txtIP.Text;
                string          db     = txtDB.Text;
                string          user   = txtUser.Text;
                string          pwd    = Request.Form["txtPWD"].ToString();
                Easy_DataAccess Conn   = new Easy_DataAccess(
                    "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);
                if (Conn == null)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Open();
                if (Conn.OpenError)
                {
                    labMsg.Text = "Non è stato possibile collegarsi al server.";
                    return;
                }
                Conn.Close();
                DataSet     DS        = new Dipartimenti();
                QueryHelper QHS       = sys.GetQueryHelper();
                string      searchdip = QHS.CmpEq("CodiceDipartimento", codice);
                if (sys.RUN_SELECT_COUNT("CodiciDipartimenti", searchdip, true) > 0)
                {
                    labMsg.Text = "Codice dipartimento già esistente, sarà aggiornato.";
                    DataTable T = DS.Tables[0];
                    sys.RUN_SELECT_INTO_TABLE(T, null, searchdip, null, false);
                    DataRow R = T.Rows[0];
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                }
                else
                {
                    DataTable T = DS.Tables[0];
                    DataRow   R = T.NewRow();
                    R["CodiceDipartimento"] = codice;
                    R["dipartimento"]       = dip;
                    R["IPserver"]           = GetVars.CryptPassword(ip);
                    R["NomeDB"]             = GetVars.CryptPassword(db);
                    R["UserDB"]             = GetVars.CryptPassword(user);
                    R["PassDB"]             = GetVars.CryptPassword(pwd);
                    T.Rows.Add(R);
                }
                PostData CP = new PostData();
                CP.InitClass(DS, sys);
                ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();
                if (!MCOLL.CanIgnore)
                {
                    labMsg.Text = "Delle regole di sicurezza impediscono l'update del db di sistema!!";
                    return;
                }

                if (MCOLL.Count > 0)
                {
                    MCOLL = CP.DO_POST_SERVICE();
                    if (!MCOLL.CanIgnore)
                    {
                        labMsg.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                        return;
                    }
                }

                labMsg.Text = "DB DI SISTEMA Aggiornato correttamente.";
            }
        }
Exemplo n.º 2
0
        protected void brnAdd_Click(object sender, EventArgs e)
        {
            if (Session["SysPasswordOk"] == null)
            {
                lblmessages.Text =
                    "Prima di procedere alla configurazione, inserire la Password di abilitazione alla configurazione.";
                return;
            }
            string     error = "";
            DataAccess sys   = GetVars.GetSystemDataAccess(this, out error);

            if (sys == null)
            {
                lblmessages.Text = "Servizio Web non installato correttamente.";
                if (error != null)
                {
                    lblmessages.Text += error;
                }
                return;
            }

            string          dip    = txtDip.Text;
            string          codice = txtCodice.Text;
            string          ip     = txtIP.Text;
            string          db     = txtDB.Text;
            string          user   = txtUser.Text;
            string          pwd    = txtPWD.Text;
            Easy_DataAccess Conn   = new Easy_DataAccess(
                "mydsn", ip, db, user, pwd, user, pwd, DateTime.Now.Year, DateTime.Now);

            if (Conn == null)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Open();
            if (Conn.OpenError)
            {
                lblmessages.Text = "Non è stato possibile collegarsi al server.";
                return;
            }
            Conn.Close();
            DataSet DS = new Dipartimenti();

            if (sys.RUN_SELECT_COUNT("CodiciDipartimenti",
                                     "(CodiceDipartimento=" +
                                     QueryCreator.quotedstrvalue(codice, true) + ")", true) > 0)
            {
                lblmessages.Text = "Codice dipartimento già esistente.";
                return;
            }
            DataTable T = DS.Tables[0];
            DataRow   R = T.NewRow();

            R["CodiceDipartimento"] = codice;
            R["dipartimento"]       = dip;
            R["IPserver"]           = GetVars.CryptPassword(ip);
            R["NomeDB"]             = GetVars.CryptPassword(db);
            R["UserDB"]             = GetVars.CryptPassword(user);
            R["PassDB"]             = GetVars.CryptPassword(pwd);
            T.Rows.Add(R);
            PostData CP = new PostData();

            CP.InitClass(DS, sys);

            ProcedureMessageCollection MCOLL = CP.DO_POST_SERVICE();

            if (!MCOLL.CanIgnore)
            {
                lblmessages.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                return;
            }
            else
            {
                if (MCOLL.Count > 0)
                {
                    CP.DO_POST_SERVICE();
                }
            }


            lblmessages.Text = "DB DI SISTEMA Aggiornato correttamente.";
        }