Torna al Thread

Protected Sub gw_Arrivati_Oggi_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gw_Arrivati_Oggi.RowCommand If (e.CommandName = "Update") Then Dim c As Control = CType(e.CommandSource, Control) Dim drop As DropDownList = DirectCast(c.FindControl("DropDownList1"), DropDownList) Dim r As GridViewRow = CType(c.NamingContainer, GridViewRow) Dim Albergo As iAlbergo Albergo = CType(Session("Albergo"), iAlbergo) Try Dim conString = ConfigurationManager.ConnectionStrings("DB_GESTIONE_ALBERGHI") Dim strConnString As String = conString.ConnectionString Using db As New SqlConnection(strConnString) db.Open() Using sqlcmd As New SqlCommand("Update_esente_imposta", db) sqlcmd.CommandType = CommandType.StoredProcedure sqlcmd.Parameters.AddWithValue("@codalbergo", SqlDbType.Int).Value = Albergo.CodAlbergo sqlcmd.Parameters.AddWithValue("@esente_imposta", SqlDbType.Int).Value = drop.SelectedValue sqlcmd.Parameters.AddWithValue("@codscheda", SqlDbType.Int).Value = r.Cells(9).Text sqlcmd.ExecuteNonQuery() End Using End Using r.Cells(8).Text = drop.SelectedIndex ScriptManager.RegisterStartupScript(Me, Me.GetType, _ "Hotel Manager", _ "javascript:alert('Dato aggiornato correttamente');", True) Catch ex As SqlException ScriptManager.RegisterStartupScript(Me, Me.GetType, "Errore", ex.Message, True) Catch ex As Exception ScriptManager.RegisterStartupScript(Me, Me.GetType, "Errore", ex.Message, True) End Try End If End Sub Protected Sub gw_Arrivati_Oggi_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gw_Arrivati_Oggi.RowDataBound Dim albergo As iAlbergo albergo = CType(Session("Albergo"), iAlbergo) If albergo.AttivazioneImposta = 1 Then If e.Row.RowType = DataControlRowType.DataRow Then Dim curValue As String = e.Row.Cells(8).Text Dim curImgCtrl As Image = DirectCast(e.Row.FindControl("Image4"), Image) If curValue <> "0" Then curImgCtrl.Visible = False End If Dim c As Control = CType(e.Row, Control) Dim drop As DropDownList = DirectCast(c.FindControl("DropDownList1"), DropDownList) drop.SelectedIndex = curValue End If Else If e.Row.RowType = DataControlRowType.DataRow Then Dim curImgCtrl As Image = DirectCast(e.Row.FindControl("Image4"), Image) curImgCtrl.Visible = False e.Row.Cells(8).Text = "" End If End If End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5