Exemplo n.º 1
0
        private void dgvLista_DoubleClick(object sender, EventArgs e)
        {
            if (ActivarFiltros == true)
            {
                int a = 0;
                this.Cursor = Cursors.WaitCursor;

                dgvLista.CurrentRow.Cells["Seleccionar"].Value = true;

                foreach (DataGridViewRow Fila in dgvLista.Rows)
                {
                    if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true)
                    {
                        a++;
                        Array.Resize(ref oPeriodo, a);

                        oPeriodo[a - 1]              = new PeriodoEN();
                        oPeriodo[a - 1].idPeriodo    = Convert.ToInt32(Fila.Cells["idPeriodo"].Value);
                        oPeriodo[a - 1].Codigo       = Fila.Cells["Codigo"].Value.ToString();
                        oPeriodo[a - 1].Nombre       = Fila.Cells["Nombre"].Value.ToString();
                        oPeriodo[a - 1].Obsevaciones = Fila.Cells["Obsevaciones"].Value.ToString();
                        oPeriodo[a - 1].Estado       = Fila.Cells["Estado"].Value.ToString();
                        oPeriodo[a - 1].Desde        = Convert.ToDateTime(Fila.Cells["Desde"].Value.ToString());
                        oPeriodo[a - 1].Hasta        = Convert.ToDateTime(Fila.Cells["Hasta"].Value.ToString());
                    }
                }

                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
        private void EvaluarCuantosMovimientosCeranAfectadosporElCierre()
        {
            PeriodoEN oPeriodoEN = new PeriodoEN();
            PeriodoLN oPeriodoLN = new PeriodoLN();

            try
            {
                DateTime Desde = new DateTime(dtpDesde.Value.Year, dtpDesde.Value.Month, dtpDesde.Value.Day);
                DateTime Hasta = new DateTime(dtpHasta.Value.Year, dtpHasta.Value.Month, dtpHasta.Value.Day);

                oPeriodoEN.Desde = Desde;
                oPeriodoEN.Hasta = Hasta;

                System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo();

                if (Desde.Year == Hasta.Year && Desde.Month == Hasta.Month)
                {
                    txtNombre.Text = string.Format("Periodo de Cierre al Mes de: '{0}'", mfi.GetMonthName(dtpDesde.Value.Month));
                }
                else if (Desde.Year == Hasta.Year && Desde.Month != Hasta.Month)
                {
                    txtNombre.Text = string.Format("Periodo de Cierre del Mes: '{0}', Hasta el mes: {1}", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month));
                }
                else if (Desde.Year != Hasta.Year && Desde.Month == Hasta.Month)
                {
                    txtNombre.Text = string.Format("Periodo de Cierre se aplicara Desde: '{0}-{2}', Hasta: '{1}-{3}'", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month), dtpDesde.Value.Year, dtpHasta.Value.Year);
                }
                else if (Desde.Year != Hasta.Year && Desde.Month != Hasta.Month)
                {
                    txtNombre.Text = string.Format("Periodo de Cierre se aplicara: '{0}-{2}', hasta: '{1}-{3}'", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month), dtpDesde.Value.Year, dtpHasta.Value.Year);
                }

                txtObservacion.Text = string.Format("Periodo de Cierre al Mes de: '{0}', con rago de fecha: '{1}' -{2}", mfi.GetMonthName(dtpDesde.Value.Month), dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString());

                if (oPeriodoLN.EvaluarCuantosMovimientosCeranAfectadosPorElCierreDePeriodo(oPeriodoEN, Program.oDatosDeConexion))
                {
                    if (oPeriodoLN.TraerDatos().Rows.Count > 0)
                    {
                        lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", oPeriodoLN.TraerDatos().Rows[0]["TotalDeRegistros"].ToString(), txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString());
                    }
                    else
                    {
                        lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", 0, txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString());
                    }
                }
                else
                {
                    lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", 0, txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, string.Format("Evaluar cuantos movimientos de cuentas se van afectar con el '{0}' ", cmbEstado.Text), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                oPeriodoLN = null;
            }
        }
