Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

View File

@@ -0,0 +1,418 @@
Option Explicit On
Option Strict On
Imports System.Data
Imports System.Linq
Imports Extensiones
Partial Class Contabilidad_PlantillasPolizasDetalle
Inherits ClsPaginas
#Region "PROPIEDADES"
Private Property DTSubProyectos As DataTable
Get
Return CType(ViewState("DTSubProyectos"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTSubProyectos") = value
End Set
End Property
Public Property DTCuentasContables As DataTable
Get
Return CType(ViewState("DTCuentasContables"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTCuentasContables") = value
End Set
End Property
Private ReadOnly Property CvePlantillaPoliza As Integer
Get
Return ViewState("CvePlantillaPoliza").ToString.ToEntero
End Get
End Property
Public Property DTDetalle As DataTable
Get
Return CType(ViewState("DTDetalle"), DataTable)
End Get
Set(value As DataTable)
ViewState("DTDetalle") = value
End Set
End Property
#End Region
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
ViewState("Orden") = ""
TxtFechaIng.Text = Date.Today.ToString("dd/MM/yyyy")
TxtUsuario.Text = UsuarioActual.CveUsuario.ToString
CreadDTDetalle()
Dim ObjPlantillaPolizasTipo As New ClsContabilidad
If ObjPlantillaPolizasTipo.GetConta_PlantillasPolizasTipo() Then
Dim row As DataRow = ObjPlantillaPolizasTipo.DtResultados().NewRow()
row("CveTipoPlantillaPoliza") = -1
row("TipoPlantillaPoliza") = "Seleccione"
ObjPlantillaPolizasTipo.DtResultados.Rows.Add(row)
ObjPlantillaPolizasTipo.DtResultados.AcceptChanges()
DdlTPP.DataSource = ObjPlantillaPolizasTipo.DtResultados()
DdlTPP.DataBind()
End If
ObjPlantillaPolizasTipo.Dispose()
Dim dt As DataTable = Nothing
If UsuarioActual.Empresa.UsaContabilidad Then
Dim Conta As New ClsContPAQi(UsuarioActual.Empresa)
If Conta.GetCuentas(-1, "-1", 1) Then
dt = Conta.DtResultados
DTCuentasContables = Conta.DtResultados
Session("DtCuentas") = Conta.DtResultados
End If
Conta.Dispose()
End If
CargaCuenta()
CargaDDL()
CargaDDLProveedor()
CargarConcepto()
ViewState("CvePlantillaPoliza") = 0
If Request("CvePlantillaPoliza") IsNot Nothing AndAlso IsNumeric(Request("CvePlantillaPoliza")) AndAlso Request("CvePlantillaPoliza").ToEntero > 0 Then
ViewState("CvePlantillaPoliza") = Request("CvePlantillaPoliza")
TRClave.Visible = False
TxtPlantillaPoliza.Enabled = False
DdlTipoPoliza.Enabled = False
DdlTPP.Enabled = False
ChkEstatus.Enabled = False
BtnGuardar.Visible = False
tableopcional.Visible = False
CargaDatos()
CargaDatosPoliza(CvePlantillaPoliza)
Else
ViewState("CvePlantillaPoliza") = -1
End If
End If
End Sub
#Region "C A R G A - D A T O S"
Public Sub CargaDatos()
Dim ObjPlantillaPolizaDetalle As New ClsContabilidad
If ObjPlantillaPolizaDetalle.GetConta_PlantillasPolizasDetalle(CvePlantillaPoliza, UsuarioActual.CveEmpresa) Then
GvDatos.DataSource = ObjPlantillaPolizaDetalle.DtResultados
ObjPlantillaPolizaDetalle.Dispose()
GvDatos.DataBind()
Else
Me.GvDatos.DataSource = Nothing
End If
OrdenaDatos()
End Sub
Public Sub CargaDatosPoliza(CvePlantillaPoliza As Integer)
Dim ObjPlantillaPolizas As New ClsContabilidad
If ObjPlantillaPolizas.GetConta_PlantillasPolizas(CvePlantillaPoliza, -1) Then
TxtPlantillaPoliza.Text = ObjPlantillaPolizas.PlantillaPoliza
DdlTipoPoliza.SelectedValue = ObjPlantillaPolizas.TipoPoliza.ToString
DdlTPP.SelectedValue = ObjPlantillaPolizas.CveTipoPlantillaPoliza.ToString
If ObjPlantillaPolizas.Estatus = "Activo" Then
ChkEstatus.Checked = True
End If
TxtFechaIng.Text = ObjPlantillaPolizas.FechaIng.ToShortDateString
TxtUsuario.Text = ObjPlantillaPolizas.Usuario
BtnGuardar.Text = "Actualizar"
Else
End If
ObjPlantillaPolizas.Dispose()
End Sub
Private Sub LimpiaDatos()
TxtPlantillaPoliza.Text = ""
DdlTipoPoliza.SelectedValue = "-1"
DdlTPP.SelectedValue = "-1"
ChkEstatus.Checked = False
ViewState("CvePlantillaPoliza") = -1
GvDatos.DataSource = Nothing
GvDatos.DataBind()
UpDatos.Update()
End Sub
Private Sub CargaCuenta()
DdlCtaContable.Items.Clear()
DdlCtaContable.DataSource = DTCuentasContables
DdlCtaContable.DataBind()
DdlCtaContable.Items.Insert(0, New ListItem("Seleccione", "-1"))
End Sub
Private Sub CargarConcepto()
DdlConcepto.DataSource = GlobalDTContaConceptosContables(-1)
DdlConcepto.DataBind()
End Sub
Private Sub CreadDTDetalle()
DTDetalle = New DataTable
DTDetalle.Columns.Add("CvePlantillaPolizaDetalle", GetType(Integer)) 'Consec
DTDetalle.Columns.Add("ConceptoContable", GetType(String))
DTDetalle.Columns.Add("CveConcepto", GetType(Integer))
DTDetalle.Columns.Add("TipoMovimiento", GetType(String))
DTDetalle.Columns.Add("TipoMovto", GetType(Integer))
DTDetalle.Columns.Add("IdCtaContable", GetType(Integer))
DTDetalle.Columns.Add("Orden", GetType(String))
DTDetalle.Columns.Add("Usuario", GetType(String))
End Sub
#End Region
Protected Sub BtnGuardar_Click(sender As Object, e As EventArgs)
Dim ObjPlantillaPoliza As New ClsContabilidad
Dim ErrorPlantilla = False
Dim CvePlantilla = -1
ObjPlantillaPoliza.IniciaTransacSQL()
If CvePlantillaPoliza < 0 Then
If ObjPlantillaPoliza.AddConta_PlantillasPolizas(TxtClave.Text.ToEntero, TxtPlantillaPoliza.Text.Trim, DdlTPP.SelectedValue.ToEntero, DdlTipoPoliza.SelectedValue.ToEntero, ChkEstatus.Checked, TxtFechaIng.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
CvePlantilla = ObjPlantillaPoliza.CvePlantillaPoliza
If DTDetalle.Rows.Count > 0 Then
For Each Row As DataRow In DTDetalle.Rows
If Not ObjPlantillaPoliza.AddConta_PlantillasPolizasDetalles(CvePlantilla, Row("CveConcepto").ToString.ToEntero, Row("TipoMovto").ToString.ToEntero, Row("IdCtaContable").ToString.ToEntero, Row("Orden").ToString.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DDLSubProyecto.SelectedValue.ToEntero, DDLProveedor.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero) Then
ErrorPlantilla = True
Exit For
End If
Next
End If
Else
ErrorPlantilla = True
End If
Else
If ObjPlantillaPoliza.UpdateConta_PlantillasPolizas(TxtPlantillaPoliza.Text.Trim, DdlTPP.SelectedValue.ToEntero, DdlTipoPoliza.SelectedValue.ToEntero, ChkEstatus.Checked, CvePlantillaPoliza) Then
ObjPlantillaPoliza.Commit()
ObjPlantillaPoliza.Dispose()
LimpiaDatos()
Alert("La Plantilla Póliza y sus Detalles fueron Actualizados correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Contabilidad/PlantillasPolizas.aspx?"";")
Exit Sub
Else
ErrorPlantilla = True
End If
End If
If Not ErrorPlantilla Then
ObjPlantillaPoliza.Commit()
LimpiaDatos()
Alert("La Plantilla Póliza y su Detalle fue agregado correctamente.", TipoMensaje.MsgInformacion, "document.location.href=""/Contabilidad/PlantillasPolizas.aspx?"";")
Else
ObjPlantillaPoliza.RollBack()
Alert("Error al agregar la Plantilla Póliza y el Detalle.", TipoMensaje.MsgError)
End If
ObjPlantillaPoliza.Dispose()
End Sub
Public Sub updatatos()
Dim ObjPlantillaPolizaDetalle As New ClsContabilidad
If ObjPlantillaPolizaDetalle.GetConta_PlantillasPolizasDetalle(-1, -1) Then
ViewState("DTPlantillaPolizaDetalle") = ObjPlantillaPolizaDetalle.DtResultados.FiltraParametros(String.Format(" CvePlantillaPoliza={0} AND CveEmpresa = {1}", CvePlantillaPoliza, UsuarioActual.CveEmpresa))
GlobalDTContaPlantillasPolizasDetalle(CvePlantillaPoliza) = ObjPlantillaPolizaDetalle.DtResultados
End If
If ObjPlantillaPolizaDetalle.GetConta_PlantillasPolizas(-1, -1) Then
GlobalDTContaPlantillasPolizas(UsuarioActual.CveEmpresa) = ObjPlantillaPolizaDetalle.DtResultados
End If
ObjPlantillaPolizaDetalle.Dispose()
End Sub
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
OcultaDiv()
Dim ObjPlantillaPolizaDetalle As New ClsContabilidad
Dim Row As DataRow
Dim ErrorActualizar = False
Dim ErrorDetalle = False
If HdnModalidad.Value = "I" Then
If CvePlantillaPoliza > 0 Then
If ObjPlantillaPolizaDetalle.AddConta_PlantillasPolizasDetalles(CvePlantillaPoliza, DdlConcepto.SelectedValue.ToEntero, DdlTipoMovimiento.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.ToEntero, TxtOrden.Text.Trim.ToEntero, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DDLSubProyecto.SelectedValue.ToEntero, DDLProveedor.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero) Then
TxtOrden.Text = ""
updatatos()
Alert("El nuevo Registro se guardó correctamente.", TipoMensaje.MsgInformacion)
UpTitulos.Update()
Else
ErrorDetalle = True
End If
Else
Try
Row = DTDetalle.NewRow
Row("CvePlantillaPolizaDetalle") = DTDetalle.Rows.Count + 1
Row("ConceptoContable") = DdlConcepto.SelectedItem.ToString
Row("CveConcepto") = DdlConcepto.SelectedValue.ToEntero
Row("TipoMovimiento") = DdlTipoMovimiento.SelectedItem.ToString
Row("TipoMovto") = DdlTipoMovimiento.SelectedValue.ToEntero
Row("IdCtaContable") = DdlCtaContable.SelectedValue.ToEntero
Row("Orden") = TxtOrden.Text.Trim.ToEntero
Row("Usuario") = UsuarioActual.Usuario
DTDetalle.Rows.Add(Row)
TxtOrden.Text = ""
UpTitulos.Update()
Catch ex As Exception
ErrorDetalle = True
End Try
End If
Else
If HdnID.Value.ToEntero <> -1 Then
If CvePlantillaPoliza > 0 Then
If ObjPlantillaPolizaDetalle.UpdateConta_PlantillasPolizasDetalle(DdlConcepto.SelectedValue.ToEntero, DdlTipoMovimiento.SelectedValue.ToEntero, DdlCtaContable.SelectedValue.ToEntero, TxtOrden.Text.Trim.ToEntero,
HdnID.Value.ToEntero, DDLSubProyecto.SelectedValue.ToEntero, DDLProveedor.SelectedValue.ToEntero, DdlPersonal.SelectedValue.ToEntero) Then
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
updatatos()
Else
ErrorActualizar = True
End If
Else
Try
Row = DTDetalle.NewRow
Row("CvePlantillaPolizaDetalle") = DTDetalle.Rows.Count + 1
Row("ConceptoContable") = DdlConcepto.SelectedItem.ToString
Row("CveConcepto") = DdlConcepto.SelectedValue.ToEntero
Row("TipoMovimiento") = DdlTipoMovimiento.SelectedItem.ToString
Row("TipoMovto") = DdlTipoMovimiento.SelectedValue.ToEntero
Row("IdCtaContable") = DdlCtaContable.SelectedValue.ToEntero
Row("Orden") = TxtOrden.Text.Trim.ToEntero
Row("Usuario") = UsuarioActual.Usuario
DTDetalle.Rows.Add(Row)
Catch ex As Exception
ErrorActualizar = True
End Try
End If
End If
End If
ObjPlantillaPolizaDetalle.Dispose()
CargaDatos()
UpDatos.Update()
End Sub
#Region "G V - D A T O S"
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim Cuenta As Integer = e.Row.DataKey("IdCtaContable").ToString.ToEntero
e.Row.FCLiteral("LtlCtaContable").Text = DTCuentasContables.FiltroPrimeroValor("Nombre", $"Id = {Cuenta}")
End If
End Sub
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
Dim ObjPlantillaPolizaDetalle As New ClsContabilidad
If CvePlantillaPoliza > 0 Then
If ObjPlantillaPolizaDetalle.RemoveConta_PlantillasPolizasDetalle(CvePlantillaPoliza, GvDatos.Rows(e.RowIndex).DataKey("CvePlantillaPolizaDetalle").ToString.ToEntero) Then
GvDatos.EditIndex = -1
updatatos()
Alert("El Concepto se eliminó correctamente.", TipoMensaje.MsgInformacion)
End If
Else
Dim index = GvDatos.Rows(e.RowIndex).DataKey("CvePlantillaPolizaDetalle").ToString.ToEntero - 1
DTDetalle.Rows.RemoveAt(index)
End If
ObjPlantillaPolizaDetalle.Dispose()
CargaDatos()
End Sub
#End Region
Public Sub CargaDDL()
DTSubProyectos = GlobalDTSubProyectos(-1, CveEmpresa:=UsuarioActual.CveEmpresa)
DDLSubProyecto.DataSource = DTSubProyectos
DDLSubProyecto.DataBind()
DDLSubProyecto.Items.Insert(0, New ListItem(" - ", "-1"))
End Sub
Private Sub CargaDDLProveedor()
DDLProveedor.DataSource = GlobalDTCompProveedores(UsuarioActual.CveEmpresa)
DDLProveedor.DataBind()
DDLProveedor.Items.Insert(0, New ListItem(" - ", "-1"))
DdlPersonal.DataSource = GlobalDTRHPersonal(UsuarioActual.CveEmpresa)
DdlPersonal.DataBind()
DdlPersonal.Items.Insert(0, New ListItem(" - ", "-1"))
End Sub
Private Sub DdlConcepto_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlConcepto.SelectedIndexChanged
If DdlConcepto.SelectedValue.Contiene("130", "29") Then
DdlPersonal.Visible = True
LblPersonal.Visible = True
Else
DdlPersonal.Visible = False
LblPersonal.Visible = False
End If
End Sub
#Region " O R D E N A M I E N T O JAVASCRIPT"
Private Sub OrdenaDatos()
If (GvDatos.Rows.Count > 0) Then
GvDatos.UseAccessibleHeader = True
GvDatos.HeaderRow.TableSection = TableRowSection.TableHeader
RegistraScript("OrdenarGV();")
End If
End Sub
#End Region
Private Sub OcultaDiv()
ScriptManager.RegisterStartupScript(Me, Me.GetType, "Llave", "HideDivRegistro();", True)
End Sub
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnModalidad.Value = "U"
HdnID.Value = GvRow.DataKey("CvePlantillaPolizaDetalle")
DdlConcepto.SelectedValueExist(GvRow.DataKey("CveConcepto"))
DdlTipoMovimiento.SelectedValueExist(IIf(GvRow.DataKey("TipoMovimiento") = "Abono", 1, 0).ToString)
DdlCtaContable.SelectedValueExist(GvRow.DataKey("IdCtaContable"))
DDLSubProyecto.SelectedValueExist(GvRow.DataKey("CveSubProyecto"))
TxtOrden.Text = GvRow.DataKey("Orden")
LbAgregar.Text = "Actualizar"
LtlTituloModal.Text = String.Format("{0}{1}", "Actualizar Concepto: ", DdlConcepto.SelectedItem)
If DdlConcepto.SelectedValue.Contiene("130", "29") Then
DdlPersonal.SelectedValueExist(GvRow.DataKey("CvePersonal"))
DdlPersonal.Visible = True
LblPersonal.Visible = True
Else
DdlPersonal.SelectedIndex = 0
DdlPersonal.Visible = False
LblPersonal.Visible = False
End If
UpModal.Update()
RegistraScript(String.Format("$('#{0}').modal();", "divAgregarSucursal"))
CargaDatos()
End Sub
Public Sub BtnAgregarSucursalModal_Click(sender As Object, e As EventArgs)
DdlPersonal.Visible = False
LblPersonal.Visible = False
LbAgregar.Text = "Agregar"
LtlTituloModal.Text = "Agregar Concepto Contable"
DdlConcepto.SelectedIndex = 0
DdlTipoMovimiento.SelectedIndex = 0
DdlCtaContable.SelectedIndex = 0
DDLSubProyecto.SelectedIndex = 0
DDLProveedor.SelectedIndex = 0
DdlPersonal.SelectedIndex = 0
TxtOrden.Text = ""
UpModal.Update()
HdnModalidad.Value = "I"
RegistraScript(String.Format("$('#{0}').modal();", "divAgregarSucursal"))
End Sub
End Class