Torna al Thread

Imports System.Data.Odbc Partial Class _Default Inherits System.Web.UI.Page Public Function Controlla(ByVal Abile As Boolean) As String If Abile = True Then Controlla = "SI" Else Controlla = "NO" End If End Function Public Function DecriptaDati(ByVal strDaDecriptare As String) As String DecriptaDati = "" If strDaDecriptare <> "" Then Try Dim clsCrypto As New ClassCripto Dim tmp As Byte() = Convert.FromBase64String(strDaDecriptare) Dim decrypted As String = clsCrypto.DeCripta_Rijndael(tmp) DecriptaDati = decrypted.ToString clsCrypto = Nothing Catch ex As Exception Dim clsGen As New ClassGenerali If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, Resources.ResourceMsg.Errore & " Decriptazione dati Profilo " & vbCrLf & ex.Message) 'Scrittura errore sul log... Call clsGen.ScriviLog("Generali/Profilo.aspx.vb.DecriptaDati", ex.Message) clsGen = Nothing End Try End If End Function Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init '+++ caricamento intestazioni righe... With DetailsViewDestinatario '.Fields(0).HeaderText = Resources.ResourceGenerali.lblNomeUtente '.Fields(1).HeaderText = Resources.ResourceGenerali.lblCognomeUtente '.Fields(2).HeaderText = Resources.ResourceGenerali.lblPasswordUtente '.Fields(3).HeaderText = Resources.ResourceGenerali.lblIndirizzo .Fields(4).HeaderText = Resources.ResourceGenerali.lblCAPUtente .Fields(5).HeaderText = Resources.ResourceGenerali.lblCittaUtente '.Fields(6).HeaderText = Resources.ResourceGenerali.lblIndirizzoRicezioneMerceUtente '.Fields(7).HeaderText = Resources.ResourceGenerali.lblTelUtente .Fields(8).HeaderText = Resources.ResourceGenerali.lblPIVA '.Fields(9).HeaderText = Resources.ResourceGenerali.lblCodiceFiscaleUtente .Fields(10).HeaderText = Resources.ResourceGenerali.lblDataNascitaUtente .Fields(11).HeaderText = Resources.ResourceGenerali.lblDettagliRegistrazione .Fields(12).HeaderText = Resources.ResourceGenerali.lblAbilitato .Fields(13).HeaderText = Resources.ResourceGenerali.lblEmailUtente End With End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'da copiare in tutte le pagine... Page.Title = Resources.ResourceMaster.PageTitle & "; " & Resources.ResourcePagesTitle.titleCarrello 'System.Threading.Thread.Sleep(5000) If Not IsPostBack Then Dim conn As New ClassConnessione Dim clsGen As New ClassGenerali Try If Session("IdUserLogged") <> "" Then Dim IdUser As Integer = 0 IdUser = clsGen.EstraiSessionIdUser(Session("IdUserLogged")) If IdUser > 0 Then '+++ Verifica abilitazione carrello +++ 'Call VerificaAbilitazioneCarrello() Call conn.EstraiDati("SELECT * FROM AbilitazioneCarrello", conn.ConnettiCatalogo) If conn.Dati.HasRows = True Then If conn.Dati("CarrelloAbilitato") = 0 Then Call clsGen.MostraMessaggio(HttpContext.Current.Handler, "CartTemporaryDisabled", conn.Dati("MSGCarrelloDisabilitato")) PanelCarrelloDisabilitato.Visible = True PanelCarrello.Visible = False lblCarrelloDisabilitato.Text = conn.Dati("MSGCarrelloDisabilitato") Exit Sub End If If conn.Dati.IsClosed = False Then conn.Dati.Close() End If Else PanelAutenticarsi.Visible = True PanelCarrello.Visible = False End If With conn Call .VerificaConnessione(.ConnettiCatalogo, DBCatalogo) '+++ Caricamente RepeaterCarrello +++ Call .EstraiDati(CStr("SELECT DISTINCT (Cart.id),ColorFotoFront,CodNome,DescNome,Prezzo,ProductID,PrezzoPromo,Quantity,Taglie.Taglia,Colori.Colore FROM Cart, Prodotti, ColoriDisponibili, Taglie, Colori WHERE CartUserID =" & CInt(IdUser) & " AND Cart.ProductID=Prodotti.id AND ColoriDisponibili.IdProdotto=Prodotti.id AND ColoriDisponibili.IdColore=Cart.Colore AND Taglie.id=Cart.Taglia AND Colori.id=Cart.Colore GROUP BY Cart.id"), conn.ConnettiCatalogo) If .Dati.HasRows = False Then PanelCarrelloVuoto.Visible = True PanelAutenticarsi.Visible = False PanelCarrello.Visible = False End If RepeaterCarrello.DataSource = .Dati RepeaterCarrello.DataBind() If .Dati.IsClosed = False Then .Dati.Close() '+++ associazione tipi di spedizione disponibili con Repeater +++ Call .VerificaConnessione(.ConnettiGenerale, DBGenerali) Call .EstraiDati(CStr("SELECT * FROM Spedizioni"), conn.ConnettiGenerale) RepeaterSpedizioni.DataSource = .Dati RepeaterSpedizioni.DataBind() If .Dati.IsClosed = False Then .Dati.Close() '+++ associazione intervalli di spedizione disponibili con Repeater +++ Call .VerificaConnessione(.ConnettiCatalogo, DBCatalogo) Call .EstraiDati(CStr("SELECT * FROM SpeseSpedizione"), conn.ConnettiCatalogo) RepeaterIntervalliSpeseSpedizione.DataSource = .Dati RepeaterIntervalliSpeseSpedizione.DataBind() If .Dati.IsClosed = False Then .Dati.Close() '+++ associazione Pagamenti disponibili con Repeater +++ Call .VerificaConnessione(.ConnettiGenerale, DBGenerali) Call .EstraiDati(CStr("SELECT * FROM PagamentiAccettati"), conn.ConnettiGenerale) RepeaterPagamentiAccettati.DataSource = .Dati RepeaterPagamentiAccettati.DataBind() If .Dati.IsClosed = False Then .Dati.Close() '+++ associazione destinaratio della merce con Repeater +++ Call .VerificaConnessione(.ConnettiCatalogo, DBCatalogo) Call .EstraiDati(CStr("SELECT * FROM Iscritti"), conn.ConnettiCatalogo) DetailsViewDestinatario.DataSource = .Dati DetailsViewDestinatario.DataBind() If .Dati.IsClosed = False Then .Dati.Close() lblIpTraced.Text = clsGen.RicavaIP End With Else PanelAutenticarsi.Visible = True PanelCarrello.Visible = False End If Catch ex As Exception If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.Page_Load", ex.Message) clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di Load del Carrello") clsGen = Nothing End Try End If End Sub Protected Sub RepeaterCarrello_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterCarrello.ItemCommand Dim conn As New ClassConnessione Dim clsGen As New ClassGenerali Try Dim IdCart As Label = CType(e.Item.FindControl("IdCart"), Label) Select Case e.CommandName.ToString Case Is = "DeleteFromCart" Dim clsOpDb As New ClassOperazioniDB Call clsOpDb.EliminaProdottoDaCarrello(CInt(IdCart.Text)) '+++ fine verifica abilitazione carrello +++ If Session("IdUserLogged") <> "" Then Dim IdUser As Integer = 0 IdUser = clsGen.EstraiSessionIdUser(Session("IdUserLogged")) If IdUser > 0 Then With conn Call .VerificaConnessione(.ConnettiCatalogo, DBCatalogo) '+++ Caricamente RepeaterCarrello +++ '+++ azzeramento campi testo +++ cosi si rivalorizzano durante l'item_databound lblCartTotale.Text = "" lblCartSpeseSpedizione.Text = "" lblCartTotaleProdotti.Text = "" 'lblScontoApplicato.Text = "" 'lblScontoApplicatoValue.Text = "" 'lblTottmp.Text = "" Call .EstraiDati(CStr("SELECT DISTINCT (Cart.id),ColorFotoFront,CodNome,DescNome,Prezzo,ProductID,PrezzoPromo,Quantity,Taglie.Taglia,Colori.Colore FROM Cart, Prodotti, ColoriDisponibili, Taglie, Colori WHERE CartUserID =" & CInt(IdUser) & " AND Cart.ProductID=Prodotti.id AND ColoriDisponibili.IdColore=Cart.Colore AND Taglie.id=Cart.Taglia AND Colori.id=Cart.Colore GROUP BY Cart.id"), conn.ConnettiCatalogo) If .Dati.HasRows = False Then PanelCarrelloVuoto.Visible = True PanelAutenticarsi.Visible = False PanelCarrello.Visible = False End If RepeaterCarrello.DataSource = .Dati RepeaterCarrello.DataBind() If .Dati.IsClosed = False Then .Dati.Close() '+++ riestrazione dati per ricostruzione Sessione utente ' e aggiornamento qt nel box login... '+++ Dim QtCarrello As Integer = 0 QtCarrello = clsGen.EstraiQuantitativoCarrello(CInt(IdUser)) Session("IdUserLogged") = clsGen.RigeneraSessionNuovoQtCarrello(CStr(Session("IdUserLogged")), CInt(QtCarrello)) QtCarrello = 0 '+++ '+++ SUPERFLUO ! c'è già un codice nell'evento Page_PreRender che LoginControl che aggiorna la label +++ 'Dim lblNprodottiCarrello As Label = CType(LoginControl1.FindControl("lblNprodottiCarrello"), Label) 'lblNprodottiCarrello.Text = QtCarrello 'LoginControl1.AggiornaQtBoxLogin(CInt(QtCarrello)) '+++ End With UpdatePanelCarrello.Update() '+++ da usare con UpdateMode=conditional, serve ad aggiornare solo quando richiamo il metodo update +++ 'Response.Redirect("~/Catalogo/Carrello.aspx", False) End If End If End Select Catch ex As Exception If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.RepeaterCarrello_ItemCommand", ex.Message) clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di ItemCommand del Carrello") clsGen = Nothing End Try End Sub Protected Sub RepeaterCarrello_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterCarrello.ItemDataBound '+++ in questo evento bisogna stare attenti a controllare il giusto item... ' in questo caso va bene perchè di item ci sono solo le righe create, ma se ci fosse prima di ' tutto un HeaderTemplate ad esempio, non troverebbe il controllo se non si fa una verifica ' con un ciclo IF che vada a vedere se sono dentro un item o un header ecc. +++ Try '+++ Ad ogni associazione di un item creato faccio il controllo e carico l'img giusta +++ Dim imgFotoProdotto As Image = CType(e.Item.FindControl("imgFotoProdotto"), Image) If imgFotoProdotto.ImageUrl = "" Or imgFotoProdotto.ImageUrl = ImgPath Then imgFotoProdotto.ImageUrl = ImgPath & "NoImmagine.jpg" End If Dim lblPrezzo As Label = CType(e.Item.FindControl("LitPrezzo"), Label) Dim lblPrezzoPromo As Label = CType(e.Item.FindControl("LitPrezzoPromo"), Label) Dim lblSubTotale As Label = CType(e.Item.FindControl("LitSubTotale"), Label) Dim lblQuantita As Label = CType(e.Item.FindControl("LitQuantita"), Label) Dim lblSpeseSpedizione As Label = CType(e.Item.FindControl("lblCartSpeseSpedizione"), Label) If lblPrezzoPromo.Text <> "" And lblPrezzoPromo.Text > 0 Then lblPrezzo.Font.Strikeout = True lblPrezzoPromo.Visible = True lblSubTotale.Text = String.Format("{0:c}", CDec(CInt(lblQuantita.Text) * CDec(lblPrezzoPromo.Text))) End If Dim ImgBtnelimina As ImageButton = CType(e.Item.FindControl("ImgBtnelimina"), ImageButton) ImgBtnelimina.OnClientClick = "return window.confirm('" & Resources.ResourceMsg.MsgConfermaEliminazioneProdotto & "')" '+++ somma dei subtotali +++ Dim lblTOTtmp As Label = CType(PanelCarrello.FindControl("lblTottmp"), Label) 'MsgBox(lblSubTotale.Text) If lblTOTtmp.Text <> "" Then If lblTOTtmp.Text > 0 Then lblTOTtmp.Text = String.Format("{0:c}", CDec(CDec(lblSubTotale.Text) + CDec(lblTOTtmp.Text))) End If Else lblTOTtmp.Text = String.Format("{0:c}", CDec(lblSubTotale.Text)) End If lblPrezzo.Dispose() lblPrezzoPromo.Dispose() lblSubTotale.Dispose() lblQuantita.Dispose() ImgBtnelimina.Dispose() Catch ex As Exception Dim clsGen As New ClassGenerali If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.RepeaterCarrello_ItemDataBound", ex.Message) clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di databound del Carrello") clsGen = Nothing End Try End Sub Protected Sub RepeaterCarrello_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RepeaterCarrello.PreRender Try Dim clsGen As New ClassGenerali Dim lblTotTmp As Label = PanelCarrello.FindControl("lblTottmp") Dim lblCartTotaleProdotti As Label = PanelCarrello.FindControl("lblCartTotaleProdotti") Dim lblCartTotale As Label = PanelCarrello.FindControl("lblCartTotale") Dim lblSpeseSpedizione As Label = PanelCarrello.FindControl("lblCartSpeseSpedizione") Dim lblScontoApplicatoValue As Label = PanelCarrello.FindControl("lblScontoApplicatoValue") '+++ il PreRender avviene per ULTIMO, quindi ricalcolo tutto nel caso che non sia 'valorizzata la spesa di spedizione...essa rimane valorizzata e modificata dai vari bottoni, ma 'viene svuotata nel caso che si tolga un prodotto dal carrello...in quel caso ricalcolo tutto da capo '...negli altri casi esco dal ricalcolo totale e lascio fare il lavoro ai bottoni ' ...da tenere presente che prima del prerender, avvengono il itemdatabound e l'itemcommand, che associano varie cose '+++ If lblSpeseSpedizione.Text <> "" Then Exit Sub 'If Not IsPostBack Then Dim intRange As Integer = 0 If lblCartTotaleProdotti.Text = "" Then lblCartTotaleProdotti.Text = lblTotTmp.Text End If If lblCartTotaleProdotti.Text <> "" Then intRange = CInt(lblCartTotaleProdotti.Text) Else intRange = 0 End If '+++ estrazione spese di spedizione in base all'intervallo di spesa +++ lblSpeseSpedizione.Text = String.Format("{0:c}", CDec(clsGen.EstraiSpeseSpedizione(CStr("SELECT SpeseSpedizione FROM SpeseSpedizione WHERE SpeseFrom <=" & intRange & " AND SpeseTo >=" & intRange & ""), "SpeseSpedizione"))) intRange = 0 '+++ controllo delle spese aggiuntive di spedizione +++ Dim i As Integer = 0 Dim lblSpesaAggiuntivaValue As Label Dim imgPagamentoSelezionatoPag As Image For i = 0 To RepeaterPagamentiAccettati.Items.Count - 1 lblSpesaAggiuntivaValue = CType(RepeaterPagamentiAccettati.Items(i).FindControl("lblSpesaAggiuntivaValue"), Label) imgPagamentoSelezionatoPag = CType(RepeaterPagamentiAccettati.Items(i).FindControl("imgPagamentoSelezionato"), Image) If imgPagamentoSelezionatoPag.Visible = True Then If CDbl(lblSpesaAggiuntivaValue.Text) > 0 Then lblSpeseSpedizione.Text = String.Format("{0:c}", CDec(CDec(lblSpeseSpedizione.Text) + CDec(lblSpesaAggiuntivaValue.Text))) Exit For End If End If Next 'End If '+++ controllo della valorizzazione dello Sconto applicato, se applicato... e calcolo del totale +++ If lblScontoApplicatoValue.Text <> "" And IsNumeric(lblScontoApplicatoValue.Text) Then 'If txtSconto.Text <> "" Then 'Dim dmlSconto As Decimal 'dmlSconto = clsgen.EstraiCodiceSconto(CStr(txtSconto.Text)) 'If dmlSconto > 0 Then If lblScontoApplicatoValue.Text > 0 Then lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text)) - CDec(lblScontoApplicatoValue.Text)) Else lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text))) End If Else lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text))) End If lblCartTotale.Text = String.Format("{0:c}", CDec(lblCartTotale.Text)) lblSpeseSpedizione.Dispose() lblTotTmp.Text = "" lblTotTmp.Dispose() lblCartTotale.Dispose() lblScontoApplicatoValue.Dispose() clsGen = Nothing Catch ex As Exception Dim clsGen As New ClassGenerali If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.RepeaterCarrello_PreRender", ex.Message) clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di PreRender del Carrello") clsGen = Nothing End Try End Sub Protected Sub btnApplicaSconto_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnApplicaSconto.Click Dim clsGen As New ClassGenerali If Page.IsValid Then Try Dim lblCartTotale As Label = PanelCarrello.FindControl("lblCartTotale") Dim lblCartTotaleProdotti As Label = PanelCarrello.FindControl("lblCartTotaleProdotti") Dim lblSpeseSpedizione As Label = PanelCarrello.FindControl("lblCartSpeseSpedizione") Dim lblScontoApplicato As Label = PanelCarrello.FindControl("lblScontoApplicato") Dim txtSconto As TextBox = PanelCarrello.FindControl("txtSconto") If lblScontoApplicato.Text <> "" Then lblScontoApplicato.Text = "" End If '+++ controllo InjSQL If clsGen.DataInjectionControl(txtSconto.Text) = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, Resources.ResourceMsg.ErroreDatiInseritiNonConsentiti) txtSconto.Text = "" Exit Sub End If '+++ '+++ ESTRAZIONE DEL VALORE DEL CODICE DA DB +++ '+++ il campo è sicuramente valorizzato grazie al ValidatorControl applicato +++ Dim dmlSconto As Decimal dmlSconto = clsGen.EstraiCodiceSconto(CStr(txtSconto.Text)) If dmlSconto > 0 Then lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text)) - CDec(dmlSconto)) txtSconto.Enabled = False btnApplicaSconto.Enabled = False lblScontoApplicato.Text = Resources.ResourceCatalogo.lblScontoApplicato lblScontoApplicato.CssClass = "TestiVerdiBIG" lblScontoApplicatoValue.Text = String.Format("{0:c}", CDec(dmlSconto)) lblScontoApplicatoValue.cssclass = "TestiVerdiBIG" Else lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text))) txtSconto.Enabled = True btnApplicaSconto.Enabled = True lblScontoApplicato.Text = Resources.ResourceCatalogo.lblScontoNonApplicato lblScontoApplicato.CssClass = "TestiRossi" lblScontoApplicatoValue.text = "" End If lblCartTotale.Text = String.Format("{0:c}", CDec(lblCartTotale.Text)) Catch ex As Exception If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.btnApplicaSconto_Click", ex.Message) 'clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di Load del Carrello") End Try clsGen = Nothing End If End Sub Protected Sub RepeaterSpedizioni_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterSpedizioni.ItemCommand Try Select Case e.CommandName.ToString Case Is = "SelezionaSpedizione" '+++ estrazione dati invisibili per sapere la spedizione scelta e ' riversamento sulle label contenitori finali '+++ Dim lblSpedID As Label = CType(e.Item.FindControl("lblSpedizioneSelezionataID"), Label) Dim lblComeSpedID As Label = CType(PanelCarrello.FindControl("lblComeSpedisceID"), Label) Dim lblSpedNOME As Label = CType(e.Item.FindControl("lblSpedizioneSelezionataNOME"), Label) Dim lblComeSpedNOME As Label = CType(PanelCarrello.FindControl("lblComeSpedisceNOME"), Label) lblComeSpedID.Text = lblSpedID.Text lblComeSpedNOME.Text = lblSpedNOME.Text '+++ FINE estrazione dati pagamento scelto Dim imgbtnSeleziona As ImageButton = CType(e.Item.FindControl("imgbtnSelezionaSpedizione"), ImageButton) Dim imgSpedSelezionata As Image = CType(e.Item.FindControl("imgSpedSelezionata"), Image) imgbtnSeleziona.Visible = False imgSpedSelezionata.Visible = True Dim Elementi As RepeaterItem For Each Elementi In RepeaterSpedizioni.Items If Not e.Item.ItemIndex = Elementi.ItemIndex Then Dim imgbtnSeleziona2 As ImageButton = CType(RepeaterSpedizioni.Items.Item(Elementi.ItemIndex).FindControl("imgbtnSelezionaSpedizione"), ImageButton) Dim imgSpedSelezionata2 As Image = CType(RepeaterSpedizioni.Items.Item(Elementi.ItemIndex).FindControl("imgSpedSelezionata"), Image) imgbtnSeleziona2.Visible = True imgSpedSelezionata2.Visible = False End If Next Elementi = Nothing imgbtnSeleziona = Nothing imgSpedSelezionata = Nothing End Select Catch ex As Exception Dim clsGen As New ClassGenerali If ViewMsgDebug = True Then clsGen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsGen.ScriviLog("Carrello.aspx.vb.RepeaterSpedizioni_ItemCommand", ex.Message) clsGen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di ItemCommand delle Spedizioni da carrello") clsGen = Nothing End Try End Sub Protected Sub RepeaterPagamentiAccettati_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles RepeaterPagamentiAccettati.ItemCommand Dim clsgen As New ClassGenerali Try Select Case e.CommandName.ToString Case Is = "SelezionaPagamento" '+++ estrazione dati invisibili per sapere il pagamento scelto e ' riversamento sulle label contenitori finali '+++ Dim lblPagID As Label = CType(e.Item.FindControl("lblPagamentoSelezionatoID"), Label) Dim lblComePagaID As Label = CType(PanelCarrello.FindControl("lblComePagaID"), Label) Dim lblPagNOME As Label = CType(e.Item.FindControl("lblPagamentoSelezionatoNOME"), Label) Dim lblComePagaNOME As Label = CType(PanelCarrello.FindControl("lblComePagaNOME"), Label) lblComePagaID.Text = lblPagID.Text lblComePagaNOME.Text = lblPagNOME.Text '+++ FINE estrazione dati pagamento scelto '+++ ricalcolo spesa finale con l'aggiunta di un eventuale sovrattassa per il tipo di spedizione +++ Dim lblCartTotaleProdotti As Label = CType(PanelCarrello.FindControl("lblCartTotaleProdotti"), Label) Dim lblCartTotale As Label = CType(PanelCarrello.FindControl("lblCartTotale"), Label) Dim lblSpesaAggiuntivaValue As Label = CType(e.Item.FindControl("lblSpesaAggiuntivaValue"), Label) Dim lblSpeseSpedizione As Label = CType(PanelCarrello.FindControl("lblCartSpeseSpedizione"), Label) '+++ estrazione intervallo di spesa per calcolo spedespedizione attribuibili +++ Dim intRange As Integer = 0 If lblCartTotaleProdotti.Text <> "" Then intRange = CInt(lblCartTotaleProdotti.Text) Else intRange = 0 End If '+++ estrazione spese di spedizione da db +++ lblSpeseSpedizione.Text = String.Format("{0:c}", CDec(clsgen.EstraiSpeseSpedizione(CStr("SELECT SpeseSpedizione FROM SpeseSpedizione WHERE SpeseFrom <=" & intRange & " AND SpeseTo >=" & intRange & ""), "SpeseSpedizione"))) 'lblCartTotale.Text = "" 'lblCartTotale.DataBind() '+++ controllo delle spese aggiuntive di spedizione +++ If CDbl(lblSpesaAggiuntivaValue.Text) > 0 Then lblSpeseSpedizione.Text = String.Format("{0:c}", CDec(CDec(lblSpeseSpedizione.Text) + CDec(lblSpesaAggiuntivaValue.Text))) End If 'UpdatePanelCarrello.Update() '+++ controllo della valorizzazione dello sconto applicato, se applicato... e calcolo del totale +++ If lblScontoApplicatoValue.Text <> "" And IsNumeric(lblScontoApplicatoValue.Text) Then 'If txtSconto.Text <> "" Then 'Dim dmlSconto As Decimal 'dmlSconto = clsgen.EstraiCodiceSconto(CStr(txtSconto.Text)) 'If dmlSconto > 0 Then If lblScontoApplicatoValue.Text > 0 Then lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text)) - CDec(lblScontoApplicatoValue.Text)) Else lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text))) End If Else lblCartTotale.Text = String.Format("{0:c}", CDec(CDec(lblCartTotaleProdotti.Text) + CDec(lblSpeseSpedizione.Text))) End If lblCartTotale.Text = String.Format("{0:c}", CDec(lblCartTotale.Text)) 'UpdatePanelCarrello.Update() '+++ '+++ associazione immagine servizio scelto +++ Dim imgbtnSelezionaPag As ImageButton = CType(e.Item.FindControl("imgbtnSelezionaPagamento"), ImageButton) Dim imgPagamentoSelezionatoPag As Image = CType(e.Item.FindControl("imgPagamentoSelezionato"), Image) imgbtnSelezionaPag.Visible = False imgPagamentoSelezionatoPag.Visible = True Dim ElementiPaga As RepeaterItem For Each ElementiPaga In RepeaterPagamentiAccettati.Items If Not e.Item.ItemIndex = ElementiPaga.ItemIndex Then Dim imgbtnSelezionaPag2 As ImageButton = CType(RepeaterPagamentiAccettati.Items.Item(ElementiPaga.ItemIndex).FindControl("imgbtnSelezionaPagamento"), ImageButton) Dim imgSpedSelezionataPag2 As Image = CType(RepeaterPagamentiAccettati.Items.Item(ElementiPaga.ItemIndex).FindControl("imgPagamentoSelezionato"), Image) imgbtnSelezionaPag2.Visible = True imgSpedSelezionataPag2.Visible = False End If Next ElementiPaga = Nothing imgbtnSelezionaPag = Nothing imgPagamentoSelezionatoPag = Nothing UpdatePanelCarrello.Update() End Select 'UpdatePanelCarrello.Update() Catch ex As Exception If ViewMsgDebug = True Then clsgen.MostraMessaggio(HttpContext.Current.Handler, Resources.ResourceMsg.Errore, ex.Message) 'SEND MAIL CON ERRORE ESTESO Call clsgen.ScriviLog("Carrello.aspx.vb.RepeaterPagamentiAccettati_ItemCommand", ex.Message) clsgen.SendMailProblemi(ex.Message & "<br><br>Errore in fase di ItemCommand dei Pagamenti accettati da carrello") End Try clsgen = Nothing End Sub Protected Sub RepeaterPagamentiAccettati_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles RepeaterPagamentiAccettati.ItemDataBound Dim PanelSpeseAggiuntive As Panel = CType(e.Item.FindControl("PanelSpeseAggiuntive"), Panel) Dim lblSpesaAggiuntivaValue As Label = CType(e.Item.FindControl("lblSpesaAggiuntivaValue"), Label) If CDbl(lblSpesaAggiuntivaValue.Text) = 0 Then PanelSpeseAggiuntive.Visible = False End If End Sub 'Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Dim request As Net.HttpWebRequest = CType(Net.WebRequest.Create("https://www.paypal.com/cgi-bin/webscr"), Net.HttpWebRequest) ' request.Method = "POST" ' Dim content As String = "Test Request Dotnethell" ' Dim encoding As New ASCIIEncoding() ' Dim buffer() As Byte = encoding.GetBytes(content) ' request.ContentType = "application/x-www-form-urlencoded" ' request.ContentLength = content.Length ' Dim newStream As IO.Stream = request.GetRequestStream() ' newStream.Write(Buffer, 0, Buffer.Length) ' newStream.Close() ' Dim response As Net.HttpWebResponse = CType(request.GetResponse, Net.HttpWebResponse) 'End Sub Protected Sub ImgBtnVaiAllaCassa_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnVaiAllaCassa.Click ''MsgBox("CLICK") 'If 0 = 0 Then ' Response.Redirect("Acquista.aspx") 'Else ' 'niente ' Response.End() 'End If 'Dim lblQualeSpedizione As Label = PanelCarrello.FindControl("lblComeSpedisceID") 'If lblQualeSpedizione.Text = "" Then ' MsgBox("NESSUNA SPED") ' Response.Redirect("~/Catalogo/Carrello.aspx") 'End If End Sub Public Sub btnAcquistaControlla(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImgBtnVaiAllaCassa.Click '+++ controlla se sono state selezionate la spedizione ed il tipo di pagamento prima 'di proseguire. Se ci sono prosegue secondo l'impostazione del parametro postbackurl del 'bottone e va a Acquista.aspx, altrimenti viene ridirezionato su Carrello.aspx '+++ Dim lblQualeSpedizione As Label = PanelCarrello.FindControl("lblComeSpedisceID") If lblQualeSpedizione.Text = "" Then 'MsgBox("NESSUNA SPED") 'Dim gen As New ClassGenerali 'gen.MostraMessaggio(Me, Resources.ResourceMsg.Errore, Resources.ResourceMsg.ErroreCarrelloSpedizioneNonSelezionata) 'Response.Redirect("~/Catalogo/Carrello.aspx", True) 'gen = Nothing 'Me.ClientScript.RegisterStartupScript(Me.GetType, "SpedMancante", "alert('Spedizione mancante!');", True) ScriptManager.RegisterStartupScript(Me, Me.GetType, "SpedMancante", "alert('Spedizione mancante!');", True) 'ScriptManager.RegisterStartupScript(Me, Me.GetType, "RedirectMancaSped", "location.href='Carrello.aspx';", True) Exit Sub Else Response.Redirect("~/Catalogo/Acquista.aspx", False) 'ScriptManager.RegisterStartupScript(Me, Me.GetType, "RedirectMancaSped", "location.href='Acquista.aspx';", True) End If 'Dim lblQualePagamento As Label = PanelCarrello.FindControl("lblComePagaID") 'If lblQualePagamento.Text = "" Then ' 'MsgBox("NESSUNA SPED") ' Dim gen As New ClassGenerali ' gen.MostraMessaggio(Me, Resources.ResourceMsg.Errore, Resources.ResourceMsg.ErroreCarrelloTipoPagamentoNonSelezionato) ' Response.Redirect("~/Catalogo/Carrello.aspx") ' gen = Nothing 'End If End Sub End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5