Exemplo n.º 3
0
        private string InformacionDelRegistro(PeriodoEN oRegistroEN)
        {
            string Cadena = @"idPeriodo: {0}, Codigo: {1}, Desde: {2}, Hasta: {3}, Nombre: {4}, Obsevaciones: {5}, Estado: {6}, 
            IdUsuarioDeCreacion: {7}, FechaDeCreacion: {8}, IdUsuarioDeModificacion: {9}, FechaDeModificacion: {10}";

            Cadena = string.Format(Cadena, oRegistroEN.idPeriodo, oRegistroEN.Codigo, oRegistroEN.Desde, oRegistroEN.Hasta, oRegistroEN.Nombre, oRegistroEN.Obsevaciones, oRegistroEN.Estado, oRegistroEN.IdUsuarioDeCreacion, oRegistroEN.FechaDeCreacion, oRegistroEN.IdUsuarioDeModificacion, oRegistroEN.FechaDeModificacion);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
        private void tsbGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    PeriodoEN oRegistroEN = InformacionDelRegistro();
                    PeriodoLN oRegistroLN = new PeriodoLN();

                    if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "AGREGAR"))
                    {
                        MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (oRegistroLN.Agregar(oRegistroEN, Program.oDatosDeConexion))
                    {
                        txtIdentificador.Text     = oRegistroEN.idPeriodo.ToString();
                        txtCodigo.Text            = oRegistroEN.Codigo;
                        ValorLlavePrimariaEntidad = oRegistroEN.idPeriodo;

                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Guardar");

                        oRegistroEN = null;
                        oRegistroLN = null;

                        this.Cursor = Cursors.Default;

                        if (CerrarVentana == true)
                        {
                            this.Close();
                        }
                        else
                        {
                            OperacionARealizar = "Modificar";
                            ObtenerValoresDeConfiguracion();
                            LlamarMetodoSegunOperacion();
                            EstablecerTituloDeVentana();
                            DeshabilitarControlesSegunOperacionesARealizar();
                        }
                    }
                    else
                    {
                        throw new ArgumentException(oRegistroLN.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Guardar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 5
0
        public bool Eliminar(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = @"Delete from periodo where idPeriodo = @idPeriodo;";
                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo;

                Comando.ExecuteNonQuery();

                DescripcionDeOperacion = string.Format("El registro fue Eliminado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Elminar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al eliminar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Eliminar Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 6
0
 public bool ListadoPorIdentificador(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oPeriodoAD.ListadoPorIdentificador(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oPeriodoAD.Error;
         return(false);
     }
 }
Exemplo n.º 7
0
 public bool ListadoParaReportes(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oPeriodoAD.ListadoParaReportes(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oPeriodoAD.Error;
         return(false);
     }
 }
Exemplo n.º 8
0
 public bool ValidarSiElRegistroEstaVinculado(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oPeriodoAD.ValidarSiElRegistroEstaVinculado(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oPeriodoAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
Exemplo n.º 9
0
 public bool RegistroDuplicadoPorFecha_contenidos(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oPeriodoAD.RegistroDuplicadoPorFecha_contenidos(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oPeriodoAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
Exemplo n.º 10
0
 public bool Agregar(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oPeriodoAD.Agregar(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oPeriodoAD.Error;
         return(false);
     }
 }
Exemplo n.º 11
0
 public bool EvaluarCuantosMovimientosCeranAfectadosPorElCierreDePeriodo(PeriodoEN oRegistroEN, DatosDeConexionEN oDatosConexionEN)
 {
     if (oPeriodoAD.EvaluarCuantosMovimientosCeranAfectadosPorElCierreDePeriodo(oRegistroEN, oDatosConexionEN))
     {
         this.Error = null;
         return(true);
     }
     else
     {
         this.Error = oPeriodoAD.Error;
         return(false);
     }
 }
Exemplo n.º 12
0
 public bool ListadoDeLosAñosEnPeriodosCerrasdos(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oPeriodoAD.ListadoDeLosAñosEnPeriodosCerrasdos(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oPeriodoAD.Error;
         return(false);
     }
 }
        private void LlenarCamposDesdeBaseDatosSegunID()
        {
            this.Cursor = Cursors.WaitCursor;

            PeriodoEN oRegistrosEN = new PeriodoEN();
            PeriodoLN oRegistrosLN = new PeriodoLN();

            oRegistrosEN.idPeriodo = ValorLlavePrimariaEntidad;

            if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion))
            {
                if (oRegistrosLN.TraerDatos().Rows.Count > 0)
                {
                    //idPeriodo, Codigo, Desde, Hasta, Nombre, Obsevaciones, Estado,
                    DataRow Fila = oRegistrosLN.TraerDatos().Rows[0];
                    txtCodigo.Text      = Fila["Codigo"].ToString();
                    txtNombre.Text      = Fila["Nombre"].ToString();
                    txtObservacion.Text = Fila["Obsevaciones"].ToString();
                    cmbEstado.Text      = Fila["Estado"].ToString();
                    dtpDesde.Value      = Convert.ToDateTime(Fila["Desde"]);
                    dtpHasta.Value      = Convert.ToDateTime(Fila["Hasta"]);

                    oRegistrosEN = null;
                    oRegistrosLN = null;
                }
                else
                {
                    string Mensaje;
                    Mensaje = string.Format("El registro solicitado de {0} no ha sido encontrado."
                                            + "\n\r-----Causas---- "
                                            + "\n\r1. Este registro pudo haber sido eliminado por otro usuario."
                                            + "\n\r2. El listado no está actualizado.", NombreEntidad);

                    MessageBox.Show(Mensaje, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    oRegistrosEN = null;
                    oRegistrosLN = null;

                    this.Close();
                }
            }
            else
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(oRegistrosLN.Error, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                oRegistrosEN = null;
                oRegistrosLN = null;
            }

            this.Cursor = Cursors.Default;
        }
Exemplo n.º 14
0
        public bool ActualizarElEstadoDelPeriodo(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos, ref MySqlConnection Cnn_Existente, ref MySqlTransaction Trasanccion_Existente)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn_Existente;
                Comando.Transaction = Trasanccion_Existente;
                Comando.CommandType = CommandType.Text;

                Consultas = @"UPDATE periodo set
	            Estado = @Estado, IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp()
                where idPeriodo = @idPeriodo;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo;
                Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value = oRegistroEN.Estado.Trim();
                Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;

                Comando.ExecuteNonQuery();

                DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 15
0
        private void tsbSeleccionarTodos_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                tsbSeleccionarTodos.Checked = !tsbMarcarTodos.Checked;

                if (tsbSeleccionarTodos.Checked == true)
                {
                    tsbSeleccionarTodos.Image = Properties.Resources.unchecked16x16;
                }
                else
                {
                    tsbSeleccionarTodos.Image = Properties.Resources.checked16x16;
                }

                int a = 0;
                this.Cursor = Cursors.WaitCursor;
                if (dgvLista.Rows.Count > 0)
                {
                    foreach (DataGridViewRow Fila in dgvLista.Rows)
                    {
                        if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true)
                        {
                            a++;
                            Array.Resize(ref oPeriodo, a);

                            oPeriodo[a - 1]              = new PeriodoEN();
                            oPeriodo[a - 1].idPeriodo    = Convert.ToInt32(Fila.Cells["idPeriodo"].Value);
                            oPeriodo[a - 1].Codigo       = Fila.Cells["Codigo"].Value.ToString();
                            oPeriodo[a - 1].Nombre       = Fila.Cells["Nombre"].Value.ToString();
                            oPeriodo[a - 1].Obsevaciones = Fila.Cells["Obsevaciones"].Value.ToString();
                            oPeriodo[a - 1].Estado       = Fila.Cells["Estado"].Value.ToString();
                            oPeriodo[a - 1].Desde        = Convert.ToDateTime(Fila.Cells["Desde"].Value.ToString());
                            oPeriodo[a - 1].Hasta        = Convert.ToDateTime(Fila.Cells["Hasta"].Value.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                AgregarRegistrosAlDTUsuario();
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
Exemplo n.º 16
0
        public bool EvaluarCuantosMovimientosCeranAfectadosPorElCierreDePeriodo(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                //Consultas = @"Select count(idTransacciones) as 'TotalDeRegistros' from transacciones where Fecha between @Desde and @Hasta";
                //Consultas = @"Select count(idTransacciones) as 'TotalDeRegistros' from transacciones where SoloFecha( Fecha ) >= SoloFecha( @Desde ) and  SoloFecha(Fecha) <= SoloFecha( @Hasta ) ";
                Consultas = @"Select count(idTransacciones) as 'TotalDeRegistros' from transacciones where SoloFecha( Fecha ) between SoloFecha( @Desde ) and SoloFecha( @Hasta )";
                Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde;
                Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta;

                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
Exemplo n.º 17
0
        public bool ListadoParaReportes(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = string.Format(@"Select idPeriodo, Codigo, Desde, Hasta, Nombre, Obsevaciones, Estado, 
                IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion
                from periodo
                Where idPeriodo > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);
                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
Exemplo n.º 18
0
        private void LLenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                PeriodoEN oRegistrosEN = new PeriodoEN();
                PeriodoLN oRegistrosLN = new PeriodoLN();

                oRegistrosEN.Where   = WhereDinamico();
                oRegistrosEN.OrderBy = " Order by Hasta desc ";

                if (oRegistrosLN.Listado(oRegistrosEN, Program.oDatosDeConexion))
                {
                    dgvLista.Columns.Clear();
                    System.Diagnostics.Debug.Print(oRegistrosLN.TraerDatos().Rows.Count.ToString());

                    if (ActivarFiltros == true)
                    {
                        dgvLista.DataSource = AgregarColumnaSeleccionar(oRegistrosLN.TraerDatos());
                    }
                    else
                    {
                        dgvLista.DataSource = oRegistrosLN.TraerDatos();
                    }

                    FormatearDGV();
                    this.dgvLista.ClearSelection();

                    tsbNoRegistros.Text = "No. Registros: " + oRegistrosLN.TotalRegistros().ToString();
                }
                else
                {
                    throw new ArgumentException(oRegistrosLN.Error);
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Llenar listado de registro en la lista", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 19
0
        public bool Eliminar(PeriodoEN oREgistroEN, DatosDeConexionEN oDatos)
        {
            if (string.IsNullOrEmpty(oREgistroEN.idPeriodo.ToString()) || oREgistroEN.idPeriodo == 0)
            {
                this.Error = @"Se debe de seleccionar un elemento de la lista";
                return(false);
            }

            if (oPeriodoAD.Eliminar(oREgistroEN, oDatos))
            {
                Error = string.Empty;
                return(true);
            }
            else
            {
                Error = oPeriodoAD.Error;
                return(false);
            }
        }
Exemplo n.º 20
0
        private TransaccionesEN InformacionDelaTransaccion(PeriodoEN oPeriodo, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.idregistro      = oPeriodo.idPeriodo;
            oRegistroEN.Modelo          = "PeriodoAD";
            oRegistroEN.Modulo          = "Periodo";
            oRegistroEN.Tabla           = "periodo";
            oRegistroEN.tipodeoperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.ip                    = oPeriodo.oLoginEN.NumeroIP;
            oRegistroEN.idusuario             = oPeriodo.oLoginEN.idUsuario;
            oRegistroEN.idusuarioaprueba      = oPeriodo.oLoginEN.idUsuario;
            oRegistroEN.descripciondelusuario = DescripcionDeOperacion;
            oRegistroEN.descripcioninterna    = Descripcion;
            oRegistroEN.NombreDelEquipo       = oPeriodo.oLoginEN.NombreDelComputador;

            return(oRegistroEN);
        }
Exemplo n.º 21
0
        public bool ListadoDeLosAñosEnPeriodosCerrasdos(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas           = @"Select date_format(Hasta, '%Y') as 'Ano' from periodo where Estado = 'CERRADO' group by year(Hasta) order by Hasta desc; ";
                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn       = null;
                Comando   = null;
                Adaptador = null;
            }
        }
        private PeriodoEN InformacionDelRegistro()
        {
            PeriodoEN oRegistroEN = new PeriodoEN();

            oRegistroEN.idPeriodo    = Convert.ToInt32((txtIdentificador.Text.Length > 0 ? txtIdentificador.Text : "0"));
            oRegistroEN.Codigo       = txtCodigo.Text.Trim();
            oRegistroEN.Desde        = dtpDesde.Value;
            oRegistroEN.Hasta        = dtpHasta.Value;
            oRegistroEN.Obsevaciones = txtObservacion.Text.Trim();
            oRegistroEN.Estado       = cmbEstado.Text;
            oRegistroEN.Nombre       = txtNombre.Text.Trim();

            //partes generales.
            oRegistroEN.oLoginEN                = Program.oLoginEN;
            oRegistroEN.IdUsuarioDeCreacion     = Program.oLoginEN.idUsuario;
            oRegistroEN.IdUsuarioDeModificacion = Program.oLoginEN.idUsuario;
            oRegistroEN.FechaDeCreacion         = System.DateTime.Now;
            oRegistroEN.FechaDeModificacion     = System.DateTime.Now;

            return(oRegistroEN);
        }
        private void tsbEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    if (txtIdentificador.Text.Length == 0 || txtIdentificador.Text == "0")
                    {
                        MessageBox.Show("No se puede continuar. Ha ocurrido un error y el registro no ha sido cargado correctamente.", OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }


                    if (MessageBox.Show("¿Está seguro que desea eliminar el registro?", "Eliminar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    PeriodoEN oRegistroEN = InformacionDelRegistro();
                    PeriodoLN oRegistroLN = new PeriodoLN();

                    if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexion, "ELIMINAR"))
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (oRegistroLN.Eliminar(oRegistroEN, Program.oDatosDeConexion))
                    {
                        txtIdentificador.Text     = oRegistroEN.idPeriodo.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.idPeriodo;

                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Eliminar");

                        oRegistroEN = null;
                        oRegistroLN = null;

                        this.Cursor = Cursors.Default;

                        if (CerrarVentana == true)
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        throw new ArgumentException(oRegistroLN.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Eliminar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 24
0
        public bool Actualizar(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas = @"UPDATE periodo set
	                Desde = @Desde, Hasta = @Hasta, Nombre = @Nombre, 
                    Obsevaciones = @Obsevaciones, Estado = @Estado, IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp()
                where idPeriodo = @idPeriodo;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo;
                Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value  = oRegistroEN.Desde;
                Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value  = oRegistroEN.Hasta;
                Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value             = oRegistroEN.Nombre.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Obsevaciones", MySqlDbType.VarChar, oRegistroEN.Obsevaciones.Trim().Length)).Value = oRegistroEN.Obsevaciones.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value             = oRegistroEN.Estado.Trim();

                Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;

                Comando.ExecuteNonQuery();

                DescripcionDeOperacion = string.Format("El registro fue Actualizado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al actualizar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 25
0
        public bool Agregar(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                Consultas = @"
                                
                insert into periodo
                (Codigo, Desde, Hasta, Nombre, Obsevaciones, Estado, IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion)
                values
                (CrearNumeroDelPeriodo(), @Desde, @Hasta, @Nombre, @Obsevaciones, @Estado, @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp());

                select idPeriodo,Codigo from periodo where idPeriodo = last_insert_id();";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde;
                Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta;
                Comando.Parameters.Add(new MySqlParameter("@Nombre", MySqlDbType.VarChar, oRegistroEN.Nombre.Trim().Length)).Value             = oRegistroEN.Nombre.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Obsevaciones", MySqlDbType.VarChar, oRegistroEN.Obsevaciones.Trim().Length)).Value = oRegistroEN.Obsevaciones.Trim();
                Comando.Parameters.Add(new MySqlParameter("@Estado", MySqlDbType.VarChar, oRegistroEN.Estado.Trim().Length)).Value             = oRegistroEN.Estado.Trim();

                Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeCreacion", MySqlDbType.Int32)).Value     = oRegistroEN.oLoginEN.idUsuario;
                Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                oRegistroEN.idPeriodo = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString());
                oRegistroEN.Codigo    = DT.Rows[0].ItemArray[1].ToString();

                DescripcionDeOperacion = string.Format("El registro fue Insertado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(true);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al insertar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 26
0
        public bool RegistroDuplicadoPorFecha_contenidos(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.Text;

                switch (TipoDeOperacion.Trim().ToUpper())
                {
                case "AGREGAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select idPeriodo from periodo where ( Desde >= @Desde and Desde <= @Hasta ) OR (Hasta >= @Desde and Hasta <= @Hasta)) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value = oRegistroEN.Desde;
                    Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value = oRegistroEN.Hasta;

                    break;

                case "ACTUALIZAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select idPeriodo from periodo where ( Desde >= @Desde and Desde <= @Hasta ) OR (Hasta >= @Desde and Hasta <= @Hasta) and idPeriodo<> @idPeriodo) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Desde", MySqlDbType.DateTime)).Value  = oRegistroEN.Desde;
                    Comando.Parameters.Add(new MySqlParameter("@Hasta", MySqlDbType.DateTime)).Value  = oRegistroEN.Hasta;
                    Comando.Parameters.Add(new MySqlParameter("@idPeriodo", MySqlDbType.Int32)).Value = oRegistroEN.idPeriodo;

                    break;

                default:
                    throw new ArgumentException("La aperación solicitada no esta disponible");
                }

                Comando.CommandText = Consultas;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (Convert.ToInt32(DT.Rows[0]["RES"].ToString()) > 0)
                {
                    DescripcionDeOperacion = string.Format("Ya existe información del Registro dentro de nuestro sistema: {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));
                    this.Error             = DescripcionDeOperacion;
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 27
0
        public bool ValidarSiElRegistroEstaVinculado(PeriodoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos));
                Cnn.Open();

                Comando             = new MySqlCommand();
                Comando.Connection  = Cnn;
                Comando.CommandType = CommandType.StoredProcedure;
                Comando.CommandText = "ValidarSiElRegistroEstaVinculado";

                Comando.Parameters.Add(new MySqlParameter("@CampoABuscar_", MySqlDbType.VarChar, 200)).Value = "idPeriodo";
                Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value    = oRegistroEN.idPeriodo;
                Comando.Parameters.Add(new MySqlParameter("@ExcluirTabla_", MySqlDbType.VarChar, 200)).Value = string.Empty;

                Adaptador = new MySqlDataAdapter();
                DT        = new DataTable();

                Adaptador.SelectCommand = Comando;
                Adaptador.Fill(DT);

                if (DT.Rows[0].ItemArray[0].ToString().ToUpper() == "NINGUNA".ToUpper())
                {
                    return(false);
                }
                else
                {
                    this.Error             = String.Format("La Operación: '{1}', {0} no se puede completar por que el registro: {0} '{2}', {0} se encuentra asociado con: {0} {3}", Environment.NewLine, TipoDeOperacion, InformacionDelRegistro(oRegistroEN), oTransaccionesAD.ConvertirValorDeLaCadena(DT.Rows[0].ItemArray[0].ToString()));
                    DescripcionDeOperacion = this.Error;

                    //Agregamos la Transacción....
                    TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "CORRECTO");
                    oTransaccionesAD.Agregar(oTran, oDatos);

                    return(true);
                }
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al validar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message);

                //Agregamos la Transacción....
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "ERROR");
                oTransaccionesAD.Agregar(oTran, oDatos);

                return(false);
            }
            finally
            {
                if (Cnn != null)
                {
                    if (Cnn.State == ConnectionState.Open)
                    {
                        Cnn.Close();
                    }
                }

                Cnn              = null;
                Comando          = null;
                Adaptador        = null;
                oTransaccionesAD = null;
            }
        }