PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/Paginas/PaginasAdmin/EditarPreciosRegionales.aspx.vb

https://gitlab.com/Jaem95/DisaApp
Visual Basic | 285 lines | 212 code | 71 blank | 2 comment | 0 complexity | 188290a42deb5f7df5f42b37fcb5cb48 MD5 | raw file
  1. Imports System
  2. Imports System.Globalization
  3. Public Class EditarPreciosRegionales
  4. Inherits System.Web.UI.Page
  5. Dim ADGeneral As ADGeneral = New ADGeneral()
  6. Dim ProductosAD As ProductosAD = New ProductosAD()
  7. Dim EditarPrecios As EditarPreciosAD = New EditarPreciosAD()
  8. Dim usuario As String
  9. Dim pwd As String
  10. Dim ubicacion As String
  11. Dim tipoUsuario As String
  12. Dim informacionUsuario As New List(Of String)
  13. Dim Accion As String = ""
  14. Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
  15. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  16. Dim ds As New Data.DataSet
  17. Dim informacionProducto As New List(Of String)
  18. usuario = CType((Session("usuario")), String)
  19. pwd = CType((Session("pwd")), String)
  20. tipoUsuario = CType((Session("tipoUsuario")), String)
  21. ubicacion = CType((Session("ubicacion")), String)
  22. Accion = Request.QueryString("Accion")
  23. If IsPostBack Then Return
  24. If usuario Is Nothing Or pwd Is Nothing Or tipoUsuario Is Nothing Or ubicacion Is Nothing Then
  25. Response.Redirect("/Login.aspx")
  26. Else
  27. informacionUsuario = ADGeneral.ConsultarInformacion(usuario)
  28. If informacionUsuario.Count() > 0 Then
  29. lblNombre2.Text = informacionUsuario(0) & " " & informacionUsuario(1)
  30. lblNombre3.Text = informacionUsuario(0) & " " & informacionUsuario(1)
  31. lblNombre4.Text = informacionUsuario(0) & " " & informacionUsuario(1)
  32. imageUsuario1.ImageUrl = informacionUsuario(13)
  33. imageUsuario2.ImageUrl = informacionUsuario(13)
  34. imageUsuario3.ImageUrl = informacionUsuario(13)
  35. End If
  36. If Not IsPostBack Then
  37. ds = ADGeneral.ConsultarRegiones()
  38. If ds.Tables(0).Rows.Count > 0 Then
  39. ddlRegion.DataSource = ds.Tables("Region").DefaultView
  40. ddlRegion.DataValueField = "id"
  41. ddlRegion.DataTextField = "nombre"
  42. ddlRegion.DataBind()
  43. End If
  44. End If
  45. If Not Accion Is Nothing Then
  46. txtCodigoBarras.Text = Request.QueryString("Accion").ToString()
  47. informacionProducto = ADGeneral.ConsultarInformacionProducto(Request.QueryString("Accion").ToString())
  48. txtNombreProducto.Text = informacionProducto(0)
  49. txtDescProducto.Text = informacionProducto(1)
  50. txtPresentacionProducto.Text = informacionProducto(2)
  51. txtCantidadPorCaja.Text = informacionProducto(3)
  52. txtClasificacion.Text = informacionProducto(6)
  53. txtCodigoBarras.Text = Request.QueryString("Accion").ToString()
  54. imagenProducto.ImageUrl = informacionProducto(9)
  55. txtIDClas.Text = informacionProducto(11)
  56. End If
  57. End If
  58. BuscarPrecioRegion(ddlRegion.SelectedValue)
  59. End Sub
  60. Private Sub BuscarPrecioRegion(selectedValue As String)
  61. Dim precioPorRegion As New List(Of String)
  62. precioPorRegion = EditarPrecios.ConsultarPreciosPorRegion(Request.QueryString("Accion"), selectedValue)
  63. If precioPorRegion.Count() > 0 Then
  64. txtPrecioRI1.Text = precioPorRegion(0)
  65. txtPrecioRF1.Text = precioPorRegion(1)
  66. txtPrecio1.Text = precioPorRegion(2)
  67. txtPrecioRI2.Text = precioPorRegion(3)
  68. txtPrecioRF2.Text = precioPorRegion(4)
  69. txtPrecio2.Text = precioPorRegion(5)
  70. txtPrecioRI3.Text = precioPorRegion(6)
  71. txtPrecioRF3.Text = precioPorRegion(7)
  72. txtPrecio3.Text = precioPorRegion(8)
  73. Else
  74. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Este producto no tiene precio en esta region');</script>", False)
  75. txtPrecioRI1.Text = ""
  76. txtPrecioRF1.Text = ""
  77. txtPrecio1.Text = ""
  78. txtPrecioRI2.Text = ""
  79. txtPrecioRF2.Text = ""
  80. txtPrecio2.Text = ""
  81. txtPrecioRI3.Text = ""
  82. txtPrecioRF3.Text = ""
  83. txtPrecio3.Text = ""
  84. End If
  85. End Sub
  86. Private Sub BuscarPrecioGeneral()
  87. Dim precioPorRegion As New List(Of String)
  88. precioPorRegion = EditarPrecios.ConsultarPreciosGenerales(Request.QueryString("Accion"))
  89. If precioPorRegion.Count() > 0 Then
  90. txtPrecioRI1.Text = precioPorRegion(0)
  91. txtPrecioRF1.Text = precioPorRegion(1)
  92. txtPrecio1.Text = precioPorRegion(2)
  93. txtPrecioRI2.Text = precioPorRegion(3)
  94. txtPrecioRF2.Text = precioPorRegion(4)
  95. txtPrecio2.Text = precioPorRegion(5)
  96. txtPrecioRI3.Text = precioPorRegion(6)
  97. txtPrecioRF3.Text = precioPorRegion(7)
  98. txtPrecio3.Text = precioPorRegion(8)
  99. Else
  100. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Este producto no tiene precio general');</script>", False)
  101. txtPrecioRI1.Text = ""
  102. txtPrecioRF1.Text = ""
  103. txtPrecio1.Text = ""
  104. txtPrecioRI2.Text = ""
  105. txtPrecioRF2.Text = ""
  106. txtPrecio2.Text = ""
  107. txtPrecioRI3.Text = ""
  108. txtPrecioRF3.Text = ""
  109. txtPrecio3.Text = ""
  110. End If
  111. End Sub
  112. Public Sub PonerInformacionEnCampos(informacion As List(Of String), codigoBarras As String)
  113. txtNombreProducto.Text = informacion(0)
  114. txtDescProducto.Text = informacion(1)
  115. txtPresentacionProducto.Text = informacion(2)
  116. txtCantidadPorCaja.Text = informacion(3)
  117. txtClasificacion.Text = informacion(6)
  118. If codigoBarras.Equals("") Then
  119. txtCodigoBarras.Text = Request.QueryString("Accion").ToString()
  120. Else
  121. txtCodigoBarras.Text = codigoBarras
  122. End If
  123. imagenProducto.ImageUrl = informacion(9)
  124. End Sub
  125. Protected Sub rbtnPrecioGeneral_SelectedIndexChanged(sender As Object, e As EventArgs)
  126. Dim precioPorRegion As New List(Of String)
  127. If rbtnPrecio.SelectedValue = "PrecioGeneral" Then
  128. rbtnPrecio.Items(1).Selected = False
  129. 'Traigo lso precios generales del producto
  130. BuscarPrecioGeneral()
  131. txtPrecioRI1.Enabled = False
  132. txtPrecioRF1.Enabled = False
  133. txtPrecio1.Enabled = False
  134. txtPrecioRI2.Enabled = False
  135. txtPrecioRF2.Enabled = False
  136. txtPrecio2.Enabled = False
  137. txtPrecioRI3.Enabled = False
  138. txtPrecioRF3.Enabled = False
  139. txtPrecio3.Enabled = False
  140. ElseIf rbtnPrecio.SelectedValue = "PrecioRegional" Then
  141. rbtnPrecio.Items(0).Selected = False
  142. BuscarPrecioRegion(ddlRegion.SelectedValue)
  143. txtPrecioRI1.Enabled = True
  144. txtPrecioRF1.Enabled = True
  145. txtPrecio1.Enabled = True
  146. txtPrecioRI2.Enabled = True
  147. txtPrecioRF2.Enabled = True
  148. txtPrecio2.Enabled = True
  149. txtPrecioRI3.Enabled = True
  150. txtPrecioRF3.Enabled = True
  151. txtPrecio3.Enabled = True
  152. End If
  153. End Sub
  154. Protected Sub btnGuardarCambios_Click(sender As Object, e As EventArgs) Handles btnGuardarCambios.Click
  155. Dim confirmValue As String = Request.Form("confirm_value")
  156. Dim script As String = ""
  157. Dim tipoPrecio As String = ""
  158. If confirmValue = "No" Then Return
  159. If Not IsNumeric(txtPrecio1.Text) Or Not IsNumeric(txtPrecio2.Text) Or Not IsNumeric(txtPrecio3.Text) Or Not IsNumeric(txtPrecioRI1.Text) Or Not IsNumeric(txtPrecioRI2.Text) Or Not IsNumeric(txtPrecioRI3.Text) Or Not IsNumeric(txtPrecioRF1.Text) Or Not IsNumeric(txtPrecioRF2.Text) Or Not IsNumeric(txtPrecioRF3.Text) Then
  160. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Solo numeros en los rangos de precio!');</script>", False)
  161. Else
  162. If rbtnPrecio.SelectedValue = "" Then
  163. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Selecciona el precio a aplicar!');</script>", False)
  164. Else
  165. tipoPrecio = rbtnPrecio.SelectedValue()
  166. If EditarPrecios.BorraPreciosViejos(Request.QueryString("Accion").ToString(), ddlRegion.SelectedValue(), txtIDClas.Text) Then
  167. If EditarPrecios.RegistrarPrecios(Request.QueryString("Accion").ToString(), txtPrecio1.Text, txtPrecioRI1.Text(), txtPrecioRF1.Text(), ddlRegion.SelectedValue()) Then
  168. If EditarPrecios.RegistrarPrecios(Request.QueryString("Accion").ToString(), txtPrecio2.Text, txtPrecioRI2.Text(), txtPrecioRF2.Text(), ddlRegion.SelectedValue()) Then
  169. If EditarPrecios.RegistrarPrecios(Request.QueryString("Accion").ToString(), txtPrecio3.Text, txtPrecioRI3.Text(), txtPrecioRF3.Text(), ddlRegion.SelectedValue()) Then
  170. If EditarPrecios.ActualizarBanderaPrecio(Request.QueryString("Accion").ToString(), tipoPrecio, ddlRegion.SelectedValue()) Then
  171. ''VER PORQUE LA TABLA DE PRECIOS TIENE REGION
  172. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('REGISTRO DE PRECIO REGIONAL PARA EL PRODUCTO " & Request.QueryString("Accion").ToString() & " EN LA REGION: " + ddlRegion.SelectedItem.ToString + "');window.location='PreciosGenerales.aspx';</script>", False)
  173. Else
  174. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Error en el registro');</script>", False)
  175. End If
  176. Else
  177. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Error en el registro');</script>", False)
  178. End If
  179. Else
  180. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Error en el registro');</script>", False)
  181. End If
  182. Else
  183. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Error en el registro');</script>", False)
  184. End If
  185. Else
  186. ScriptManager.RegisterStartupScript(Me, GetType(Page), "temp", "<script language='javascript'>alert('Error en el registro');</script>", False)
  187. End If
  188. End If
  189. End If
  190. txtNombreProducto.Attributes.Add("value", txtNombreProducto.Text())
  191. End Sub
  192. Protected Sub ddlRegion_SelectedIndexChanged(sender As Object, e As EventArgs)
  193. rbtnPrecio.SelectedValue = Nothing
  194. txtPrecioRI1.Enabled = True
  195. txtPrecioRF1.Enabled = True
  196. txtPrecio1.Enabled = True
  197. txtPrecioRI2.Enabled = True
  198. txtPrecioRF2.Enabled = True
  199. txtPrecio2.Enabled = True
  200. txtPrecioRI3.Enabled = True
  201. txtPrecioRF3.Enabled = True
  202. txtPrecio3.Enabled = True
  203. BuscarPrecioRegion(ddlRegion.SelectedValue)
  204. End Sub
  205. Protected Sub btnCerrarSesion_Click(sender As Object, e As EventArgs)
  206. FormsAuthentication.SignOut()
  207. usuario = vbNull
  208. pwd = vbNull
  209. Session.Remove("usuario")
  210. Session.Remove("contra")
  211. Session.Abandon()
  212. Response.Redirect("/Login.aspx")
  213. End Sub
  214. End Class