Torna al Thread
Protected Sub add_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If (descr.Text = "" Or prez.Text = "" Or tempf.Text = "") Then
If desc.Text = "" Then
eff.Text = "il campo Descrizione è obbligatorio"
ElseIf prez.Text = "" Then
eff.Text = "il campo prezzo è obbligatorio"
ElseIf tempf.Text = "" Then
eff.Text = "il campo Tempo fornitura è obbligatorio"
End If
Else
Dim c As Integer
Dim con2 As New System.Data.OleDb.OleDbConnection("Provider=SQLOLEDB;Data Source=GOMMOSA\SQLEXPRESS;Initial Catalog=MIO_SITO2;User ID=sa;Password=saweb")
con2.Open()
Dim com2 As New System.Data.OleDb.OleDbCommand()
com2.Connection = con2
Dim com3 As New System.Data.OleDb.OleDbCommand()
com3.Connection = con2
com3.CommandText = "select MAX(ID_PRODOTTO) AS MASSIMO from PRODOTTI"
com3.ExecuteNonQuery()
Dim dr1 As System.Data.OleDb.OleDbDataReader
dr1 = com3.ExecuteReader()
dr1.Read()
c = CDec("0" & dr1.GetValue(0)) + 1
com2.CommandText = "INSERT INTO PRODOTTI(ID_PRODOTTO, DESCRIZIONE,DETTAGLIO, PREZZO, ID_CATEGORIA, ID_PRODUTTORE, T_FORNITURA, DISPONIBILITA, LIVELLO_RIORDINO, IMMAGINE) VALUES (" + CStr(c) + ","
com2.CommandText = com2.CommandText + "'" + descr.Text + "', "
com2.CommandText = com2.CommandText + "'" + det.Text + "', "
com2.CommandText = com2.CommandText + "" + prez.Text + ", '" + categ.Text + "' , '" + produt.Text + "' ,"
com2.CommandText = com2.CommandText + "" + tempf.Text + ", 0, 0,"
com2.CommandText = com2.CommandText + "'" + im.FileName + "') "
com2.ExecuteNonQuery()
eff.Text = "prodotto inserito"
con2.Close()
End If
End Sub
Protected Sub ce_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim con As New System.Data.OleDb.OleDbConnection("Provider=SQLOLEDB;Data Source=GOMMOSA\SQLEXPRESS;Initial Catalog=MIO_SITO2;User ID=sa;Password=saweb")
con.Open()
Dim com4 As New System.Data.OleDb.OleDbCommand()
com4.Connection = con
com4.CommandText = "select * from PRODOTTI where DESCRIZIONE like '%" & nom.Text & "%'"
Dim dr4 As System.Data.OleDb.OleDbDataReader
dr4 = com4.ExecuteReader()
Response.Write("<html> <head> <div> <title> Risultati della ricerca: </title> </head> <body>")
Response.Write("<table border=1 bordercolor=black cellspacing=1 align=left>")
Response.Write("<tr> <th>ID_PRODOTTO</th><th>DESCRIZIONE</th><th>DETTAGLIO</th><th>IMMAGINE</th><th>PREZZO</th><th>DISPONIBILITA</th> </tr>")
While (dr4.Read())
Response.Write("<tr>")
Response.Write("<td>" & dr4("ID_PRODOTTO") & "</td>")
Response.Write("<td>" & dr4("DESCRIZIONE") & "</td>")
Response.Write("<td>" & dr4("DETTAGLIO") & "</td>")
Response.Write("<td>" + dr4("IMMAGINE") + "</td>")
Response.Write("<td>" & dr4("PREZZO") & "</td>")
Response.Write("<td>" & dr4("DISPONIBILITA") & "</td>")
Response.Write("</tr>")
End While
Response.Write("</table> </div>")
Response.Write("</body> </html>")
dr4.Close()
con.Close()
End Sub