Esempio n. 1
0
        protected void SubmitHome_Click(object sender, System.EventArgs e)
        {
            uploadTable upTable = new uploadTable();
            usersTable  user    = (usersTable)Session["utenteAutenticato"];

            //Controllo File nullo e notifica
            if (File_UP.PostedFile.FileName == "")
            {
                Response.Write("File non caricato correttamente; Data di caricamento: " + DateTime.Now.ToString("dd/MM/yyyy"));
            }
            else
            {
                //Creazione Directory -- "C:\\Users\\pc\\Desktop\\caricamenti" --
                if (!Directory.Exists(saveLocation + "\\" + user.id))
                {
                    Directory.CreateDirectory(saveLocation + "\\" + user.id);
                }



                Response.Write(File_UP.PostedFile.FileName + "; Data di caricamento: " + DateTime.Now.ToString("dd/MM/yyyy"));

                File_UP.PostedFile.SaveAs(saveLocation + "\\" + user.id + "\\" + File_UP.PostedFile.FileName);

                SmartInfoUploadEntities uploadEntities = new SmartInfoUploadEntities();

                //if(upTable.nome_file == File_UP.PostedFile.FileName)
                //Query per confrontare Nome del file caricato e ID dell'utente che esegue l'upload
                if (uploadEntities.uploadTable.Where((X) =>
                                                     X.nome_file == File_UP.PostedFile.FileName &&
                                                     X.id_cliente == user.id) == null)
                {
                    //Carico dati in upTable
                    upTable.id_cliente = user.id;
                    upTable.nome_file  = File_UP.PostedFile.FileName;
                    uploadEntities.uploadTable.Add(upTable);
                }
                else
                {
                    upTable.data_caricamento = DateTime.Now;
                }

                uploadEntities.SaveChanges();
            }
        }
Esempio n. 2
0
        protected void submitSignInButton_Click(object sender, EventArgs e)
        {
            if ((username.Text.Length <= 3) || (password.Text.Length <= 3) || (username.Text.Length >= 25) || (username.Text.Length >= 25))
            {
                Response.Write("Username o Password troppo lunghe");
            }

            //INSERIMENTO USER / PASS SUL DB
            SmartInfoUploadEntities db = new SmartInfoUploadEntities();

            usersTable usersTb = new usersTable(); //= db.usersTable.Select((X) => X.username == username.Text && X.password == password.Text).FirstOrDefault();

            usersTb.username = username.Text;
            usersTb.password = password.Text;
            db.usersTable.Add(usersTb);
            db.SaveChanges();
            Response.Redirect("Login.aspx");
        }
Esempio n. 3
0
        /*protected void Page_Load(object sender, EventArgs e)
         * {
         *  string user = username.Text;
         * }
         */

        protected void submitButton_Click(object sender, EventArgs e)
        {
            //PULIZIA STRINGHE

            /*
             * char[] charToTrim = { '@', '#', ' ', '.', ',', ';', '-', '+', '_', '?', '!', '&', '%', 'è', 'ò', 'à', 'ù', '+', '*', '[', ']', '{', '}' };
             * string user = username.Text.Trim(charToTrim);
             * string pass = password.Text.Trim(charToTrim);
             */



            //CONTROLLO USER / PASS PRESENTI SUL DB
            SmartInfoUploadEntities db = new SmartInfoUploadEntities();

            usersTable usersTb = db.usersTable.Where((X) => X.username == username.Text && X.password == password.Text).FirstOrDefault();

            //GESTIONE LOGIN - REDIRECT
            Session["utenteAutenticato"] = usersTb;
            if (usersTb != null)
            {
                Response.Redirect("Home.aspx");
            }
        }