示例#1
0
        private void dgvTelefonos_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            try
            {
                if (e.Clicks == 2)
                {
                    if (e.RowHandle >= 0 && ModoOperacion == ModoOperacion.Modificacion)
                    {
                        // Cambiar imagen del botón agregar y mostrar el boton de quitar
                        btnAgregarTelefono.BackgroundImage = Properties.Resources.edit_validated_40458;
                        btnQuitarTelefono.Visible          = true;

                        // Obtener datos de la fila selecciona y llenar objeto entidad y controles con dichos datos
                        DataRow FilaSeleccionada = dgvTelefonos.GetDataRow(e.RowHandle);
                        Telefono = new Emp.TELEFONOS
                        {
                            IdTelefono     = (int)FilaSeleccionada["IdTelefono"],
                            IdPersona      = Empleado.IdPersona,
                            IdTipoTelefono = (int)FilaSeleccionada["IdTipoTelefono"],
                            Telefono       = FilaSeleccionada["Telefono"].ToString(),
                            Activo         = FilaSeleccionada["Activo"].ToString()
                        };
                        txtTelefono.Text = Telefono.Telefono;
                        cmbTipoTelefono.SelectedValue = Telefono.IdTipoTelefono;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnAgregarTelefono.BackgroundImage = Properties.Resources.anadir;
                btnQuitarTelefono.Visible          = false;
            }
        }
示例#2
0
        public void ABCTELEFONOS(char Op, Emp.TELEFONOS TELEFONOS)
        {
            const string querySql = "Emp.prTELEFONOS";
            int          IntReturn;

            try
            {
                using (SqlConnection connection = _objPersistencia.GetSqlConnection())
                {
                    connection.Open();

                    using (SqlCommand sqlCmnd = _objPersistencia.GetSqlCommand(connection, querySql, CommandType.StoredProcedure))
                    {
                        sqlCmnd.Parameters.AddWithValue("@Op", Op);
                        sqlCmnd.Parameters.AddWithValue("@IdTelefono", TELEFONOS.IdTelefono);
                        sqlCmnd.Parameters.AddWithValue("@IdPersona", TELEFONOS.IdPersona);
                        sqlCmnd.Parameters.AddWithValue("@IdTipoTelefono", TELEFONOS.IdTipoTelefono);
                        sqlCmnd.Parameters.AddWithValue("@Telefono", TELEFONOS.Telefono);
                        sqlCmnd.Parameters.AddWithValue("@Activo", TELEFONOS.Activo);

                        // Ejecucion del sqlCommand
                        using (SqlDataReader reader = sqlCmnd.ExecuteReader())
                        {
                            if (!reader.Read())
                            {
                                throw new Exception("La ejecución del Store Procedure no arrojó ningun dato");
                            }

                            // Verificamos el resultado de la ejecucion de sp 0 = correcto y 1 existe algun error
                            IntReturn = (int)reader["Result"];

                            if (IntReturn >= 1)
                            {
                                throw new Exception(reader["MensajeError"].ToString());
                            }
                            if (IntReturn == 1)
                            {
                                throw new Exception($"{reader["MensajeError"]}\n\nSP: {querySql}");
                            }

                            reader.Close();
                        }

                        connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#3
0
 private void btnQuitarTelefono_Click(object sender, EventArgs e)
 {
     try
     {
         LnEmp.ABCTELEFONOS('B', Telefono);
         txtTelefono.ResetText();
         LlenaGridTelefonos();
         Telefono = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     finally
     {
         btnAgregarTelefono.BackgroundImage = Properties.Resources.anadir;
         btnQuitarTelefono.Visible          = false;
     }
 }
示例#4
0
        private void btnAgregarTelefono_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidarTelefono())
                {
                    // Se trata de una alta
                    if (Telefono == null)
                    {
                        Telefono = new Emp.TELEFONOS
                        {
                            IdPersona      = Empleado.IdPersona,
                            IdTipoTelefono = (int)cmbTipoTelefono.SelectedValue,
                            Telefono       = txtTelefono.Text.Trim(),
                            Activo         = "1"
                        };

                        LnEmp.ABCTELEFONOS('A', Telefono);
                    }
                    else // Es una modificación
                    {
                        Telefono.Telefono       = txtTelefono.Text.Trim();
                        Telefono.IdTipoTelefono = (int)cmbTipoTelefono.SelectedValue;
                        LnEmp.ABCTELEFONOS('C', Telefono);
                        btnAgregarTelefono.BackgroundImage = Properties.Resources.anadir;
                    }

                    // Limpiar los controles de captura
                    txtTelefono.ResetText();
                    LlenaGridTelefonos();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                btnAgregarTelefono.BackgroundImage = Properties.Resources.anadir;
                btnQuitarTelefono.Visible          = false;
                Telefono = null;
            }
        }
示例#5
0
 public void ABCTELEFONOS(char Op, Emp.TELEFONOS TELEFONOS)
 {
     _objAdEmpleados.ABCTELEFONOS(Op, TELEFONOS);
 }