Esempio n. 1
0
        public bool EvaluarSiElRegistrosEstaAsociado(CuentaEN 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;
                Comando.CommandText = @"select case when exists(Select NoCuenta from cuenta where CuentaMadre = @NoCuenta) then 1 else 0 end as 'RES'";

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

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

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

                if (Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString()) == 0)
                {
                    return(false);
                }
                else
                {
                    this.Error             = string.Format("La operación: '{0}' no se puede completar por el registro esta asociado a otras cuentas", TipoDeOperacion);
                    DescripcionDeOperacion = this.Error;

                    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);
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "RIGISTRO ASOCIADO A CUENTA MADRE", "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;
            }
        }
Esempio n. 2
0
        private string InformacionDelRegistro(CuentaEN oRegistroEN)
        {
            string Cadena = @"idCuenta: {0}, DescCuenta: {1}, SaldoCuenta: {2}, NivelCuenta: {3}, CuentaMadre: {4}, IdUsuarioDeCreacion: {5}, FechaDeCreacion: {6}, IdUsuarioDeModificacion: {7}, FechaDeModificacion: {8}, idCategoriaDeCuenta: {9}, idTipoDeCuenta: {10}, NoCuenta: {11}";

            Cadena = string.Format(Cadena, oRegistroEN.idCuenta, oRegistroEN.DescCuenta, oRegistroEN.SaldoCuenta, oRegistroEN.NivelCuenta, oRegistroEN.CuentaMadre, oRegistroEN.IdUsuarioDeCreacion, oRegistroEN.FechaDeCreacion, oRegistroEN.IdUsuarioDeModificacion, oRegistroEN.FechaDeModificacion, oRegistroEN.oCategoriaDeCuentaEN.idCategoriaDeCuenta, oRegistroEN.oTipoDeCuentaEN.idTipoDeCuenta, oRegistroEN.NoCuenta);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
Esempio n. 3
0
        public bool Eliminar(CuentaEN 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 Cuenta where NoCuenta = @NoCuenta;";
                Comando.CommandText = Consultas;

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

                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", "Eliminar 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;
            }
        }
Esempio n. 4
0
        public bool Listado(CuentaEN 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 
                c.idCategoriaDeCuenta, c.idTipoDeCuenta, gc.idGrupoDeCuentas,c.NoCuenta,c.idCuenta, 
                c.DescCuenta,c.SaldoCuenta, MovimientosDelDiaPorCuenta(NoCuenta) as 'MovimientosDelDia', TrearSaldoActualConMovimientosDelDia(NoCuenta) as 'SaldoAlDia',cc.DescCategoriaDeCuenta,gc.DescGrupoDeCuentas, c.NivelCuenta, c.CuentaMadre, 
                c.IdUsuarioDeCreacion, c.FechaDeCreacion, c.IdUsuarioDeModificacion, 
                c.FechaDeModificacion, tc.DescTipoDeCuenta, EvaLuarSiEsCuentaDeBanco(c.NoCuenta) as 'EsCuentaDeBanco',
                c.DescCuentaContenido
                from cuenta as c
                inner join categoriadecuenta as cc on cc.idCategoriaDeCuenta = c.idCategoriaDeCuenta
                inner join tipodecuenta as tc on tc.idTipoDeCuenta = c.idTipoDeCuenta
                inner join grupodecuentas as gc on gc.idGrupoDeCuentas = cc.idGrupoDeCuentas
                where NoCuenta > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);

                System.Diagnostics.Debug.Print(Consultas);
                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;
            }
        }
