Beispiel #1
0
        public bool ModificarCargos(DataRepository.PropiedadesCargos cargo, int id)
        {
            string     sqlModificar = @"Update Usuario.Puesto_Empleados set Nombre_Puesto = @Nombre_Puesto Where Id_PuestoEmpleado = @id";
            SqlCommand command      = conn.Comando(sqlModificar);

            try
            {
                conn.DbOpen();
                using (command)
                {
                    command.Parameters.Add("@id", SqlDbType.Int).Value = id;
                    command.Parameters.Add("@Nombre_Puesto", SqlDbType.VarChar).Value = cargo.Nombre_Puesto;
                    command.ExecuteNonQuery();
                }
                return(true);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.DbClose();
            }
        }
Beispiel #2
0
        public bool InsertarCargo(DataRepository.PropiedadesCargos cargo)
        {
            string sqlInsertar = @"Insert into Usuario.Puesto_Empleados (Nombre_Puesto) values (@Nombre_Puesto)";

            SqlCommand command = conn.Comando(sqlInsertar);

            try
            {
                conn.DbOpen();
                using (command)
                {
                    command.Parameters.Add("@Nombre_Puesto", SqlDbType.VarChar).Value = cargo.Nombre_Puesto;
                    command.ExecuteNonQuery();
                    MessageBox.Show("Se ha agregado exitosamente el cargo.");
                }
                return(true);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("No se puede ingresar este nuevo cargo, ya que el nombre existe.");
                return(false);
            }
            finally
            {
                conn.DbClose();
            }
        }