Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 14

Discussione: Controlli per debug

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    708

    Controlli per debug

    Ciao a tutti

    non so quasi nulle di asp.net xrò sino ad ora riuscivo a fare delle modifiche con successo.

    Ho una pagina aspx, funzionante, x l'inserimento dati in db access. Vorrei modificare questa pagina x far inserire i dati in un'altra tabella ma le mie modifiche non funzionano xchè non scrive nel db.

    Visto che non mi da nessun errore, vorrei chiedervi se potete aiutarmi ad inserire dei controlli x vedere se scrive nel db.
    Ad es. l'equivalente di asp:

    Response.Write Sql

    com'è in asp.net?

  2. #2
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116

    Re: Controlli per debug

    Originariamente inviato da Pierhagi
    Ciao a tutti

    non so quasi nulle di asp.net xrò sino ad ora riuscivo a fare delle modifiche con successo.

    Ho una pagina aspx, funzionante, x l'inserimento dati in db access. Vorrei modificare questa pagina x far inserire i dati in un'altra tabella ma le mie modifiche non funzionano xchè non scrive nel db.

    Visto che non mi da nessun errore, vorrei chiedervi se potete aiutarmi ad inserire dei controlli x vedere se scrive nel db.
    Ad es. l'equivalente di asp:

    Response.Write Sql

    com'è in asp.net?

    dipende dal linguaggio; in basic è:

    Response.Write(sql)
    Pietro

  3. #3
    Moderatore di ASP.net L'avatar di djciko
    Registrato dal
    Nov 2002
    Messaggi
    6,887
    Metti il blocco di codice in un costrutto Try Catch:

    codice:
    Try
      ..codice per inserimento
    Catch ex as Exception
      Response.Write(ex.message)
    End Try
    E' la prassi standard per i pezzi di codice che accedono al DB.
    Inoltre prova la query anche direttamente su access...

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    708
    Ciao e grazie x le risposte!

    ...cmq non riesco a farlo funzionare!

    Pietro devono essere file fatti da te se non ricordo male... è un upload resize img.

    Cmq nel codice sotto ci sono 2 Response.Write che non riesco a visualizzare. Potete modifircarli x vedere quale quale campo non fa scrivere nel db?


    string sqlString = "INSERT INTO [TabArticolo] (NOME, CODICE_CATEGORIA, CODICE_LINGUA) VALUES ('" + (imgDestFolder() + fileName) + "', '" + (tbnDestFolder() + fileName) + "', '" + nome + "', '" + codice_categoria + "', '" + codice_lingua + "');";

    using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connString))
    {
    conn.Open();
    System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sqlString, conn);
    try
    {
    cmd.ExecuteNonQuery();
    Response.Write("
    Si è Codice inserito correttamente!
    ");
    Status.Text += "<span style=\"color:Green;\">File '" + fileName + "' Inserito correttamente. Ok!
    </span>";
    }
    catch (Exception ex)
    {
    Response.Write("
    Si &egrave; verificato un errore durante l'esecuzione dello script SQL corrente.
    ");
    Status.Text += "<span style=\"color:Red;\">Errore : " + ex.Message + "</span>
    ";
    }
    finally
    {
    conn.Close();
    }
    } // using (OleDbConnection conn = new OleDbConnection(connString))
    // Fine codice per inserimento nel DataBase

  5. #5
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    il codice di sotto va sicuramente in errore perchè l'istruzione sql non è valida, ma almeno fa vedere l'errore

    codice:
    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
        protected void Button1_Click(object sender, EventArgs e)
        {
            OleDbConnection connessione = null;
            OleDbCommand comando = null;
            string sql = "";
            
            try
            {
                connessione = new OleDbConnection(gl.StringaConnessione);
                connessione.Open();
                comando = connessione.CreateCommand();
                sql = "";
                comando.CommandText = sql;
    
                comando.ExecuteNonQuery();
                
                
            }
            catch (Exception ex)
            {
                this.LabelErrore.Text = HttpContext.Current.Server.HtmlEncode(ex.Message).Replace("\r\n", "
    ").Replace("\n", "
    ").Replace("\r", "
    ");
            }
            finally
            {
                if (connessione != null) connessione.Close();
            }
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
            <hr />
            <asp:Label ID="LabelErrore" runat="server" Text="" EnableViewState="false"></asp:Label>
        </div>
        </form>
    </body>
    </html>
    Pietro

  6. #6

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    708
    Ragazzi non sono in grado!

    Inserndo:

    Response.Write("Verifica:" + sqlString + "
    ");
    Response.Flush();

    ho visto che mi da problemi sul redirect...che tralatro è sullo stesso file.

    Posso spedirvi il mio file visto che incollarlo qui non ci sta?

  8. #8
    Moderatore di ASP.net L'avatar di djciko
    Registrato dal
    Nov 2002
    Messaggi
    6,887
    Originariamente inviato da Pierhagi
    Posso spedirvi il mio file visto che incollarlo qui non ci sta?
    No, meglio lavorare sul forum.
    In che senso "non ci sta" ?

    ps: ricordati dei tag CODE per il codice

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    708
    Mi spiace x la lunghezza!
    Divido il cs in 3 parti... così ci sta!

    codice:
     void Page_Load(object sender, System.EventArgs e)
      {
       titletext2.Text =  "INSERISCI ARTICOLO";
       Status.Text += "";
      
      string dbconn, sql_grand, sql, sql2, sql_categoria, sql_categoria2, dbcomm, dbread;// sql_on_line
      OleDbConnection connDB;
      OleDbCommand cmd; 
      OleDbDataReader aReader;
      
      OleDbCommand cmd2; 
      OleDbDataReader aReader2;
    
      OleDbCommand cmd_categoria; 
      OleDbDataReader aReader_categoria;
      
      OleDbCommand cmd_categoria2; 
      OleDbDataReader aReader_categoria2;
    
      string connString = ConfigurationSettings.AppSettings["dbConnString"]; 
      connDB = new OleDbConnection(connString);
      connDB.Open();
    	
      sql_categoria = "SELECT DISTINCT CODICE_CATEGORIA FROM TabCategoria ORDER BY CODICE_CATEGORIA";
      cmd_categoria = new OleDbCommand(sql_categoria, connDB);
      aReader_categoria = cmd_categoria.ExecuteReader();
      if (!Page.IsPostBack) 
      {
      ArrayList values = new ArrayList();
      try
      {
      	values.Add("");
        while (aReader_categoria.Read()) 
        {
          values.Add(aReader_categoria[0]);
        }
        codice_categoria.DataSource = values;
        codice_categoria.DataBind();
      } 
      finally
      {
        aReader_categoria.Close();
      }
     	}
      sql_categoria2 = "SELECT DISTINCT CODICE_CATEGORIA FROM TabCategoria ORDER BY CODICE_CATEGORIA";
      cmd_categoria2 = new OleDbCommand(sql_categoria2, connDB);
      aReader_categoria2 = cmd_categoria2.ExecuteReader();
      if (!Page.IsPostBack) 
      {
      ArrayList values = new ArrayList();
      try
      {
      	values.Add("");
        while (aReader_categoria2.Read()) 
        {
         values.Add(aReader_categoria2[0]);
        }
    
    correlati.DataSource = values;
    correlati.DataBind();
      }
      finally
      {
        aReader_categoria2.Close();
      }
    }
      sql2 = "SELECT DISTINCT CODICE_LINGUA FROM TabLingua ORDER BY CODICE_LINGUA";
      cmd2 = new OleDbCommand(sql2, connDB);
      aReader2 = cmd2.ExecuteReader();
      if (!Page.IsPostBack) 
      {
      ArrayList language_values = new ArrayList();
      try
      {
      language_values.Add("");
      while (aReader2.Read()) 
        {
          language_values.Add(aReader2[0]);
        }
        codice_lingua.DataSource = language_values;
        codice_lingua.DataBind();
      }
      finally
      {
        aReader2.Close();
        connDB.Close();
      }    
      }  
      }
     bool IsImage(string fileName)
     {
      string ext = Path.GetExtension(fileName).ToLower();
      bool imageFlag = false;
    
      if (ext != null)
       {
        switch (ext)
         {
          case ".emf" :
          case ".exif" :
          case ".ico" :
          case ".wmf" :
          case ".png" :
          case ".gif" :
          case ".bmp" :
          case ".tiff" :
          case ".tif" :
          case ".jpeg" : 
          case ".jpg" : imageFlag = true; break;
    
          default: imageFlag = false; break;
         }
       } 
      else
       imageFlag = false;
    
      return imageFlag;
     }
     void CalcolaAspectRatio_BestFit(double orgWidth, double orgHeight, ref double newWidth, ref double newHeight)
      {
       if ((orgWidth == newWidth) && (orgHeight == newHeight)) return;
    
       if ((newWidth > orgWidth) && (newHeight > orgHeight)) 
        {
         newWidth = orgWidth;
    	 newHeight = orgHeight;
    	 return;   
    	}
       double aw = orgWidth / orgHeight;
       double ah = orgHeight / orgWidth;
    
       double resw = aw * newHeight;
       double resh = ah * newWidth;
    
       if (resw > newWidth) 
        { 
    	 resw = newWidth;
    	 resh = ah * resw;
    	}
       if (resh > newHeight) 
        { 
    	 resh = newHeight;
    	 resw = aw * resh;
    	}
       newWidth = resw;
       newHeight = resh;
      }
     void CalcolaAspectRatio_Biggest(double orgWidth, double orgHeight, ref double newWidth, ref double newHeight)
      {
       if ((orgWidth == newWidth) && (orgHeight == newHeight)) return;
    
       if ((newWidth > orgWidth) && (newHeight > orgHeight)) 
        {
         newWidth = orgWidth;
    	 newHeight = orgHeight;
    	 return;   
    	}
       double resw = newWidth;
       double resh = newHeight;
       
       double aw = orgWidth / orgHeight;
       double ah = orgHeight / orgWidth;
       if (resw > orgWidth) resw = orgWidth;
       if (resh > orgHeight) resh = orgHeight;
       if (orgWidth != orgHeight)
    	{
    	 if (orgWidth > orgHeight)
    	  {
    	   resw = resw;
    	   resh = ah * resw;
    	  } 
    	 else
    	  {
    	   if (orgWidth < orgHeight)
    		{
    		 resh = resh;
    		 resw = aw * resh;
    		}
    	  } 
    	}
       newWidth = resw;
       newHeight = resh;
     } 
    string giveMeANewName(string orgName, string pathToCheck)
     {
      bool exit = false;
      string path = pathToCheck + "/";
      string fileName = Path.GetFileNameWithoutExtension(orgName);
      string ext = Path.GetExtension(orgName).ToLower();
      int count = 0;
      string newFileName = "";
      
      path = (path.Replace("\\", "/")).Replace("//", "/");
      path = Server.MapPath(path);
      
      do
       {
        newFileName = fileName + count + ext;
        
    	if (!File.Exists(path + newFileName)) exit = true;
    
    	count ++;
       } while(!exit);
      
      return (newFileName);
     } 
     
    string ResizeAnUploadedImage(HttpPostedFile file, double newWidth, double newHeight, string virPath, bool overwrite)
      {
       string destPath = ".";
       double resWidth = 1.0;
       double resHeight = 1.0;
       bool owr = false;
       bool exist = false;
    
       if (virPath != "") destPath = virPath;
       if (newWidth > 0) resWidth = newWidth;
       if (newHeight > 0) resHeight = newHeight;
       
       if (overwrite)
        owr = true;
       else
        owr = false;
    	
       int pathCheck = (destPath.Substring(destPath.LastIndexOf('/') + 1)).Length;
       if (pathCheck > 0) destPath += "/";
    
       string fileName = Path.GetFileName(file.FileName);
       string estensione = Path.GetExtension(file.FileName).ToLower();
    
       ImageCodecInfo[] imgCodec = ImageCodecInfo.GetImageEncoders();
       EncoderParameters encPars = new EncoderParameters(2);
       EncoderParameter encPar1 = new EncoderParameter( System.Drawing.Imaging.Encoder.Quality, 100L );
       EncoderParameter encPar2 = new EncoderParameter( System.Drawing.Imaging.Encoder.Compression, 100L );
       
       encPars.Param[0] = encPar1;
       encPars.Param[1] = encPar2;
    
       destPath = Server.MapPath(destPath);
       exist = File.Exists(destPath + fileName);
       
       if (!owr && exist) 
        {
    	 fileName = giveMeANewName(file.FileName, virPath);
    	 exist = false;
    	}
       
       if (!exist && (fileName.Length != 0) || owr)
        {
         if (!IsImage(fileName))
          {
           if (fileName.Length != 0)
             Status.Text += "<span style=\"color:Red;\">File '" + fileName + "' is not a valid image format. Upload... Aborted.</span>
    ";
           return ("");
          }
    	  using(System.Drawing.Image image = System.Drawing.Image.FromStream(file.InputStream))
          {
    	   CalcolaAspectRatio_Biggest(image.Width, image.Height, ref resWidth, ref resHeight);
    	   
           using(Bitmap bitmap = new Bitmap((int)(resWidth), (int)(resHeight)))
            {
             string message = "Uploaded";
    		 
    		 bitmap.SetResolution(image.HorizontalResolution, image.VerticalResolution);
    		 
    		 Graphics g = Graphics.FromImage(bitmap);
    		 g.InterpolationMode = InterpolationMode.HighQualityBicubic;		 
    		 g.SmoothingMode = SmoothingMode.HighQuality;
    		 g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    		 g.CompositingQuality = CompositingQuality.HighQuality;
    		 g.DrawImage(image, new Rectangle(0, 0, (int)(resWidth), (int)(resHeight)));
    		 g.Dispose();
    		 
             if (exist && owr)
               {
               message = "OverWritted";
               try
                {
                 File.Delete(destPath + fileName);    
                }
               catch(IOException ioe)
                {
                   message = "<div id=\"error\">Error: " + ioe.GetType().Name + ": The write operation could not be performed because the specified part of the file is locked. Not OverWritted</div>";
                }
              }
             if ((estensione == ".jpg") || (estensione == ".jpeg"))
              bitmap.Save(destPath + fileName, imgCodec[1], encPars);
             else
              bitmap.Save(destPath + fileName, image.RawFormat);
    		  
             if (fileName == file.FileName) 
    		  Status.Text += "<span style=\"color:Green;\">File '" + fileName + " &#64; [" + (int)(image.Width) + "px X " + (int)(image.Height) + "px]' " + message + " with this new size [" + (int)(resWidth) + "px X " + (int)(resHeight) + "px]</span>
    ";
    		 else
    		  Status.Text += "<span style=\"color:Green;\">File \"<u>" + file.FileName + "</u>\" saved &amp;renamed in \"" + fileName + "\".</span>
    ";
            }
          }
        }
       return (fileName);
      } 
    
    string imgDestFolder()
     {
      return ("/public/image/foto/");
     }
    string tbnDestFolder()
     {
      return ("/public/image/miniature/");
     }
    
    void InserisciNomiDeiFilesNelDB_Access(string fileList, char token, string codice_categoria, string codice_lingua, string on_line, string nome, string codice_articolo,string descrizione_corta, string descrizione, string prezzo, string iva, string prezzo_acquisto, string prezzo_vendita, string prezzo_ingrosso, string punti_sconto, string offerta, string stato, string data_inserimento, string giacenza, string giacenza_infinita, string produttore, string taglia, string peso, string misure, string correlati, string nome_comune, string nome_scientifico, string nome_famiglia) 
      {  
       string [] fileListSplitted = fileList.Split(new Char [] {token}); 
    
       int fLS = fileListSplitted.Length; 
       Status.Text += "
    <hr>Inserimento dei dati nel DataBase : 
    
    "; 
    
       string connString = ConfigurationSettings.AppSettings["dbConnString"];
       string imgFields = "";
       string imgValues = "";
       int ii = 0;
        
       foreach (string s in fileListSplitted) 
        { 
         if (s != "") 
          { 
    	   ii++;
    	   imgFields+="IMG_"+ii.ToString()+",IMG_TBN_"+ii.ToString()+",";
    	   imgValues+="'" + (imgDestFolder() + s) + "','" + (tbnDestFolder() + s) + "',";
          } 
        } 
    	
    string sqlString = "INSERT INTO [TabArticolo] ("+imgFields+"CODICE_CATEGORIA, CODICE_LINGUA, ON_LINE, NOME, CODICE_ARTICOLO, DESCRIZIONE_CORTA, DESCRIZIONE, PREZZO, IVA, PREZZO_ACQUISTO, PREZZO_VENDITA, PREZZO_INGROSSO, PUNTI_SCONTO, OFFERTA, STATO, DATA_INSERIMENTO, GIACENZA, GIACENZA_INFINITA, PRODUTTORE, TAGLIA, PESO, MISURE, CORRELATI, NOME_COMUNE, NOME_SCIENTIFICO, NOME_FAMIGLIA) VALUES ("+imgValues+"'" + codice_categoria + "', '" + codice_lingua + "', '" + on_line + "', '" + nome + "', '" + codice_articolo + "', '" + descrizione_corta + "',  '" + descrizione + "',  '" + prezzo + "',  '" + iva + "',  '" + prezzo_acquisto + "', '" + prezzo_vendita + "',  '" + prezzo_ingrosso + "',  '" + punti_sconto + "',  '" + offerta + "', '" + stato + "', '" + data_inserimento + "', '" + giacenza + "', '" + giacenza_infinita + "', '" + produttore + "', '" + taglia + "', '" + peso + "', '" + misure + "','" + correlati + "','" + nome_comune + "','" + nome_scientifico + "', '" + nome_famiglia + "');";
    	   
           using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connString)) 
            { 
             conn.Open(); 
             System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(sqlString, conn); 
             try 
              { 
               cmd.ExecuteNonQuery(); 
               Status.Text += "<span style=\"color:Green;\">Record Inserito correttamente. Ok!
    </span>"; 
              } 
             catch (Exception ex) 
              {
               Status.Text += "<span style=\"color:Red;\">Errore : " + ex.Message + "</span>
    "; 
              } 
             finally 
              { 
               conn.Close(); 
              } 
            }  
      }

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    708
    codice:
    void SubmitFiles(Object sender, EventArgs e)
     {
      HttpFileCollection uploadedFiles = Request.Files;
      Status.Text = ""; 
      string ListaNomi = "";
      string tmbFolder = tbnDestFolder();
      string imgFolder = imgDestFolder();
      string newFileName = "";
      string fileName = "";
    
      string CODICE_CATEGORIA = "";  
      if ( (codice_categoria.SelectedItem.Text != "") && ((codice_categoria.SelectedItem.Text.ToString()).Length > 0) ) CODICE_CATEGORIA = codice_categoria.SelectedItem.Text;
      
      string CODICE_LINGUA = "IT";  
      if ( (codice_lingua.SelectedItem.Text != "") && ((codice_lingua.SelectedItem.Text.ToString()).Length > 0) ) CODICE_LINGUA = codice_lingua.SelectedItem.Text;
      
      string ON_LINE = "";
    
      if (on_line.Checked)
      {
      	ON_LINE = "TRUE";
      } 
      else
      {
      	ON_LINE = "FALSE";
      }    
      string NOME = ""; 
      if ( (nome.Text != "") && ((nome.Text.ToString()).Length > 0) ) NOME = nome.Text;
      
      string CODICE_ARTICOLO = ""; 
      if ( (codice_articolo.Text != "") && ((codice_articolo.Text.ToString()).Length > 0) ) CODICE_ARTICOLO = codice_articolo.Text;
      
      string DESCRIZIONE_CORTA = "";
      if ( (descrizione_corta.Text != "") && ((descrizione_corta.Text.ToString()).Length > 0) ) DESCRIZIONE_CORTA = descrizione_corta.Text;
      
      string DESCRIZIONE = "";
      if ( (descrizione.Text != "") && ((descrizione.Text.ToString()).Length > 0) ) DESCRIZIONE = descrizione.Text;
      
      string PREZZO = "";
      if ( (prezzo.Text != "") && ((prezzo.Text.ToString()).Length > 0) ) PREZZO = prezzo.Text;
      
      string IVA = "";
      if ( (iva.Text != "") && ((iva.Text.ToString()).Length > 0) ) IVA = iva.Text;
      
      string PREZZO_ACQUISTO = "";
      if ( (prezzo_acquisto.Text != "") && ((prezzo_acquisto.Text.ToString()).Length > 0) ) PREZZO_ACQUISTO = prezzo_acquisto.Text;
      
      string PREZZO_VENDITA = "";
      if ( (prezzo_vendita.Text != "") && ((prezzo_vendita.Text.ToString()).Length > 0) ) PREZZO_VENDITA = prezzo_vendita.Text;
      
      string PREZZO_INGROSSO = "";
      if ( (prezzo_ingrosso.Text != "") && ((prezzo_ingrosso.Text.ToString()).Length > 0) ) PREZZO_INGROSSO = prezzo_ingrosso.Text;
      
      string PUNTI_SCONTO = ""; 
      if ( (punti_sconto.Text != "") && ((punti_sconto.Text.ToString()).Length > 0) ) PUNTI_SCONTO = punti_sconto.Text;
      
      string OFFERTA = "";
      
      if (offerta.Checked)
      {
      	OFFERTA = "TRUE";
      } 
      else
      {
      	OFFERTA = "FALSE";
      }   
      
      string STATO = "";
      if ( (stato.Text != "") && ((stato.Text.ToString()).Length > 0) ) STATO = stato.Text;
      
      string DATA_INSERIMENTO = "";
      if ( (data_inserimento.Text != "") && ((data_inserimento.Text.ToString()).Length > 0) ) DATA_INSERIMENTO = data_inserimento.Text;
      
      string GIACENZA = "";
      if ( (giacenza.Text != "") && ((giacenza.Text.ToString()).Length > 0) ) GIACENZA = giacenza.Text;
      
      string GIACENZA_INFINITA = ""; 
    
      if (giacenza_infinita.Checked)
      {
      	GIACENZA_INFINITA = "TRUE";
      } 
      else
      {
      	GIACENZA_INFINITA = "FALSE";
      }  
      string PRODUTTORE = "";
      if ( (produttore.Text != "") && ((produttore.Text.ToString()).Length > 0) ) PRODUTTORE = produttore.Text;
      
      string TAGLIA = "";
      if ( (taglia.Text != "") && ((taglia.Text.ToString()).Length > 0) ) TAGLIA = taglia.Text;
      
      string PESO = ""; 
      if ( (peso.Text != "") && ((peso.Text.ToString()).Length > 0) ) PESO = peso.Text;
      
      string MISURE = ""; 
      if ( (misure.Text != "") && ((misure.Text.ToString()).Length > 0) ) MISURE = misure.Text;
      
      string CORRELATI = "";
      if ( (correlati.Text != "") && ((correlati.Text.ToString()).Length > 0) ) CORRELATI = correlati.Text;
      
      string NOME_COMUNE = ".";
      if ( (nome_comune.Text != "") && ((nome_comune.Text.ToString()).Length > 0) ) NOME_COMUNE = nome_comune.Text;
      
      string NOME_SCIENTIFICO = "";
      if ( (nome_scientifico.Text != "") && ((nome_scientifico.Text.ToString()).Length > 0) ) NOME_SCIENTIFICO = nome_scientifico.Text; 
      
      string NOME_FAMIGLIA = "";
      if ( (nome_famiglia.Text != "") && ((nome_famiglia.Text.ToString()).Length > 0) ) NOME_FAMIGLIA = nome_famiglia.Text;
      
      for (int i = 0; i < uploadedFiles.Count; i ++)  
       {
        newFileName = "";
    	fileName = uploadedFiles[i].FileName;
    
        newFileName = ResizeAnUploadedImage(uploadedFiles[i], 800.0, 600.0, imgFolder, false);
    
        newFileName = ResizeAnUploadedImage(uploadedFiles[i], 140.0, 140.0, tmbFolder, false);
    
        if (fileName != "")
    	 {
    	  if ((newFileName != "") && (newFileName != fileName)) 
    	   ListaNomi += newFileName + "|";
    	  else
    	   ListaNomi += fileName + "|";
    	 }	
       }
       InserisciNomiDeiFilesNelDB_Access(ListaNomi, '|', CODICE_CATEGORIA, CODICE_LINGUA, ON_LINE, NOME, CODICE_ARTICOLO, DESCRIZIONE_CORTA, DESCRIZIONE, PREZZO, IVA, PREZZO_ACQUISTO, PREZZO_VENDITA, PREZZO_INGROSSO, PUNTI_SCONTO, OFFERTA, STATO, DATA_INSERIMENTO, GIACENZA, GIACENZA_INFINITA, PRODUTTORE, TAGLIA, PESO, MISURE, CORRELATI, NOME_COMUNE, NOME_SCIENTIFICO, NOME_FAMIGLIA);
      
      Status.Text += "
    <center><pre>Coded by <a href=\"http://forum.html.it/forum/member.php?s=&action=getinfo&userid=83362\" title=\"R.B.Riddick\" target=\"blank\">R.B.Riddick &copy;</a> on <a href=\"http://www.html.it\" target=\"_blank\">html.it</a></pre></center>";
      Status.Text += "
    
    <a href=\"http://validator.w3.org/check?uri=referer\" target=\"blank\"><img src=\"http://www.w3.org/Icons/valid-html401\" alt=\"Valid HTML 4.01 Transitional\" height=\"31\" width=\"88\" border=\"0\"></a></p>";
    	Response.Redirect("inserisci_articolo.aspx"); /*** CODICE REFRESH ***/
    }
     bool ResizeAnImageFile(string fileSource, string destFolder, double nwWidth, double nwHeight, bool owr)
      {
       string fileName = Path.GetFileName(fileSource);
       string estensione = Path.GetExtension(fileName).ToLower();
       string destPath = destFolder + "/"; 
    
       double resWidth = nwWidth;
       double resHeight = nwHeight;
       
       bool stato = false;
       bool exist = false;	
       
       if (nwWidth == 0) return false;
       if (nwHeight == 0) return false;
    
       ImageCodecInfo[] imgCodec = ImageCodecInfo.GetImageEncoders();
       EncoderParameters encPars = new EncoderParameters(2);
       EncoderParameter encPar1 = new EncoderParameter( System.Drawing.Imaging.Encoder.Quality, 100L );
       EncoderParameter encPar2 = new EncoderParameter( System.Drawing.Imaging.Encoder.Compression, 100L );
       
       encPars.Param[0] = encPar1;
       encPars.Param[1] = encPar2;
    
       exist = File.Exists(destPath + fileName);
       if ( ((!File.Exists(destPath + fileName)) && (fileName != ""))  || owr)
    	{
    	 using(System.Drawing.Image image = System.Drawing.Image.FromFile(fileSource))
    	  {
    	   CalcolaAspectRatio_Biggest(image.Width, image.Height, ref resWidth, ref resHeight);
    	   
           using(Bitmap bitmap = new Bitmap((int)(resWidth), (int)(resHeight)))
            {
    		 bitmap.SetResolution(image.HorizontalResolution, image.VerticalResolution);
    		 
    		 Graphics g = Graphics.FromImage(bitmap);
    		 g.InterpolationMode = InterpolationMode.HighQualityBicubic;		 
    		 g.SmoothingMode = SmoothingMode.HighQuality;
    		 g.PixelOffsetMode = PixelOffsetMode.HighQuality;
    		 g.CompositingQuality = CompositingQuality.HighQuality;
    		 g.DrawImage(image, new Rectangle(0, 0, (int)(resWidth), (int)(resHeight)));
    		 g.Dispose();
    		 
             if (exist && owr)
               {
               try
                {
                 File.Delete(destPath + fileName);    
                }
               catch(IOException ioe)
                {
                  stato = false;
                }
              }
    		  
             if ((estensione == ".jpg") || (estensione == ".jpeg"))
              bitmap.Save(destPath + fileName, imgCodec[1], encPars);
             else
              bitmap.Save(destPath + fileName, image.RawFormat);
    		  
    		 stato = true;
           }
    	  }
    	 }
    	else
    	 if (File.Exists(destPath + fileName) && (!owr))	stato = false;
    
       return stato;	
      }
       
    void SubmitFolder(Object sender, EventArgs e)
     {
      string ListaNomi = "";
      
      string srcFolder = "./";
      
      string tmbFolder = tbnDestFolder();
      string imgFolder = imgDestFolder();
      
      double tWidth = 140.0;
      double tHeight = 140.0;
      
      double imgWidth = 800.0;
      double imgHeight = 600.0;
      
      string CODICE_CATEGORIA = ".";
      string CODICE_LINGUA = ".";
      string ON_LINE = ".";
      string NOME = ".";
      string CODICE_ARTICOLO = ".";
      string DESCRIZIONE_CORTA = ".";
      string DESCRIZIONE = ".";
      string PREZZO = ".";
      string IVA = ".";
      string PREZZO_ACQUISTO = ".";
      string PREZZO_VENDITA = ".";
      string PREZZO_INGROSSO = ".";
      string PUNTI_SCONTO = ".";
      string OFFERTA = ".";
      string STATO = ".";
      string DATA_INSERIMENTO = ".";
      string GIACENZA = ".";
      string GIACENZA_INFINITA = ".";
      string PRODUTTORE = ".";
      string TAGLIA = ".";
      string PESO = ".";
      string MISURE = ".";
      string CORRELATI = ".";
      string NOME_COMUNE = ".";
      string NOME_SCIENTIFICO = ".";
      string NOME_FAMIGLIA = ".";
    	
    	if ( (codice_categoria.SelectedItem.Text != "") && ((codice_categoria.SelectedItem.Text.ToString()).Length > 0) ) CODICE_CATEGORIA = codice_categoria.SelectedItem.Text;
      	
    	if ( (codice_lingua.SelectedItem.Text != "") && ((codice_lingua.SelectedItem.Text.ToString()).Length > 0) ) CODICE_LINGUA = codice_lingua.SelectedItem.Text;
    
    	if (on_line.Checked)
      	{
      		ON_LINE = "TRUE";
      	} 
      	else
      	{
      		ON_LINE = "FALSE";
      	}
    	if ( (nome.Text != "") && ((nome.Text.ToString()).Length > 0) ) NOME = nome.Text;
      
    	if ( (codice_articolo.Text != "") && ((codice_articolo.Text.ToString()).Length > 0) ) CODICE_ARTICOLO = codice_articolo.Text;
      
    	if ( (descrizione_corta.Text != "") && ((descrizione_corta.ToString()).Length > 0) ) DESCRIZIONE_CORTA = descrizione_corta.Text;
      
    	if ( (descrizione.Text != "") && ((descrizione.Text.ToString()).Length > 0) ) DESCRIZIONE = descrizione.Text;
       
    	if ( (prezzo.Text != "") && ((prezzo.Text.ToString()).Length > 0) ) PREZZO = prezzo.Text;
    		
    	if ( (iva.Text != "") && ((iva.Text.ToString()).Length > 0) ) IVA = iva.Text;
    	
    	if ( (prezzo_acquisto.Text != "") && ((prezzo_acquisto.Text.ToString()).Length > 0) ) PREZZO_ACQUISTO = prezzo_acquisto.Text;
    	
    	if ( (prezzo_vendita.Text != "") && ((prezzo_vendita.Text.ToString()).Length > 0) ) PREZZO_VENDITA = prezzo_vendita.Text;
    	
    	if ( (prezzo_ingrosso.Text != "") && ((prezzo_ingrosso.Text.ToString()).Length > 0) ) PREZZO_INGROSSO = prezzo_ingrosso.Text;
    	
        if ( (punti_sconto.Text != "") && ((punti_sconto.Text.ToString()).Length > 0) ) PUNTI_SCONTO = punti_sconto.Text;
    	
    	if (offerta.Checked)
      	{
      		OFFERTA = "TRUE";
      	} 
      	else
      	{
      		OFFERTA = "FALSE";
      	}
    	
    	if ( (stato.Text != "") && ((stato.Text.ToString()).Length > 0) ) STATO = stato.Text;
    	
    	if ( (data_inserimento.Text != "") && ((data_inserimento.Text.ToString()).Length > 0) ) DATA_INSERIMENTO = data_inserimento.Text;
    	
    	if ( (giacenza.Text != "") && ((giacenza.Text.ToString()).Length > 0) ) GIACENZA = giacenza.Text;
    
    	if (giacenza_infinita.Checked)
      	{
      		GIACENZA_INFINITA = "TRUE";
      	} 
      	else
      	{
      		GIACENZA_INFINITA = "FALSE";
      	}
    	
    	if ( (produttore.Text != "") && ((produttore.Text.ToString()).Length > 0) ) PRODUTTORE = produttore.Text;
    	
    	if ( (taglia.Text != "") && ((taglia.Text.ToString()).Length > 0) ) TAGLIA = taglia.Text;
    			
    	if ( (peso.Text != "") && ((peso.Text.ToString()).Length > 0) ) PESO = peso.Text;
    	
    	if ( (misure.Text != "") && ((misure.Text.ToString()).Length > 0) ) MISURE = misure.Text;
    	
    	if ( (correlati.Text != "") && ((correlati.Text.ToString()).Length > 0) ) CORRELATI = correlati.Text;
    	
    	if ( (nome_comune.Text != "") && ((nome_comune.Text.ToString()).Length > 0) ) NOME_COMUNE = nome_comune.Text;
    	
    	if ( (nome_scientifico.Text != "") && ((nome_scientifico.Text.ToString()).Length > 0) ) NOME_SCIENTIFICO = nome_scientifico.Text;
    	
    	if ( (nome_famiglia.Text != "") && ((nome_famiglia.Text.ToString()).Length > 0) ) NOME_FAMIGLIA = nome_famiglia.Text;
    	
      
      if ( (cartella.Text != "") && ((cartella.Text.ToString()).Length > 0) ) 
       {
        srcFolder = cartella.Text + "/";
    	srcFolder = (srcFolder.Replace("\\", "/")).Replace("//", "/");
       }
      else
       {
        Status.Text = "<span style=\"color:red;\">Error : Server Folder not specified!</span>
    ";
    	return;
       }
       
      Status.Text = ""; 
      srcFolder = Server.MapPath(srcFolder);
      tmbFolder = Server.MapPath(tmbFolder);
      imgFolder = Server.MapPath(imgFolder);

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.