Esempio n. 5
0
        public bool TraerInformacionDelAsociado(CuentaEN 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 
                c.idCategoriaDeCuenta, c.idTipoDeCuenta, gc.idGrupoDeCuentas,c.NoCuenta,c.idCuenta, 
                c.DescCuenta,cc.DescCategoriaDeCuenta,gc.DescGrupoDeCuentas, c.SaldoCuenta, c.NivelCuenta, c.CuentaMadre, 
                c.IdUsuarioDeCreacion, c.FechaDeCreacion, c.IdUsuarioDeModificacion, 
                c.FechaDeModificacion, tc.DescTipoDeCuenta
                from cuenta as c
                inner join categoriadecuenta as cc on cc.idCategoriaDeCuenta = c.idCategoriaDeCuenta
                inner join tipodecuenta as tc on tc.idTipoDeCuenta = c.idTipoDeCuenta
                inner join grupodecuentas as gc on gc.idGrupoDeCuentas = cc.idGrupoDeCuentas
                where c.NoCuenta = (select c1.CuentaMadre from cuenta as c1 where  c1.NoCuenta = {0} and c1.CuentaMadre = '{1}') ", oRegistroEN.NoCuenta, oRegistroEN.CuentaMadre);

                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;
            }
        }
Esempio n. 6
0
        public bool ListadoCompletoDeLasCuentas(CuentaEN 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 
                c.idCategoriaDeCuenta, c.idTipoDeCuenta, gc.idGrupoDeCuentas,c.NoCuenta,c.idCuenta, 
                c.DescCuenta,cc.DescCategoriaDeCuenta,gc.DescGrupoDeCuentas, c.SaldoCuenta, c.NivelCuenta, 
                c.CuentaMadre, tc.DescTipoDeCuenta, gc.Debitos, gc.Creditos, c.DescCuentaContenido 
                from cuenta as c
                inner join categoriadecuenta as cc on cc.idCategoriaDeCuenta = c.idCategoriaDeCuenta
                inner join tipodecuenta as tc on tc.idTipoDeCuenta = c.idTipoDeCuenta
                inner join grupodecuentas as gc on gc.idGrupoDeCuentas = cc.idGrupoDeCuentas
                where NoCuenta > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);

                System.Diagnostics.Debug.Print("Consulta: " + Consultas);
                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;
            }
        }
