Exemplo n.º 1
0
        private void LlenarInformacionDelCargo()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                CargoEN oRegistroEN = new CargoEN();
                CargoLN oRegistroLN = new CargoLN();
                oRegistroEN.Where   = "";
                oRegistroEN.OrderBy = "";

                if (oRegistroLN.Listado(oRegistroEN, Program.oDatosDeConexioEN))
                {
                    cmbCargo.DataSource    = oRegistroLN.TraerDatos();
                    cmbCargo.DisplayMember = "Cargo";
                    cmbCargo.ValueMember   = "IdCargo";
                    cmbCargo.SelectedIndex = -1;
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Información de los tipos de cuentas", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 2
0
        public bool ValidarRegistroDuplicado(CargoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                InicialisarVariablesGlovales(oDatos);

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

                    Consultas = @"SELECT CASE WHEN EXISTS(Select IdCargo from cargo where upper(trim(Cargo)) = upper(trim(@Cargo))) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Cargo", MySqlDbType.VarChar, oRegistroEN.Cargo.Trim().Length)).Value = oRegistroEN.Cargo.Trim();

                    break;

                case "ACTUALIZAR":

                    Consultas = @"SELECT CASE WHEN EXISTS(Select IdCargo from cargo where upper(trim(Cargo)) = upper(trim(@Cargo)) and IdCargo <> @IdCargo) THEN 1 ELSE 0 END AS 'RES'";
                    Comando.Parameters.Add(new MySqlParameter("@Cargo", MySqlDbType.VarChar, oRegistroEN.Cargo.Trim().Length)).Value = oRegistroEN.Cargo.Trim();
                    Comando.Parameters.Add(new MySqlParameter("@IdCargo", MySqlDbType.Int32)).Value = oRegistroEN.IdCargo;

                    break;

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

                Comando.CommandText = Consultas;

                InicialisarAdaptador();

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

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

                DescripcionDeLaOperacion = 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 oTransaccion = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "REGISTRO DUPLICADO DENTRO DE LA BASE DE DATOS", "ERROR");
                oTransaccionesAD.Agregar(oTransaccion, oDatos);

                return(false);
            }
            finally
            {
                FinalizarConexion();
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 3
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 oCargo, a);

                        oCargo[a - 1]         = new CargoEN();
                        oCargo[a - 1].IdCargo = Convert.ToInt32(Fila.Cells["IdCargo"].Value);
                        oCargo[a - 1].Cargo   = Fila.Cells["Cargo"].Value.ToString();
                    }
                }

                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
