示例#1
0
        public bool Actualizar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = @"UPDATE faltas set
	                            Fecha = @Fecha, 
                                IdEmpleado = @IdEmpleado                    
                            where IdFaltas = @IdFaltas;";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@IdFaltas", MySqlDbType.Int32)).Value   = oRegistroEN.IdFaltas;
                Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.Date)).Value       = oRegistroEN.Fecha;
                Comando.Parameters.Add(new MySqlParameter("@IdEmpleado", MySqlDbType.Int32)).Value = oRegistroEN.oEmpleadoEN.IdEmpleado;

                Comando.ExecuteNonQuery();

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#2
0
        public bool Listado(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = string.Format(@"Select IdFaltas, Fecha, IdEmpleado from faltas where IdFaltas = 0 {0} {1}", oRegistroEN.Where, oRegistroEN.OrderBy);

                Comando.CommandText = Consultas;

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#3
0
        public bool ValidarSiElRegistroEstaVinculado(FaltasEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
        {
            try
            {
                InicialisarVariablesGlobalesProcedure(oDatos);

                Comando.Parameters.Add(new MySqlParameter("@CampoABuscar_", MySqlDbType.VarChar, 200)).Value = "IdFaltas";
                Comando.Parameters.Add(new MySqlParameter("@ValorCampoABuscar", MySqlDbType.Int32)).Value    = oRegistroEN.IdFaltas;
                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
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                this.Error = ex.Message;

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#4
0
        public bool Agregar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);
                Consultas = @"insert into faltas 
				                (Fecha, IdEmpleado) 
                                values 
                                (@Fecha, @IdEmpleado);
                            Select  last_insert_ID() as 'ID';";

                Comando.CommandText = Consultas;

                Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.Datetime)).Value   = oRegistroEN.Fecha;
                Comando.Parameters.Add(new MySqlParameter("@IdEmpleado", MySqlDbType.Int32)).Value = oRegistroEN.oEmpleadoEN.IdEmpleado;

                InicialisarAdaptador();

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

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#5
0
        public bool ListadoPorID(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = string.Format(@"Select IdFaltas, Fecha, emp.IdEmpleado, emp.Nombre as 'Empleado' from faltas as fts
                                            inner join empleado as emp on emp.IdEmpleado = fts.IdEmpleado
                                            where IdFaltas = @IdFaltas", oRegistroEN.IdFaltas);

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

                Comando.CommandText = Consultas;

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#6
0
        public bool ListadoParaReportes(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = string.Format(@"Select IdFaltas, Fecha, emp.IdEmpleado, emp.Nombre as 'Empleado' from faltas as fts
                                            inner join empleado as emp on emp.IdEmpleado = fts.IdEmpleado
                                            where IdFaltas > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy);

                Comando.CommandText = Consultas;

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#7
0
        public bool Eliminar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = @"delete from faltas where IdFaltas = @IdFaltas;";

                Comando.CommandText = Consultas;

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

                Comando.ExecuteNonQuery();

                InicialisarAdaptador();

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
            }
        }
示例#8
0
        private void dgvLista_DoubleClick(object sender, EventArgs e)
        {
            if (ActivarFiltros == true)
            {
                int a = 1;

                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 oFaltas, a);

                        oFaltas[a - 1]                    = new FaltasEN();
                        oFaltas[a - 1].IdFaltas           = Convert.ToInt32(Fila.Cells["IdFaltas"].Value);
                        oFaltas[a - 1].Fecha              = Convert.ToDateTime(Fila.Cells["Fecha"].Value.ToString());
                        oFaltas[a - 1].oEmpleadoEN.Nombre = Fila.Cells["Empleado"].ToString();
                    }
                }
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
        private void tsbGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                if (LosDatosIngresadosSonCorrectos())
                {
                    FaltasEN oRegistroEN = InformacionDelRegistro();
                    FaltasLN oRegistroLN = new FaltasLN();

                    /*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.IdFaltas.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.IdFaltas;

                        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;
            }
        }
示例#10
0
        private string InformacionDelRegistro(FaltasEN oRegistroEN)
        {
            string Cadena = @"IdFaltas: {0}, Fecha: {1}, IdEmpleado: {2}";

            Cadena = string.Format(Cadena, oRegistroEN.IdFaltas, oRegistroEN.Fecha, oRegistroEN.oEmpleadoEN.IdEmpleado);
            Cadena = Cadena.Replace(",", Environment.NewLine);
            return(Cadena);
        }
示例#11
0
 public bool Eliminar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
 {
     if (oFaltasAD.Eliminar(oRegistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oFaltasAD.Error;
         return(false);
     }
 }
示例#12
0
 public bool ListadoPorIdentificador(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
 {
     if (oFaltasAD.ListadoPorID(oRegistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oFaltasAD.Error;
         return(false);
     }
 }
示例#13
0
 public bool ListadoParaCombos(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
 {
     if (oFaltasAD.ListadoParaCombos(oRegistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oFaltasAD.Error;
         return(false);
     }
 }
示例#14
0
 public bool ValidarSiElRegistroEstaVinculado(FaltasEN oRegistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion)
 {
     if (oFaltasAD.ValidarSiElRegistroEstaVinculado(oRegistroEN, oDatos, TipoDeOperacion))
     {
         Error = oFaltasAD.Error;
         return(true);
     }
     else
     {
         Error = string.Empty;
         return(false);
     }
 }
示例#15
0
        private FaltasEN InformacionDelRegistro()
        {
            FaltasEN oRegistroEN = new FaltasEN();

            oRegistroEN.IdFaltas = Convert.ToInt32((txtIdentificador.Text.Length > 0 ? txtIdentificador.Text : "0"));
            oRegistroEN.Fecha    = dtpFecha.Value;

            oRegistroEN.oEmpleadoEN.IdEmpleado = Convert.ToInt32(cmbEmpleado.SelectedValue);
            oRegistroEN.oEmpleadoEN.Nombre     = cmbEmpleado.Text.Trim();

            //partes generales.
            oRegistroEN.oLoginEN = Program.oLoginEN;

            return(oRegistroEN);
        }
示例#16
0
        private void LlenarCamposDesdeBaseDatosSegunID()
        {
            this.Cursor = Cursors.WaitCursor;

            FaltasEN oRegistrosEN = new FaltasEN();
            FaltasLN oRegistrosLN = new FaltasLN();

            oRegistrosEN.IdFaltas = ValorLlavePrimariaEntidad;

            if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexioEN))
            {
                if (oRegistrosLN.TraerDatos().Rows.Count > 0)
                {
                    DataRow Fila = oRegistrosLN.TraerDatos().Rows[0];

                    dtpFecha.Value            = Convert.ToDateTime(Fila["Fecha"].ToString());
                    cmbEmpleado.SelectedValue = Convert.ToInt32(Fila["IdEmpleado"].ToString());
                    cmbEmpleado.Text          = Fila["Empleado"].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;
        }
示例#17
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 oFaltas, a);

                            oFaltas[a - 1]                    = new FaltasEN();
                            oFaltas[a - 1].IdFaltas           = Convert.ToInt32(Fila.Cells["ID"].Value);
                            oFaltas[a - 1].Fecha              = Convert.ToDateTime(Fila.Cells["Tipo De Contrato"].Value.ToString());
                            oFaltas[a - 1].oEmpleadoEN.Nombre = Fila.Cells["Empleado"].Value.ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                AgregarRegistroAlDTUsuario();
                this.Cursor = Cursors.Default;
                this.Close();
            }
        }
示例#18
0
 public bool Actualizar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
 {
     if (string.IsNullOrEmpty(oRegistroEN.IdFaltas.ToString()) || oRegistroEN.IdFaltas == 0)
     {
         this.Error = @"Se debe seleccionar un elemneto de la lista.";
         return(false);
     }
     if (oFaltasAD.Actualizar(oRegistroEN, oDatos))
     {
         Error = string.Empty;
         return(true);
     }
     else
     {
         Error = oFaltasAD.Error;
         return(false);
     }
 }
示例#19
0
        private void LlenarListado()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                FaltasEN oRegistroEN = new FaltasEN();
                FaltasLN oRegistroLN = new FaltasLN();

                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;
            }
        }
示例#20
0
        public bool Agregar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();
            try
            {
                InicialisarVariablesGlovales(oDatos);
                Consultas = @"insert into faltas 
				                (Fecha, IdEmpleado) 
                                values 
                                (@Fecha, @IdEmpleado);
                            Select  last_insert_ID() as 'ID';";

                Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.Date)).Value       = oRegistroEN.Fecha;
                Comando.Parameters.Add(new MySqlParameter("@IdEmpleado", MySqlDbType.Int32)).Value = oRegistroEN.oEmpleadoEN.IdEmpleado;

                InicialisarAdaptador();

                oRegistroEN.IdFaltas = 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;
            }
        }
示例#21
0
        private TransaccionesEN InformacionDelaTransaccion(FaltasEN oFaltas, String TipoDeOperacion, String Descripcion, String Estado)
        {
            TransaccionesEN oRegistroEN = new TransaccionesEN();

            oRegistroEN.IdRegistro      = oFaltas.IdFaltas;
            oRegistroEN.Modelo          = "FaltasAD";
            oRegistroEN.Modulo          = "General";
            oRegistroEN.Tabla           = "Faltas";
            oRegistroEN.TipoDeOperacion = TipoDeOperacion;
            oRegistroEN.Estado          = Estado;
            oRegistroEN.IP                    = oFaltas.oLoginEN.NumeroIP;
            oRegistroEN.IdUsuario             = oFaltas.oLoginEN.IdUsuario;
            oRegistroEN.IdUsuarioAPrueva      = oFaltas.oLoginEN.IdUsuario;
            oRegistroEN.DescripcionDelUsuario = DescripcionDeLaOperacion;
            oRegistroEN.DescripcionInterna    = Descripcion;
            oRegistroEN.nombredelequipo       = oFaltas.oLoginEN.NombreDelEquipo;

            return(oRegistroEN);
        }
示例#22
0
        public bool Actualizar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = @"UPDATE faltas set
	                            Fecha = @Fecha, 
                                IdEmpleado = @IdEmpleado                    
                            where IdFaltas = @IdFaltas;";

                Comando.Parameters.Add(new MySqlParameter("@IdFaltas", MySqlDbType.Int32)).Value   = oRegistroEN.IdFaltas;
                Comando.Parameters.Add(new MySqlParameter("@Fecha", MySqlDbType.Date)).Value       = oRegistroEN.Fecha;
                Comando.Parameters.Add(new MySqlParameter("@IdEmpleado", MySqlDbType.Int32)).Value = oRegistroEN.oEmpleadoEN.IdEmpleado;

                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;
            }
        }
示例#23
0
        public bool Eliminar(FaltasEN oRegistroEN, DatosDeConexionEN oDatos)
        {
            oTransaccionesAD = new TransaccionesAD();
            try
            {
                InicialisarVariablesGlovales(oDatos);

                Consultas = @"delete from faltas where IdFaltas = @IdFaltas;";

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

                Comando.ExecuteNonQuery();

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

                //Agregamos la transaccion...
                TransaccionesEN oTransacciones = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Elminar Registro", "CORRECTO");
                oTransaccionesAD.Agregar(oTransacciones, oDatos);

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

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

                return(false);
            }
            finally
            {
                FinalizarConexion();
                oTransaccionesAD = null;
            }
        }
示例#24
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;
                    }

                    FaltasEN oRegistroEN = InformacionDelRegistro();
                    FaltasLN oRegistroLN = new FaltasLN();

                    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.IdFaltas.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.IdFaltas;

                        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;
            }
        }
示例#25
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;
                    }

                    FaltasEN oRegistroEN = InformacionDelRegistro();
                    FaltasLN oRegistroLN = new FaltasLN();

                    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.IdFaltas.ToString();
                        ValorLlavePrimariaEntidad = oRegistroEN.IdFaltas;

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