Esempio n. 7
0
 public bool ValidarRegistroDuplicadoPorDescripcionDeLaCuenta(CuentaEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oCuentaAD.ValidarRegistroDuplicadoPorDescripcionDeLaCuenta(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oCuentaAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
Esempio n. 8
0
 public bool EvaluarSiElRegistrosEstaAsociado(CuentaEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oCuentaAD.EvaluarSiElRegistrosEstaAsociado(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oCuentaAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
Esempio n. 9
0
 public bool Listado(CuentaEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oCuentaAD.Listado(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCuentaAD.Error;
         return(false);
     }
 }
Esempio n. 10
0
 public bool TraerInformacionDelAsociado(CuentaEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oCuentaAD.TraerInformacionDelAsociado(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCuentaAD.Error;
         return(false);
     }
 }
Esempio n. 11
0
        public bool ListadoParaCombos(CuentaEN 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 
	                c.NoCuenta,c.idCuenta, c.DescCuenta, c.SaldoCuenta, c.NivelCuenta, c.CuentaMadre, 
                    c.IdUsuarioDeCreacion, c.FechaDeCreacion, c.IdUsuarioDeModificacion, 
                    c.FechaDeModificacion, c.idCategoriaDeCuenta, c.idTipoDeCuenta
                from cuenta as c
                inner join categoriadecuenta as cc on cc.idCategoriaDeCuenta = c.idCategoriaDeCuenta
                inner join tipodecuenta tc on tc.idTipoDeCuenta = c.idTipoDeCuenta
                where NoCuenta > 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;
            }
        }
Esempio n. 12
0
        public bool ListadoDeMovimientosDelDiaPorCuenta(CuentaEN 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 t.NumeroDeTransaccion,t.Fecha, td.Debe, td.Haber,c.idCuenta, c.DescCuenta, c.NoCuenta from transacciones as t
                inner join transacciondetalle  as td on td.idTransacciones = t.idTransacciones
                inner join cuenta as c on c.NoCuenta = td.NoCuenta
                where td.NoCuenta > 0 {0} Order by t.Fecha, t.NumeroDeTransaccion ", oRegistroEN.Where);
                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;
            }
        }
Esempio n. 13
0
        private TransaccionesEN InformacionDelaTransaccion(CuentaEN oCuenta, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.idregistro      = oCuenta.NoCuenta;
            oRegistroEN.Modelo          = "CuentasAD";
            oRegistroEN.Modulo          = "Cuentas";
            oRegistroEN.Tabla           = "Cuenta";
            oRegistroEN.tipodeoperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.ip                    = oCuenta.oLoginEN.NumeroIP;
            oRegistroEN.idusuario             = oCuenta.oLoginEN.idUsuario;
            oRegistroEN.idusuarioaprueba      = oCuenta.oLoginEN.idUsuario;
            oRegistroEN.descripciondelusuario = DescripcionDeOperacion;
            oRegistroEN.descripcioninterna    = Descripcion;
            oRegistroEN.NombreDelEquipo       = oCuenta.oLoginEN.NombreDelComputador;

            return(oRegistroEN);
        }
Esempio n. 14
0
        public bool Eliminar(CuentaEN oREgistroEN, DatosDeConexionEN oDatos)
        {
            if (string.IsNullOrEmpty(oREgistroEN.NoCuenta.ToString()) || oREgistroEN.NoCuenta == 0)
            {
                this.Error = @"Se debe de seleccionar un elemento de la lista";
                return(false);
            }

            if (oCuentaAD.Eliminar(oREgistroEN, oDatos))
            {
                Error = string.Empty;
                return(true);
            }
            else
            {
                Error = oCuentaAD.Error;
                return(false);
            }
        }
        private void TraerInformacionDeLaCuentaAsociada()
        {
            try
            {
                if (Controles.IsNullOEmptyElControl(txtIdentificadorAsociado) == false && Convert.ToInt32(txtIdentificadorAsociado.Text) > 0)
                {
                    CuentaEN oRegistroEN = new CuentaEN();
                    oRegistroEN.NoCuenta    = Convert.ToInt32(txtIdentificador.Text);
                    oRegistroEN.CuentaMadre = txtIdentificadorAsociado.Text.Trim();

                    CuentaLN oRegistroLN = new CuentaLN();

                    if (oRegistroLN.TraerInformacionDelAsociado(oRegistroEN, Program.oDatosDeConexion))
                    {
                        if (oRegistroLN.TraerDatos().Rows.Count > 0)
                        {
                            gpCuentaAsociada.Visible = true;

                            DataRow Fila = oRegistroLN.TraerDatos().Rows[0];

                            txtDescricpcionDeLaCuentaAsociada.Text = Fila["DescCuenta"].ToString();
                            txtCuentaAsociadaIdCuenta.Text         = Fila["idCuenta"].ToString();
                        }
                        else
                        {
                            gpCuentaAsociada.Visible = false;
                        }
                    }
                    else
                    {
                        throw new ArgumentException(oRegistroLN.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Información de cuenta asociada", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 16
0
        public bool ValidarRegistroDuplicadoPorCategoria(CuentaEN 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 idCuenta FROM Cuenta WHERE upper(idCuenta) = upper(@idCuenta)  and upper(trim(DescCuenta)) = upper(@DescCuenta) and idCategoriaDeCuenta = @idCategoriaDeCuenta ) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@idCuenta", MySqlDbType.VarChar, oRegistroEN.idCuenta.Trim().Length)).Value     = oRegistroEN.idCuenta.Trim();
                    Comando.Parameters.Add(new MySqlParameter("@DescCuenta", MySqlDbType.VarChar, oRegistroEN.DescCuenta.Trim().Length)).Value = oRegistroEN.DescCuenta.Trim();
                    Comando.Parameters.Add(new MySqlParameter("@idCategoriaDeCuenta", MySqlDbType.Int32)).Value = oRegistroEN.oCategoriaDeCuentaEN.idCategoriaDeCuenta;

                    break;

                case "ACTUALIZAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(SELECT idCuenta FROM Cuenta WHERE upper(idCuenta) = upper(@idCuenta) and upper(trim(DescCuenta)) = upper(@DescCuenta) and idCategoriaDeCuenta = @idCategoriaDeCuenta and NoCuenta <> @DescCuenta) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@idCuenta", MySqlDbType.VarChar, oRegistroEN.idCuenta.Trim().Length)).Value     = oRegistroEN.idCuenta.Trim();
                    Comando.Parameters.Add(new MySqlParameter("@DescCuenta", MySqlDbType.VarChar, oRegistroEN.DescCuenta.Trim().Length)).Value = oRegistroEN.DescCuenta.Trim();
                    Comando.Parameters.Add(new MySqlParameter("@idCategoriaDeCuenta", MySqlDbType.Int32)).Value = oRegistroEN.oCategoriaDeCuentaEN.idCategoriaDeCuenta;
                    Comando.Parameters.Add(new MySqlParameter("@NoCuenta", MySqlDbType.Int32)).Value            = oRegistroEN.NoCuenta;

                    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 una cuenta  dentro de nuestro sistema con la misma descripción: {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 POR IDENTIFICADOR,  DESCRIPCION DE LA CUENTA Y TIPO DE CUENTA", "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;
            }
        }
Esempio n. 17
0
        public bool Actualizar(CuentaEN 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 cuenta set
	                idCuenta = @idCuenta, DescCuenta = @DescCuenta, SaldoCuenta = @SaldoCuenta, NivelCuenta = @NivelCuenta, CuentaMadre = @CuentaMadre, 
	                IdUsuarioDeModificacion = @IdUsuarioDeModificacion, FechaDeModificacion = current_timestamp(), 
	                idCategoriaDeCuenta = @idCategoriaDeCuenta, idTipoDeCuenta = @idTipoDeCuenta
                where  NoCuenta = @NoCuenta;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@NoCuenta", MySqlDbType.Int32)).Value = oRegistroEN.NoCuenta;
                Comando.Parameters.Add(new MySqlParameter("@idCuenta", MySqlDbType.VarChar, oRegistroEN.idCuenta.Trim().Length)).Value     = oRegistroEN.idCuenta.Trim();
                Comando.Parameters.Add(new MySqlParameter("@DescCuenta", MySqlDbType.VarChar, oRegistroEN.DescCuenta.Trim().Length)).Value = oRegistroEN.DescCuenta.Trim();
                Comando.Parameters.Add(new MySqlParameter("@SaldoCuenta", MySqlDbType.Decimal)).Value = oRegistroEN.SaldoCuenta;
                Comando.Parameters.Add(new MySqlParameter("@NivelCuenta", MySqlDbType.Int32)).Value   = oRegistroEN.NivelCuenta;
                Comando.Parameters.Add(new MySqlParameter("@CuentaMadre", MySqlDbType.VarChar, oRegistroEN.CuentaMadre.Trim().Length)).Value = oRegistroEN.CuentaMadre.Trim();
                Comando.Parameters.Add(new MySqlParameter("@IdUsuarioDeModificacion", MySqlDbType.Int32)).Value = oRegistroEN.oLoginEN.idUsuario;
                Comando.Parameters.Add(new MySqlParameter("@idCategoriaDeCuenta", MySqlDbType.Int32)).Value     = oRegistroEN.oCategoriaDeCuentaEN.idCategoriaDeCuenta;
                Comando.Parameters.Add(new MySqlParameter("@idTipoDeCuenta", MySqlDbType.Int32)).Value          = oRegistroEN.oTipoDeCuentaEN.idTipoDeCuenta;

                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;
            }
        }
        private void LlenarCamposDesdeBaseDatosSegunID()
        {
            this.Cursor = Cursors.WaitCursor;

            CuentaEN oRegistrosEN = new CuentaEN();
            CuentaLN oRegistrosLN = new CuentaLN();

            oRegistrosEN.idCuenta = idCuenta;

            if (oRegistrosLN.ListadoPorIdCuenta(oRegistrosEN, Program.oDatosDeConexion))
            {
                if (oRegistrosLN.TraerDatos().Rows.Count > 0)
                {
                    int NivelCuenta;
                    int idTipoDeCuenta;

                    DataRow Fila = oRegistrosLN.TraerDatos().Rows[0];
                    txtIdentificador.Text                = Fila["NoCuenta"].ToString();
                    mskidCuenta.Text                     = Fila["idCuenta"].ToString();
                    txtIdCuenta.Text                     = ExtraerCadenaDelaMascar(mskidCuenta);
                    cmbGrupoDeCuenta.SelectedValue       = Convert.ToInt32(Fila["idGrupoDeCuentas"].ToString());
                    cmbCategoriaDeLaCuenta.SelectedValue = Convert.ToInt32(Fila["idCategoriaDeCuenta"].ToString());
                    txtDescCuenta.Text                   = Fila["DescCuenta"].ToString();
                    cmbGrupoDeCuenta.SelectedValue       = Convert.ToInt32(Fila["idGrupoDeCuentas"].ToString());
                    NivelCuenta = Convert.ToInt32(Fila["NivelCuenta"]);
                    txtIdentificadorAsociado.Text = Fila["CuentaMadre"].ToString();
                    idTipoDeCuenta = Convert.ToInt32(Fila["idTipoDeCuenta"].ToString());
                    txtSaldo.Text  = string.Format("{0:###,###,###.0#}", Convert.ToDecimal(Fila["SaldoCuenta"].ToString()));
                    txtDescCuentaContenido.Text = Fila["DescCuentaContenido"].ToString();

                    //Traer informacion sobre la cuenta a la que esta asociada el registro.....
                    TraerInformacionDeLaCuentaAsociada();

                    if (NivelCuenta > 1)
                    {
                        cmbCategoriaDeLaCuenta.Enabled = false;
                        cmbGrupoDeCuenta.Enabled       = false;
                    }

                    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.", idCuenta);

                    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;
        }
Esempio n. 19
0
        public bool Agregar(CuentaEN 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 cuenta
                (idCuenta, DescCuenta, SaldoCuenta, NivelCuenta, CuentaMadre, 
                IdUsuarioDeCreacion, FechaDeCreacion, IdUsuarioDeModificacion, FechaDeModificacion, 
                idCategoriaDeCuenta, idTipoDeCuenta, NoCuenta)
                values
                (@idCuenta, @DescCuenta, @SaldoCuenta, @NivelCuenta, @CuentaMadre, 
                @IdUsuarioDeCreacion, current_timestamp(), @IdUsuarioDeModificacion, current_timestamp(), 
                @idCategoriaDeCuenta, @idTipoDeCuenta, IdentificadorDeLaCuenta());

                Select max(NoCuenta) as 'ID' from cuenta;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@idCuenta", MySqlDbType.VarChar, oRegistroEN.idCuenta.Trim().Length)).Value     = oRegistroEN.idCuenta.Trim();
                Comando.Parameters.Add(new MySqlParameter("@DescCuenta", MySqlDbType.VarChar, oRegistroEN.DescCuenta.Trim().Length)).Value = oRegistroEN.DescCuenta.Trim();
                Comando.Parameters.Add(new MySqlParameter("@SaldoCuenta", MySqlDbType.Decimal)).Value = oRegistroEN.SaldoCuenta;
                Comando.Parameters.Add(new MySqlParameter("@NivelCuenta", MySqlDbType.Int32)).Value   = oRegistroEN.NivelCuenta;
                Comando.Parameters.Add(new MySqlParameter("@CuentaMadre", MySqlDbType.VarChar, oRegistroEN.CuentaMadre.Trim().Length)).Value = oRegistroEN.CuentaMadre.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;
                Comando.Parameters.Add(new MySqlParameter("@idCategoriaDeCuenta", MySqlDbType.Int32)).Value     = oRegistroEN.oCategoriaDeCuentaEN.idCategoriaDeCuenta;
                Comando.Parameters.Add(new MySqlParameter("@idTipoDeCuenta", MySqlDbType.Int32)).Value          = oRegistroEN.oTipoDeCuentaEN.idTipoDeCuenta;

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

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

                oRegistroEN.NoCuenta = Convert.ToInt32(DT.Rows[0].ItemArray[0].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;
            }
        }
Esempio n. 20
0
        public bool ValidarSiElRegistroEstaVinculado(CuentaEN 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 = "NoCuenta";
                Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value    = oRegistroEN.NoCuenta;
                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", "REGISTRO VINCULADO A OTRAS TABLAS", "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);
                TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO VINCULADO A OTRAS TABLAS", "CORRECTO");
                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;
            }
        }