Option Explicit On Option Strict On Imports System.Data Imports System.Linq Imports Extensiones Partial Class AC_PresupuestoIngresos Inherits ClsPaginas #Region "PROPIEDADES" Private Property CvePresupuestoIngresos As Integer Get CvePresupuestoIngresos = ViewState("CvePresupuestoIngresos").ToString.ToEntero End Get Set(value As Integer) ViewState("CvePresupuestoIngresos") = value End Set End Property Private Property EsProyecto As Integer Get EsProyecto = ViewState("EsProyecto").ToString.ToEntero End Get Set(value As Integer) ViewState("EsProyecto") = value End Set End Property Private Property Bloqueado As Integer Get Bloqueado = ViewState("Bloqueado").ToString.ToEntero End Get Set(value As Integer) ViewState("Bloqueado") = 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 CvePresupuestoIngresos = IfNull(Request("CvePresupuestoIngresos"), "0").ToString.ToEntero EsProyecto = IfNull(Request("EsProyecto"), "0").ToString.ToEntero Bloqueado = IfNull(Request("Bloqueado"), "0").ToString.ToEntero CargaDefault() If CvePresupuestoIngresos > 0 Then CargaDatos() End If If Bloqueado = 1 Then btnGuardar.Visible = False btnDividir.Visible = False CboFuenteRecaudacion.Enabled = False CboRubroIngreso.Enabled = False DdlEjercicio.Enabled = False txtTotal.Enabled = False txtEnero.Enabled = False txtFebrero.Enabled = False txtMarzo.Enabled = False txtAbril.Enabled = False txtMayo.Enabled = False txtJunio.Enabled = False txtJulio.Enabled = False txtAgosto.Enabled = False txtSeptiembre.Enabled = False txtOctubre.Enabled = False txtNoviembre.Enabled = False txtDiciembre.Enabled = False BtnCancelar.Text = "Regresar" If EsProyecto = 0 Then Alert("Este Anteproyecto ya se genero como Presupuesto.", TipoMensaje.MsgInformacion) Else Alert("Este Presupuesto ya se Autorizó.", TipoMensaje.MsgInformacion) End If End If End If End Sub Public Sub CargaDatos() Dim objAC As New ClsAC If objAC.GetPresupuestoIngresos(CvePresupuestoIngresos, -1, CBool(EsProyecto), UsuarioActual.CveEmpresa) Then If objAC.DtResultados.Rows.Count = 1 Then CboFuenteRecaudacion.SelectedValue = objAC.DtResultados.Rows(0)("CveFuenteRecaudacion").ToString CboRubroIngreso.SelectedValue = objAC.DtResultados.Rows(0)("CveRubroIngreso").ToString txtTotal.Text = objAC.DtResultados.Rows(0)("Total").ToString.FormatoNumero txtEnero.Text = objAC.DtResultados.Rows(0)("Enero").ToString.FormatoNumero txtFebrero.Text = objAC.DtResultados.Rows(0)("Febrero").ToString.FormatoNumero txtMarzo.Text = objAC.DtResultados.Rows(0)("Marzo").ToString.FormatoNumero txtAbril.Text = objAC.DtResultados.Rows(0)("Abril").ToString.FormatoNumero txtMayo.Text = objAC.DtResultados.Rows(0)("Mayo").ToString.FormatoNumero txtJunio.Text = objAC.DtResultados.Rows(0)("Junio").ToString.FormatoNumero txtJulio.Text = objAC.DtResultados.Rows(0)("Julio").ToString.FormatoNumero txtAgosto.Text = objAC.DtResultados.Rows(0)("Agosto").ToString.FormatoNumero txtSeptiembre.Text = objAC.DtResultados.Rows(0)("Septiembre").ToString.FormatoNumero txtOctubre.Text = objAC.DtResultados.Rows(0)("Octubre").ToString.FormatoNumero txtNoviembre.Text = objAC.DtResultados.Rows(0)("Noviembre").ToString.FormatoNumero txtDiciembre.Text = objAC.DtResultados.Rows(0)("Diciembre").ToString.FormatoNumero DdlEjercicio.SelectedValue = objAC.DtResultados.Rows(0)("Ejercicio").ToString End If End If objAC.Dispose() End Sub #Region " VALORES INICIALES " Private Sub CargaDefault() txtEnero.Attributes.Add("onKeyUp", "sumaTotal();") txtFebrero.Attributes.Add("onKeyUp", "sumaTotal();") txtMarzo.Attributes.Add("onKeyUp", "sumaTotal();") txtAbril.Attributes.Add("onKeyUp", "sumaTotal();") txtMayo.Attributes.Add("onKeyUp", "sumaTotal();") txtJunio.Attributes.Add("onKeyUp", "sumaTotal();") txtJulio.Attributes.Add("onKeyUp", "sumaTotal();") txtAgosto.Attributes.Add("onKeyUp", "sumaTotal();") txtSeptiembre.Attributes.Add("onKeyUp", "sumaTotal();") txtOctubre.Attributes.Add("onKeyUp", "sumaTotal();") txtNoviembre.Attributes.Add("onKeyUp", "sumaTotal();") txtDiciembre.Attributes.Add("onKeyUp", "sumaTotal();") CargaEjercicios() CargaFuenteRecaudacion() CargaRubroIngreso() End Sub #Region "COMBOS" Private Sub CargaEjercicios() Dim ClsConta As New ClsContPAQi(UsuarioActual.Empresa) If ClsConta.GetEjercicios() Then DdlEjercicio.DataSource = ClsConta.DtResultados Else DdlEjercicio.DataSource = Nothing End If ClsConta.Dispose() DdlEjercicio.DataBind() DdlEjercicio.SelectedValueExist(UsuarioActual.Empresa.EjercicioActual.ToString) End Sub Private Sub CargaFuenteRecaudacion() CboFuenteRecaudacion.DataSource = GlobalDTAC_FuentesRecaudacion(UsuarioActual.CveEmpresa) CboFuenteRecaudacion.DataBind() CboFuenteRecaudacion.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub Private Sub CargaRubroIngreso() CboRubroIngreso.DataSource = GlobalDTAC_MatrizIngresos.FiltraParametros("Caracteristicas = 1") CboRubroIngreso.DataBind() CboRubroIngreso.Items.Insert(0, New ListItem("Seleccione", "-1")) End Sub #End Region #End Region Protected Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click Dim objAC As New ClsAC() Dim Total As Double = txtTotal.Text.Replace(",", "").Trim.ToDouble Dim Enero As Double = txtEnero.Text.Replace(",", "").Trim.ToDouble Dim Febrero As Double = txtFebrero.Text.Replace(",", "").Trim.ToDouble Dim Marzo As Double = txtMarzo.Text.Replace(",", "").Trim.ToDouble Dim Abril As Double = txtAbril.Text.Replace(",", "").Trim.ToDouble Dim Mayo As Double = txtMayo.Text.Replace(",", "").Trim.ToDouble Dim Junio As Double = txtJunio.Text.Replace(",", "").Trim.ToDouble Dim Julio As Double = txtJulio.Text.Replace(",", "").Trim.ToDouble Dim Agosto As Double = txtAgosto.Text.Replace(",", "").Trim.ToDouble Dim Septiembre As Double = txtSeptiembre.Text.Replace(",", "").Trim.ToDouble Dim Octubre As Double = txtOctubre.Text.Replace(",", "").Trim.ToDouble Dim Noviembre As Double = txtNoviembre.Text.Replace(",", "").Trim.ToDouble Dim Diciembre As Double = txtDiciembre.Text.Replace(",", "").Trim.ToDouble Dim Ejercicio As Integer = DdlEjercicio.SelectedValue.ToEntero Dim CveFuenteRecaudacion As Integer = CboFuenteRecaudacion.SelectedValue.ToString.ToEntero Dim CveRubroIngreso As Integer = CboRubroIngreso.SelectedValue.ToString.ToEntero If CvePresupuestoIngresos = 0 Then If objAC.AddPresupuestoIngresos(CveFuenteRecaudacion, CveRubroIngreso, Ejercicio, Total, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then Alert("El Presupuesto de Ingreso se guardo Correctamente", TipoMensaje.MsgInformacion, "document.location.href=""/AC/CatPresupuestoIngresos.aspx""") End If Else If objAC.UpdatePresupuestoIngresos(CvePresupuestoIngresos, CveFuenteRecaudacion, CveRubroIngreso, Total, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre) Then Alert("El Presupuesto de Ingreso se actualizo Correctamente", TipoMensaje.MsgInformacion, "document.location.href=""/AC/CatPresupuestoIngresos.aspx""") End If End If objAC.Dispose() End Sub Protected Sub BtnProyecto_Click(sender As Object, e As EventArgs) Dim AC As New ClsAC Dim Total As Double = txtTotal.Text.Replace(",", "").Trim.ToDouble Dim Enero As Double = txtEnero.Text.Replace(",", "").Trim.ToDouble Dim Febrero As Double = txtFebrero.Text.Replace(",", "").Trim.ToDouble Dim Marzo As Double = txtMarzo.Text.Replace(",", "").Trim.ToDouble Dim Abril As Double = txtAbril.Text.Replace(",", "").Trim.ToDouble Dim Mayo As Double = txtMayo.Text.Replace(",", "").Trim.ToDouble Dim Junio As Double = txtJunio.Text.Replace(",", "").Trim.ToDouble Dim Julio As Double = txtJulio.Text.Replace(",", "").Trim.ToDouble Dim Agosto As Double = txtAgosto.Text.Replace(",", "").Trim.ToDouble Dim Septiembre As Double = txtSeptiembre.Text.Replace(",", "").Trim.ToDouble Dim Octubre As Double = txtOctubre.Text.Replace(",", "").Trim.ToDouble Dim Noviembre As Double = txtNoviembre.Text.Replace(",", "").Trim.ToDouble Dim Diciembre As Double = txtDiciembre.Text.Replace(",", "").Trim.ToDouble Dim Ejercicio As Integer = 2015 Dim CveFuenteRecaudacion As Integer = CboFuenteRecaudacion.SelectedValue.ToString.ToEntero Dim CveRubroIngreso As Integer = CboRubroIngreso.SelectedValue.ToString.ToEntero If CvePresupuestoIngresos > 0 Then If AC.ProyectoPresupuestoIngresos(Ejercicio, CveFuenteRecaudacion, CveRubroIngreso, Total, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, CvePresupuestoIngresos) Then Alert("El Presupuesto de Ingreso se ACTUALIZO Correctamente como PROYECTO", TipoMensaje.MsgInformacion, "document.location.href=""/AC/CatPresupuestosIngresos.aspx""") End If Else Alert("ERROR", TipoMensaje.MsgError) End If End Sub End Class