示例#1
0
        protected void btndel_Click(object sender, EventArgs e)
        {
            if (((SystemDBIsConnected() == false) || Session["DBUserConn"] == null))
            {
                return;
            }

            DataAccess  sys      = GetSystemDB();
            QueryHelper QHS      = sys.GetQueryHelper();
            DataSet     DS       = new vistaForm_virtualuser();
            DataTable   T        = DS.Tables["virtualuser"];
            string      login    = Request.Form["txtlogin"].ToString();
            string      cognome  = Request.Form["txtCognome"].ToString();
            string      nome     = Request.Form["txtNome"].ToString();
            string      cf       = Request.Form["txtCf"].ToString();
            string      coddip   = Request.Form["txtcoddip"].ToString();
            string      custuser = Request.Form["txtcustuser"].ToString();
            string      userkind = Request.Form["userkind"].ToString();



            string filter = QHS.AppAnd(QHS.CmpEq("userkind", userkind), QHS.CmpEq("codicedipartimento", coddip),
                                       QHS.CmpEq("username", login));

            sys.RUN_SELECT_INTO_TABLE(T, null, filter, null, false);

            if (T == null || T.Rows.Count == 0)
            {
                lblError.Text = "Record inesistente";
                return;
            }

            DataRow DR = T.Rows[0];

            DR.Delete();

            PostData PD = new PostData();

            PD.InitClass(DS, sys);

            ProcedureMessageCollection MCOLL = PD.DO_POST_SERVICE();

            if (!MCOLL.CanIgnore)
            {
                lblError.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                return;
            }
            PD.DO_POST_SERVICE();
            lblError.Text = "<p style=\"color: blue;\">Utente '" + login + "' Eliminato.</p>";
            EmptyForm(false);
        }
示例#2
0
        protected void btnadd_Click(object sender, EventArgs e)
        {
            lblError.Text = "";


            if (Request.Form["txtcognome"].ToString() == "")
            {
                lblError.Text = "Inserire il cognome<br/>";
                return;;
            }

            if (Request.Form["txtnome"].ToString() == "")
            {
                lblError.Text = "Inserire il nome<br/>";
                return;
            }
            if (Request.Form["txtcustuser"] == "")
            {
                lblError.Text = "Inserire l'utente applicativo<br/>";
                return;
            }

            if (Request.Form["txtlogin"].ToString() == "")
            {
                lblError.Text = "Inserire la login<br/>";
                return;
            }

            if (Request.Form["txtEmail"].ToString() == "")
            {
                lblError.Text = "Inserire l'email<br/>";
                return;
            }

            DataAccess sys = GetSystemDB();

            DataSet     DS         = new vistaForm_virtualuser();
            string      login      = Request.Form["txtlogin"].ToString();
            string      cognome    = Request.Form["txtCognome"].ToString();
            string      nome       = Request.Form["txtNome"].ToString();
            string      cf         = Request.Form["txtCf"].ToString();
            string      coddip     = Request.Form["txtcoddip"].ToString();
            string      custuser   = Request.Form["txtcustuser"].ToString();
            string      email      = Request.Form["txtEmail"].ToString();
            string      typeofuser = Request.Form["userkind"].ToString();
            QueryHelper QHS        = sys.GetQueryHelper();

            if (custuser == "")
            {
                lblError.Text = "Utente Applicativo non specificato";
                return;
            }

            if (!CustomUserExists(custuser))
            {
                lblError.Text = "L'Utente Applicativo specificato è inesistente";
                return;
            }

            string filter = QHS.AppAnd(QHS.CmpEq("userkind", typeofuser), QHS.CmpEq("codicedipartimento", coddip),
                                       QHS.CmpEq("username", login));
            int numberofrecs = sys.RUN_SELECT_COUNT("virtualuser", filter, false);

            string    query     = "SELECT MAX(idvirtualuser) as maxvalue from virtualuser";
            DataTable RES       = sys.SQLRunner(query);
            int       newkeynum = CfgFn.GetNoNullInt32(RES.Rows[0]["maxvalue"]) + 1;

            DataTable T = DS.Tables["virtualuser"];
            DataRow   DR;

            if (numberofrecs == 0)
            {
                DR = T.NewRow();
                DR["idvirtualuser"] = newkeynum;
            }
            else
            {
                sys.RUN_SELECT_INTO_TABLE(T, null, filter, null, false);
                DR = T.Rows[0];
            }
            DR["username"]           = login;
            DR["codicedipartimento"] = coddip;
            DR["userkind"]           = typeofuser;
            DR["sys_user"]           = custuser;
            DR["surname"]            = cognome;
            DR["forename"]           = nome;
            DR["cf"]    = cf;
            DR["email"] = email;
            if (numberofrecs == 0)
            {
                T.Rows.Add(DR);
            }

            PostData PD = new PostData();

            PD.InitClass(DS, sys);
            ProcedureMessageCollection MCOLL = PD.DO_POST_SERVICE();

            if (!MCOLL.CanIgnore)
            {
                lblError.Text = "Delle regole di sicurezza impediscono l'update del db di sistema!!";
                return;
            }
            MCOLL = PD.DO_POST_SERVICE();
            if (!MCOLL.CanIgnore)
            {
                lblError.Text = "Delle regole di sicurezza hanno impedito l'update del db di sistema!!";
                return;
            }
            if (numberofrecs == 0)
            {
                lblError.Text = "<p style=\"color: blue;text-align: center;\">Utente aggiunto.</p>";
            }
            else
            {
                lblError.Text = "<p style=\"color: blue;text-align: center;\">Utente aggiornato.</p>";
            }
        }