Modificar precio de PS por Marca

This commit is contained in:
janeth arvizu
2019-08-30 12:48:46 -07:00
parent 11ee44c8d6
commit 41b8e23d9a
5 changed files with 524 additions and 68 deletions

View File

@@ -1253,6 +1253,7 @@ Partial Class Clientes
'CargaFormaPago33()
'CargaComboCFDI()
LnkPorcentajeMarcas.Visible = True
LnkPorcentajePrecios.Visible = True
If UsuarioActual.TienePermisoProceso(261) Then LnkVerGrafica.Visible = True
@@ -8132,14 +8133,12 @@ Partial Class Clientes
End Sub
#End Region
#Region "PORCENTAJE PRECIO DE PRODUCTOS"
Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click
RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios"))
#Region "PORCENTAJE PRECIO DE MARCAS"
Private Sub LnkPorcentajeMarcas_Click(sender As Object, e As EventArgs) Handles LnkPorcentajeMarcas.Click
RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajeMarcas"))
CreaDT()
'txtPorcentaje.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5"))
'CargaPorcentajesProductos()
CargaMarcas()
LimpiaModalPorcentaje()
End Sub
@@ -8156,6 +8155,7 @@ Partial Class Clientes
DTPorcentajeTemp.Columns.Add(column)
DTPorcentajeTemp.Columns.Add("CveMarca", GetType(Integer))
DTPorcentajeTemp.Columns.Add("Marca", GetType(String))
DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal))
DTPorcentajeTemp.Columns.Add("Estatus", GetType(String))
DTPorcentajePrecios = DTPorcentajeTemp.Clone
@@ -8171,58 +8171,11 @@ Partial Class Clientes
CargaGridPorcentajes()
UpPorcentaje.Update()
End Sub
'Private Sub CargaPorcentajesProductos()
' 'Llenar el dropdownlist de Secciones
' If UsuarioActual.CveEmpresa = 66 Then
' DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
' Else
' Dim ObjClasificaciones As New ClsClasificaciones
' If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
' DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados
' End If
' ObjClasificaciones.Dispose()
' End If
' DdlClasificacion2.DataBind()
' CargaPS()
' CargaGridPorcentajes()
' UpPorcentaje.Update()
'End Sub
'Private Sub CargaPS()
' DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
' If UsuarioActual.CveEmpresa = 66 Then
' DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
' End If
' If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
' DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
' DdlProducto2.DataBind()
' DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
' End If
'End Sub
'Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange
' DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
'End Sub
'Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost)
' Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
' If drPS IsNot Nothing Then
' Dim Precio = drPS("Precio").ToString.ToDouble
' LbPrecioG.Text = Precio.FormatoNumero()
' LbPrecioA.Text = ((Precio * txtPorcentaje.Text.ToDecimal) / 100).FormatoNumero
' End If
'End Sub
Private Sub CargaGridPorcentajes()
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPorcentajeProductos(CveCliente) Then
If ObjPS.GetPorcentajeMarcas(CveCliente) Then
DTPorcentajePrecios = ObjPS.DtResultados
GvM.DataSource = DTPorcentajePrecios
End If
@@ -8244,13 +8197,14 @@ Partial Class Clientes
DdlMarcaPS.SelectedValue = "-1"
End Sub
Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
Protected Sub LbAgregarMarca_Click(sender As Object, e As EventArgs) Handles LbAgregarMarca.Click
If txtPorcentaje.Text.ToDecimal >= 0 And txtPorcentaje.Text.ToDecimal <= 100 Then
Dim registro As DataRow = DTPorcentajePrecios.NewRow
registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1
registro.Item("CveMarca") = DdlMarcaPS.SelectedValue.ToEntero
registro.Item("Marca") = DdlMarcaPS.SelectedItem.Text
registro.Item("PorcentajeProducto") = txtPorcentaje.Text.ToDecimal
registro.Item("Estatus") = "I"
DTPorcentajePrecios.Rows.Add(registro)
@@ -8262,7 +8216,7 @@ Partial Class Clientes
LimpiaModalPorcentaje()
End Sub
Protected Sub DeleteRow(sender As Object, e As EventArgs)
Protected Sub DeleteRowMarca(sender As Object, e As EventArgs)
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
@@ -8322,6 +8276,238 @@ Partial Class Clientes
End Sub
Protected Sub BtnGuardarPorcentajesMarca_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajesMarca.Click
Dim TieneError As Boolean = False
Dim ObjPS As New ClsProductosServicios
ObjPS.IniciaTransacSQL()
For Each Dr As DataRow In DTPorcentajePrecios.Rows
If Dr("Estatus").ToString <> "" Then
If Dr("Estatus").ToString = "I" Then
If Not ObjPS.AddPorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal, UsuarioActual.CveUsuario) Then
TieneError = True
End If
ElseIf Dr("Estatus").ToString = "U" Then
If Not ObjPS.UpdatePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero, Dr("PorcentajeProducto").ToString.ToDecimal) Then
TieneError = True
End If
ElseIf Dr("Estatus").ToString = "D" Then
If Not ObjPS.RemovePorcentajeMarcas(CveCliente, Dr("CveMarca").ToString.ToEntero) Then
TieneError = True
End If
End If
End If
Next
If TieneError Then
ObjPS.RollBack()
Else
ObjPS.Commit()
Alert("Los Porcentajes se guardaron correctamente.", TipoMensaje.MsgInformacion)
RegistraScript("$('#DivPorcentajeMarcas').modal('hide')", "hidemodal")
End If
ObjPS.Dispose()
End Sub
#End Region
#Region "PORCENTAJE PRECIO DE PRODUCTOS"
Private Sub LnkPorcentajePrecios_Click(sender As Object, e As EventArgs) Handles LnkPorcentajePrecios.Click
RegistraScript(String.Format("$('#{0}').modal();", "DivPorcentajePrecios"))
CreaDT2()
TxtPorcentajePS.Attributes.Add("onchange", String.Format("FnCambiaPorcentaje({0});", "5"))
CargaPorcentajesProductos()
LimpiaModalPorcentaje2()
End Sub
Private Sub CreaDT2()
Dim DTPorcentajeTemp As New DataTable
Dim column As DataColumn = New DataColumn("No")
column.DataType = Type.GetType("System.Int32")
With column
.AutoIncrement = True
.AutoIncrementSeed = 1
.AutoIncrementStep = 1
End With
DTPorcentajeTemp.Columns.Add(column)
DTPorcentajeTemp.Columns.Add("CvePS", GetType(Integer))
DTPorcentajeTemp.Columns.Add("Producto", GetType(String))
DTPorcentajeTemp.Columns.Add("PrecioG", GetType(Decimal))
DTPorcentajeTemp.Columns.Add("PorcentajeProducto", GetType(Decimal))
DTPorcentajeTemp.Columns.Add("PrecioA", GetType(Decimal))
DTPorcentajeTemp.Columns.Add("Estatus", GetType(String))
DTPorcentajePrecios = DTPorcentajeTemp.Clone
End Sub
Private Sub CargaPorcentajesProductos()
'Llenar el dropdownlist de Secciones
If UsuarioActual.CveEmpresa = 66 Then
DdlClasificacion2.DataSource = GlobalDTSubFamilias(UsuarioActual.CveEmpresa).FiltraParametros("", Orderby:="Clasificacion")
Else
Dim ObjClasificaciones As New ClsClasificaciones
If ObjClasificaciones.GetClasificacionesExistencias(UsuarioActual.CveEmpresa) Then
DdlClasificacion2.DataSource = ObjClasificaciones.DtResultados
End If
ObjClasificaciones.Dispose()
End If
DdlClasificacion2.DataBind()
CargaPS()
CargaGridPorcentajes2()
UpPorcentajeP.Update()
End Sub
Private Sub CargaPS()
DdlProducto2.setEsWebService(UsuarioActual.Empresa.Funcionalidad(105) = "1")
If UsuarioActual.CveEmpresa = 66 Then
DdlProducto2.ddlWS.Attributes.Add("data-pagina", "Inventarios")
End If
If Not DdlProducto2.UsaWebService AndAlso CType(DdlProducto2.DataSource, DataTable) Is Nothing Then
DdlProducto2.DataSource = GlobalDTPSSimplificado(UsuarioActual.CveEmpresa).FiltraParametros("CveTipoPS = 2")
DdlProducto2.DataBind()
DdlProducto2.ddl.Items.Insert(0, New ListItem("Seleccione", "-1"))
End If
End Sub
Protected Sub DdlProducto2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DdlProducto2.selectedindexchange
DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
End Sub
Private Sub DdlProducto2IndexChange(CvePSParametro As Integer, Ddl As ADServerControl.Dropdownlost)
Dim drPS As DataRow = GlobalDTPS(UsuarioActual.CveEmpresa, CvePS:=CvePSParametro).FiltroPrimero("")
If drPS IsNot Nothing Then
Dim Precio = drPS("Precio").ToString.ToDouble
LbPrecioG.Text = Precio.FormatoNumero()
LbPrecioA.Text = ((Precio * TxtPorcentajePS.Text.ToDecimal) / 100).FormatoNumero
End If
End Sub
Private Sub CargaGridPorcentajes2()
Dim ObjPS As New ClsProductosServicios
If ObjPS.GetPorcentajeProductos(CveCliente) Then
DTPorcentajePrecios = ObjPS.DtResultados
GvP.DataSource = DTPorcentajePrecios
End If
ObjPS.Dispose()
GvP.DataBind()
UpPorcentajePS.Update()
End Sub
Private Sub CargaDTPorcentajePrecios2(DtTemp As DataTable)
GvP.DataSource = DtTemp
GvP.DataBind()
UpPorcentajePS.Update()
End Sub
Private Sub LimpiaModalPorcentaje2()
TxtPorcentajePS.Text = ""
DdlClasificacion2.SelectedValue = "-1"
DdlProducto2.SelectedText = ""
End Sub
Protected Sub LbAgregar_Click(sender As Object, e As EventArgs) Handles LbAgregar.Click
If DdlProducto2.SelectedText <> "" Then
If TxtPorcentajePS.Text.ToDecimal >= 0 And TxtPorcentajePS.Text.ToDecimal <= 100 Then
Dim registro As DataRow = DTPorcentajePrecios.NewRow
registro.Item("No") = DTPorcentajePrecios.Rows.Count + 1
registro.Item("CvePS") = DdlProducto2.SelectedValue.ToEntero
registro.Item("Producto") = DdlProducto2.SelectedText
registro.Item("PrecioG") = LbPrecioG.Text.ToDecimal
registro.Item("PrecioA") = LbPrecioG.Text.ToDecimal * TxtPorcentajePS.Text.ToDecimal / 100
registro.Item("PorcentajeProducto") = TxtPorcentajePS.Text.ToDecimal
registro.Item("Estatus") = "I"
DTPorcentajePrecios.Rows.Add(registro)
CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
Else
Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
End If
Else
Alert("El campo <b>''Producto''</b> es necesario, por favor ingréselo.", TipoMensaje.MsgAdvertencia)
End If
LimpiaModalPorcentaje()
End Sub
Protected Sub DeleteRow(sender As Object, e As EventArgs)
Dim lnkRemove As LinkButton = DirectCast(sender, LinkButton)
If DTPorcentajePrecios.Rows.Count > 0 And lnkRemove.CommandArgument.ToString.Length > 0 Then
Dim i As Integer
i = lnkRemove.CommandArgument.ToString.ToEntero
Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", i))
If Drs.Count > 0 Then
If CveCliente > 0 AndAlso Drs(0)("CvePS").ToString.ToEntero > 0 Then
Drs(0)("Estatus") = "D"
Else
Drs(0).Delete()
End If
End If
DTPorcentajePrecios.AcceptChanges()
End If
GvP.EditIndex = -1
CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
End Sub
Protected Sub GvP_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles GvP.RowEditing
GvP.EditIndex = e.NewEditIndex
CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
End Sub
Protected Sub GvP_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles GvP.RowCancelingEdit
GvP.EditIndex = -1
CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
End Sub
Protected Sub GvP_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles GvP.RowUpdating
Dim PorcentajeProducto As Double = GvP.Rows(e.RowIndex).FCTextBox("TxtPorcentajeP").Text.ToDouble
If PorcentajeProducto >= 0 And PorcentajeProducto <= 100 Then
Dim No As Integer = GvP.Rows(e.RowIndex).DataKey("No").ToEntero
Dim Drs As DataRow() = DTPorcentajePrecios.Select(String.Format("No = {0}", No))
If Drs.Count > 0 Then
Drs(0)("PorcentajeProducto") = PorcentajeProducto
Drs(0)("PrecioA") = Drs(0)("PrecioG").ToString.ToDouble * PorcentajeProducto / 100
Drs(0)("Estatus") = "U"
End If
DTPorcentajePrecios.AcceptChanges()
GvP.EditIndex = -1
CargaDTPorcentajePrecios2(DTPorcentajePrecios.FiltraParametros("Estatus <> 'D' "))
Else
Alert("El Porcentaje debe estar en un rango entre 0 y 100", TipoMensaje.MsgAdvertencia)
End If
End Sub
Protected Sub BtnGuardarPorcentajes_Click(sender As Object, e As EventArgs) Handles BtnGuardarPorcentajes.Click
Dim TieneError As Boolean = False
@@ -8362,9 +8548,9 @@ Partial Class Clientes
End Sub
'Protected Sub BtnCambiaPorcentaje_Click(sender As Object, e As EventArgs)
' DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
'End Sub
Protected Sub BtnCambiaPorcentaje_Click(sender As Object, e As EventArgs)
DdlProducto2IndexChange(DdlProducto2.SelectedValue.ToEntero, DdlProducto2)
End Sub
#End Region
#Region " A C U M U L A D O R E S"