Exemplo n.º 4
0
        public bool ListadoPorID(CargoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = string.Format(@"Select IdCargo, Cargo from Cargo where IdCargo = @IdCargo", oRegistroEN.IdCargo);

                Comando.CommandText = Consultas;

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

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
Exemplo n.º 5
0
        private string InformacionDelRegistro(CargoEN oRegistroEN)
        {
            string Cadena = @"IdCargo: {0}, Cargo: {1}";

            Cadena = string.Format(Cadena, oRegistroEN.IdCargo, oRegistroEN.Cargo);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
Exemplo n.º 6
0
        private void tsbGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    CargoEN oRegistroEN = InformacionDelRegistro();
                    CargoLN oRegistroLN = new CargoLN();

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

                    if (oRegistroLN.Agregar(oRegistroEN, Program.oDatosDeConexioEN))
                    {
                        txtIdentificador.Text     = oRegistroEN.IdCargo.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.IdCargo;

                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "GUARDAR");

                        oRegistroEN = null;
                        oRegistroLN = null;

                        this.Cursor = Cursors.Default;

                        if (CerrarVentana == true)
                        {
                            this.Close();
                        }
                        else
                        {
                            OperacionARealizar = "GUARDAR";
                            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.º 7
0
 public bool ListadoPorIdentificador(CargoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oCargoAD.ListadoPorID(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCargoAD.Error;
         return(false);
     }
 }
Exemplo n.º 8
0
 public bool ValidarSiElRegistroEstaVinculado(CargoEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oCargoAD.ValidarSiElRegistroEstaVinculado(oREgistroEN, oDatos, TipoDeOperacion))
     {
         Error = oCargoAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
Exemplo n.º 9
0
 public bool Agregar(CargoEN oRegistroEN, DatosDeConexionEN oDatos)
 {
     if (oCargoAD.Agregar(oRegistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCargoAD.Error;
         return(false);
     }
 }
Exemplo n.º 10
0
 public bool ListadoParaReportes(CargoEN oREgistroEN, DatosDeConexionEN oDatos)
 {
     if (oCargoAD.ListadoParaReportes(oREgistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCargoAD.Error;
         return(false);
     }
 }
Exemplo n.º 11
0
        private CargoEN InformacionDelRegistro()
        {
            CargoEN oRegistroEN = new CargoEN();

            oRegistroEN.IdCargo = Convert.ToInt32((txtIdentificador.Text.Length > 0 ? txtIdentificador.Text : "0"));
            oRegistroEN.Cargo   = 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);
        }
Exemplo n.º 12
0
        public bool ValidarSiElRegistroEstaVinculado(CargoEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                InicialisarVariablesGlobalesProcedure(oDatos);

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

                InicialisarAdaptador();

                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));
                    DescripcionDeLaOperacion = this.Error;

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

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

                DescripcionDeLaOperacion = 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 oTransaccion = InformacionDelaTransaccion(oRegistroEN, "VALIDAR", "VALIDAR SI EL REGISTRO ESTA VINCULADO", "ERROR");
                oTransaccionesAD.Agregar(oTransaccion, oDatos);

                return(false);
            }
            finally
            {
                FinalizarConexion();
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 13
0
 public bool Actualizar(CargoEN oRegistrEN, DatosDeConexionEN oDatos)
 {
     if (string.IsNullOrEmpty(oRegistrEN.IdCargo.ToString()) || oRegistrEN.IdCargo == 0)
     {
         this.Error = @"Se debe seleccionar un elemento de la lista";
         return(false);
     }
     if (oCargoAD.Actualizar(oRegistrEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oCargoAD.Error;
         return(false);
     }
 }
Exemplo n.º 14
0
        private void LlenarCamposDesdeBaseDatosSegunID()
        {
            this.Cursor = Cursors.WaitCursor;

            CargoEN oRegistrosEN = new CargoEN();
            CargoLN oRegistrosLN = new CargoLN();

            oRegistrosEN.IdCargo = ValorLlavePrimariaEntidad;

            if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexioEN))
            {
                if (oRegistrosLN.TraerDatos().Rows.Count > 0)
                {
                    DataRow Fila = oRegistrosLN.TraerDatos().Rows[0];
                    txtNombre.Text = Fila["Cargo"].ToString();
                    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.", Nombre_Entidad);

                    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.º 15
0
        /// <summary>
        /// Agrega (INSERTA) El Registro En La Tabla ***CARGO***
        /// </summary>
        /// <param name="oRegistroEN"></param>
        /// <param name="oDatos"></param>
        /// <returns></returns>
        public bool Agregar(CargoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();
            try
            {
                InicialisarVariablesGlovales(oDatos);
                Consultas = @"insert into Cargo
                        (Cargo)
                        values
                        (@Cargo);
                        Select  last_insert_ID() as 'ID';";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@Cargo", MySqlDbType.VarChar, oRegistroEN.Cargo.Trim().Length)).Value = oRegistroEN.Cargo.Trim();

                InicialisarAdaptador();

                oRegistroEN.IdCargo = Convert.ToInt32(DT.Rows[0].ItemArray[0].ToString());

                DescripcionDeLaOperacion = string.Format("El registro se ha insertado correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN));

                TransaccionesEN oTransacciones = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTransacciones, oDatos);

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

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

                TransaccionesEN oTransacciones = InformacionDelaTransaccion(oRegistroEN, "Agregar", "Agregar Nuevo Registro", "ERROR");
                oTransaccionesAD.Agregar(oTransacciones, oDatos);

                return(false);
            }
            finally
            {
                FinalizarConexion();
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 16
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 oCargo, a);

                            oCargo[a - 1]         = new CargoEN();
                            oCargo[a - 1].IdCargo = Convert.ToInt32(Fila.Cells["ID"].Value);
                            oCargo[a - 1].Cargo   = Fila.Cells["Cargo"].Value.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                AgregarRegistroAlDTUsuario();
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
Exemplo n.º 17
0
        private void LlenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                CargoEN oRegistroEN = new CargoEN();
                CargoLN oRegistroLN = new CargoLN();

                oRegistroEN.Where = WhereDinamico();

                if (oRegistroLN.Listado(oRegistroEN, Program.oDatosDeConexioEN))
                {
                    dgvLista.Columns.Clear();
                    System.Diagnostics.Debug.Print(oRegistroLN.TraerDatos().Rows.Count.ToString());

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

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

                    tsbNoRegistros.Text = "No. Registros: " + oRegistroLN.TotalRegistros().ToString();
                }
                else
                {
                    throw new ArgumentException(oRegistroLN.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.º 18
0
        private TransaccionesEN InformacionDelaTransaccion(CargoEN oCargo, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.IdRegistro = oCargo.IdCargo;
            oRegistroEN.Modelo     = "CargoAD";
            //oRegistroEN.Modulo = "#";
            oRegistroEN.Tabla           = "Cargo";
            oRegistroEN.TipoDeOperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.IP                    = oCargo.oLoginEN.NumeroIP;
            oRegistroEN.IdUsuario             = oCargo.oLoginEN.IdUsuario;
            oRegistroEN.IdUsuarioAPrueva      = oCargo.oLoginEN.IdUsuario;
            oRegistroEN.DescripcionDelUsuario = DescripcionDeLaOperacion;
            oRegistroEN.DescripcionInterna    = Descripcion;
            oRegistroEN.nombredelequipo       = oCargo.oLoginEN.NombreDelEquipo;

            return(oRegistroEN);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Actualizar El Registro En La Tabla ***CARGO***
        /// </summary>
        /// <param name="oRegistroEN"></param>
        /// <param name="oDatos"></param>
        /// <returns></returns>
        public bool Actualizar(CargoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();

            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = @"update Cargo set Cargo = @Cargo where IdCargo = @IdCargo;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@IdCargo", MySqlDbType.Int32)).Value = oRegistroEN.IdCargo;
                Comando.Parameters.Add(new MySqlParameter("@Cargo", MySqlDbType.VarChar, oRegistroEN.Cargo.Trim().Length)).Value = oRegistroEN.Cargo.Trim();

                Comando.ExecuteNonQuery();

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

                TransaccionesEN oTransacciones = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTransacciones, oDatos);

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

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

                TransaccionesEN oTransacciones = InformacionDelaTransaccion(oRegistroEN, "Actualizar", "Actualizar Registro", "ERROR");
                oTransaccionesAD.Agregar(oTransacciones, oDatos);

                return(false);
            }
            finally
            {
                FinalizarConexion();
                oTransaccionesAD = null;
            }
        }
Exemplo n.º 20
0
        public bool ListadoParaReportes(CargoEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas           = string.Format(@"select IdCargo, Cargo from cargo where IdCargo > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);
                Comando.CommandText = Consultas;

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
Exemplo n.º 21
0
        private void tsbActualizar_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 aplicar los cambios al registro seleccionado?", "Actualizar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }

                    CargoEN oRegistroEN = InformacionDelRegistro();
                    CargoLN oRegistroLN = new CargoLN();

                    if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexioEN, "ACTUALIZAR"))
                    {
                        if (PermitirCambiarRegistroAunqueEstenVinculados == true && AplicarCambio == true)
                        {
                            if (MessageBox.Show(string.Format("Está seguro que desea actualizar los cambios en el registro seleccionado ya que este se encuentra asociado a otras Entidades de manera interna? {0} {1}", Environment.NewLine, oRegistroLN.Error), "Confirmación de Actualización", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.OK)
                            {
                                this.Cursor = Cursors.Default;
                                return;
                            }
                        }
                        else
                        {
                            this.Cursor = Cursors.Default;
                            MessageBox.Show(oRegistroLN.Error, "Actualizar la información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexioEN, "ACTUALIZAR"))
                    {
                        this.Cursor = Cursors.Default;
                        MessageBox.Show(oRegistroLN.Error, "Actualizar la información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    if (oRegistroLN.Actualizar(oRegistroEN, Program.oDatosDeConexioEN))
                    {
                        txtIdentificador.Text     = oRegistroEN.IdCargo.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.IdCargo;

                        EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "ACTUALIZAR");

                        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, "Actualizar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 22
0
        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;
                    }

                    CargoEN oRegistroEN = InformacionDelRegistro();
                    CargoLN oRegistroLN = new CargoLN();

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

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

                        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;
            }
        }