Torna al Thread
Protected Sub listapagamenti_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles listapagamenti.RowCommand
If (e.CommandName = "Edit") Then
Dim c As Control = CType(e.CommandSource, Control)
Dim r As GridViewRow = CType(c.NamingContainer, GridViewRow)
data1.Text = r.Cells(2).Text.Substring(0, 10)
data2.Text = r.Cells(2).Text.Substring(13, 10)
TxtCro.Text = r.Cells(3).Text
Txtdataversamento.Text = r.Cells(4).Text
modificarecord.Value = 1
idpagamento.Value = CInt(r.Cells(1).Text)
End If
If (e.CommandName = "Delete") Then
Try
Albergo = CType(Session("Albergo"), iAlbergo)
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("delete_pagamenti", db)
sqlcmd.CommandType = CommandType.StoredProcedure
Dim id As Integer = CInt(idpagamento.Value)
sqlcmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = id
sqlcmd.Parameters.AddWithValue("@idstruttura", SqlDbType.Int).Value = Albergo.CodAlbergo
sqlcmd.Parameters.AddWithValue("@codcomune", SqlDbType.Int).Value = Albergo.CodComuneAlbergo
sqlcmd.ExecuteNonQuery()
listapagamenti.DataSource = Getpagamenti(Albergo.CodAlbergo, CInt(Now.Year), Albergo.CodComuneAlbergo)
listapagamenti.DataBind()
modificarecord.Value = 0
idpagamento.Value = Getidpagamento(Albergo.CodAlbergo, Albergo.CodComuneAlbergo)
End Using
End Using
Catch ex As SqlException
prompt = New ImpromptuPrompt
prompt.Options.Buttons.Add("Chiudi", "ok")
prompt.Options.Top = 350
prompt.Options.PromptSpeed = "slow"
prompt.Options.Show = "show"
prompt.Message = ex.Message
ImpromptuHelper.ShowPrompt(prompt)
Catch ex As Exception
prompt = New ImpromptuPrompt
prompt.Options.Buttons.Add("Chiudi", "ok")
prompt.Options.Top = 350
prompt.Options.PromptSpeed = "slow"
prompt.Options.Show = "show"
prompt.Message = ex.Message
ImpromptuHelper.ShowPrompt(prompt)
End Try
End If
End Sub